Use the following assembly code to answer the questions below, assuming that:
X19 = f, X20 = g, X21 = i, X22 = &a
LDUR X19, [X22, #0]
LDUR X20, [X22, #8]
ADDI X21, XZR, #0
LOOP: SUB X9, X19, X20
CBZ ENDLOOP
ADDI X19, X19, #1
ADDI X21, X21, #1
B LOOP
ENDLOOP: STUR X21, [X22, #16]
a.What value would the assembler insert for ENDLOOP in the CBZ instruction?
b. What value would the assembler insert for LOOP in the B instruction?
c.If a[0] = 5 and a[1] = 8, what value will be stored in a[2]?
d. How many R, D, I, B, and CBZ instructions are executed if a[0] = 5 and a[1] = 8?
A. if X9 =0 then CBZ execute succesfully then it goto to ENDLOOP so CBZ must be zero.
B. It is branch unconditionally to instruction labeled to LOOP.
C. It is a counter that will increase till a[0] become equal to a[1] So answer would be 3.
D. --
Use the following assembly code to answer the questions below, assuming that: X19 = f, X20...
Translate the following LEGv8 assembly into C, assuming that: X19 = f, X20 = g, X21 = h, X22 = &a SUB X9, X20, X21 CBZ X9, ELSE LSL X9, X20, #3 ADD X9, X22, X9 LDUR X19, [X9, #0] B END ELSE: LDUR X19, [X22, #0] END: SUB X21, X19, X20
1- What is true about the following code sequence: addi x18, x0, 1 addi x19, x0, 2 addi x20, x0, 2 addi x21, x0, 4 addi x22, x0, 5 Must stall on the addi results Can avoid stalls using only forwarding Can execute without stalling or forwarding None of the above 2- What is true about the following code sequence: ld x9, 64(x22) add x9, x21, x9 Must stall on the ld result Can avoid stalls using only forwarding Can...
Convert the following C statement to the corresponding ARMv7 assembly code: Assume that the variables f, g, h, i, and j are assigned to registers X0,X1,X2,X3, and X4, respectively. Assume that the base address of the arrays A and B are in registers X6 and X7, respectively. B[8] = A[i−j]; Convert the following LEGv8 assembly instructions to ARMv7 as well as find the corresponding C statement. Assume that the variables f, g, h, i, and j are assigned to registers...
4. Convert the below C code snippet to LEGV8 assembly code. Base address of x is stored in register X19. Assume variables a, b, andc are stored in registers X20, X21, and X22 respectively. Assume all values are 64-bits. Do not use divide and multiply instructions in your code. Comment your assembly code. (30 Points) x[e] a x[1]; q [e]x x[a/2]b; x[2]; + x[1] x[2] x[c] C >> 4: x[1] +
4. Convert the below C code snippet to LEGV8...
convert C to LEGv8
(an example given below)
Q1 [15] Convert the following C code to LEG. Assume the following variable/register assignments: Base of A i X19 X20 int main { long long int A[6] = {1, 2, e, e, e, e}; for unsigned int i = 0; i < { A[i+2] myFunction (A[ i] , A[i+1] ); } return 0 } 4; i+ //convert to LEG //convert to LEG //convert the entire myFunction to LEG long long int myFunction...
Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){ rpt=rpt-1; goto loop } 2. Translate the following Risc-V code into C. variable 'i' in register x5, variable 'result' in x6 ,base address of integer 'memarray' in x10 addi x6,x0,0 addi x29,x0,100 LOOP: ld x7,0(x10) add x5,x5,x7 addi x10,x10,8 addi x6,x6,1 blt x6,x29, LOOP
2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2. $s2. 2 subi $t1. st1. 1 bne t1. 0. LOOP DONE: LOOP: it st2. $0. stl beq t2. 0. DONE addi $s2. Ss2. 2 LOOP DONE: For the loops written in MIPS assembly in the above table, assume that the register Şt1 is initialized to the value of 10. What is the value in register $s2 assuming that $s2 initially has a value of...
Problem 1 Consider the piece of ARM Cortex MO+ assembly code given below and answer the following questions: mw 1.AGAIN CMP RO, #10 BLE LESSEQUAL MOVS RO, #0 B DONE LESSEQUAL ADDS RO, RO, R1 B AGAIN 5. DONE 1. Assume RO is initialized with the value 20, what is the value of RO when the code above completes execution? How many times is Instruction 5 executed? Assume RO is initialized with the value o, and R1 with the value...
1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...
Given the assembly code below, calculate the offset value of beq instruction. (Offset value: the value in immediate field of beq) beg $80, $s1, L1 addi $81, $sl, 1 sub $81, $sl, $50 LI: add $sl, $sl, $50 Offset: Moving to another question will save this response. DOD OSC F3 8.