Code Segment - Computer Organization - Homework, Exercises of Computer Architecture and Organization

These HOMEWOR NOTES are very easy to understand and very helpful to built a concept about the foundation of computers ORGANIZATION and Database Design.The key points in these slide are:Code Segment, High-Level Language, Assembly Language, Registers Indicated in Code, Language Segments, High-Level Code Segment, Condition Codes, Conditional-Branch Instruction, Condition Code Values, Selection Sort

Typology: Exercises

2012/2013

Uploaded on 04/27/2013

arundhati
arundhati 🇮🇳

4.5

(23)

88 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Organization Test 2
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 + R3
end if
end for
b) while (R8 > 20) do
if (R8 < 100) OR (R8 > 200) then
R7 = R8
R8 = R8 - 10
else
R8 = R8 - R7
end if
R7 = R6 + 4
end while
Spring 2003 Name: ______________________
Docsity.com
pf3
pf4

Partial preview of the text

Download Code Segment - Computer Organization - Homework and more Exercises Computer Architecture and Organization in PDF only on Docsity!

Computer Organization Test 2

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:

AREA DATA, READWRITE

ARRAY DCD 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25

N DCD 5

POINTER DCD ARRAY

END

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

B FOR

BGT END_FOR

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