


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Question 1. (25 points) Translate the following high-level language code segment to ARM assembly language. Use the registers indicated in the code.
a) for R0 = 0 to 100 by steps of size 10 do if (R3 < R0) AND (R2 >= 50) then R2 = R2 + R end if end for
b) while (R8 > 20) do if (R8 < 100) OR (R8 > 200) then R7 = R R8 = R8 - 10 else R8 = R8 - R end if R7 = R6 + 4 end while
Question 2. (10 points) Suppose you have the following data AREA in ARM assembly language:
For each of the following assembly language segments, what value is loaded into register R2?
d) MOV R0, # LDR R1, POINTER LDR R2, [R1, R0, LSL #2]
b) LDR R1, POINTER MOV R4, # ADD R3, R1, R4, LSR # LDR R2, [R3]
c) LDR R0, N LDR R1, POINTER LDR R2, [R1, R0, LSL #3]
a) LDR R0, N LDR R1, POINTER LDR R2, [R1, R0, LSL #2]
Question 3. (7 points) For the data AREA in question 2, complete the translation of the following high-level code segment to ARM assembly language.
end for FOR CMP R0, #
array[i+1] = array[i] MOV R0, #
for i = 0 to 14 do LDR R1, POINTER
Question 4. (8 points) The ARM Compare instruction "CMP R2, R3" sets the condition codes (N, Z, C, V bits) according to the result of (R2 - R3). For the ARM conditional-branch instruction "BLT LABEL" (branch less than), what must the condition code values be inorder for the branch to be taken?
g) (10 points) Using the registers you indicated, write the ARM assembly language statements to perform the statements:
temp = numbers[lastUnsortedIndex] numbers[lastUnsortedIndex] = numbers[maxIndex] numbers[maxIndex] = temp