Given the following C variable and its assembly storage:
Variable Location i %rax
Select the line of C code that translates to the following set of assembly instructions:
test %rax,%rax jle 4008b9
Question options:
if ( i >= 0 ) |
|
if ( i < 0 ) |
|
if ( i < 1 ) |
|
|
Given code:
test %rax,%rax jle 4008b9
first instruction compares rax with itself means check if variable i is equal to 0 or less than 0 or grater than 0
second instruction jumps to given address if i is less than or equal to 0
jle meas Jump Less than or Equal
Answer:
if(i<1)
Given the following C variable and its assembly storage: Variable Location i %rax Select the line...
Systems Question 7 Question 7 options: Consider the code fragment below. What value is pushed onto the stack by the callinstruction? 0x400627 <main+55> callq 0x4004a0 <printf@plt> x 0x40062c <main+60> mov $0x400745,%edi Question 4 (2 points) Given the array declaration below, which one of the following is equivalent to a[4]? int a[10]; Question 4 options: *( a + 4 ) *( a + 1 ) *a + 1 *(a + 16) none of these Question 5 (2 points) Suppose we have...
Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) { if( j < 10) { a = 0; } else { a = 1;} } else { a = 2; }
QUESTION 5 ;:Consider the following x64 assembly code data myName db "My name is Michael. What is yours?" bss yourName db 10 text global _start start: mov rax, 1 mov rdi, 1 mov rsi, myName mov rdx, 35 syscall mov rax, 0 mov rdi, 1 mov rsi, yourName mov rdx, 10 syscall mov rax, 60 mov rdi, 0 syscall This program prints on the monitor screen the string "My name is Michael. What is yours?" and then exits. This program...
2) Write a MIPS assembly language version of the following C code segment: int A[75], B[75]; for (i = 1; i < 73; i ++) { C[i] = (A[i + 1] + A[i]) * (B[i + 2] - A[i-1]); } Arrays A, B and C start at memory location A000hex, B000hex and C000hex respectively. Try to reduce the total number of instructions and the number of expensive instructions such as multiplies. WRITE A SIMPLE CODE WORKING FOR MARS 4.5
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C program. Use a minimal number of MIPS assembly instructions: f g(h 5); For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C...
Given the following C Code segment convert it to ARM assembly. Assume the following register assignment have been made before your section of code begins. C Variable Register assignment r1 y r2 r3 r10 j r11 int x=0, y=0, z=0; int main() { for (int i = 0; i<10; i++) for (int j 0; j < 20; j++) if (i* j > 100) X++; if (i j >= 15) y++; + فہه Z = X + y; }
Compile the following C while loop into MIPS assembly code assuming the following register-variable mapping shown below. Also assume the array A holds integers.//$s0: A, $s1: I, $s2: j, $s3: x for(i=0; i<100; i++) {x=0; for(j = i + l; j < 100; j++) {x = x + A [j];} A[i] = x;}
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2; B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...
Compile the assembly code for the following C codes. Assume that i, j, and k have been stored in $s0, $s1, and $s2 respectively. The base address of the array B is stored in $s4. Please only use only TRUE MIPS instructions. for (i = k; i > 0; i = i - 2) j = i + 2k; for (i = 0; i < k; i++) for (j = 1; j < i; j++) B[2j] = B[i - k]-4