Question: HW7 Assignment (20 points) Answer the following questions: 1. What are the lowest and highest addresses in a 220 byte memory in which a four-byte

HW7 Assignment (20 points) Answer the following questions:

1. What are the lowest and highest addresses in a 220 byte memory in which a four-byte word is the smallest addressable unit? ( 2 points )

2. Make a table indicating which of the instruction addcc, andcc, orcc, and the synthetic instruction not, can set the z, n, c and v flags to 1. ( 2 points )

3. Which of the following ARC instructions are legal, and if not, why not? Assume l_b is 0xFFFB. ( 6 points )

a. sethi 0xABCDEF, %r12

b. or %r15, 0x1FFF, %r22

c. srl %r8, 32, %r9

4. A section of ARC assembly code is shown below. What does it do? Express your answer in terms of the actions it goes through. Does it add up numbers, or clear something out? Does it simulate a for loop, a while loop or something else? Assume that a and b are memory locations that are defined elsewhere in the code. ( 4 points )

Y : ld [k], %r1

addcc %r1, -4, %r1

st %r1, [k]

bneg X

ld [a], %r1, %r2

ld [b], %r1, %r3

addcc %r2, %r3, %r4

st %r4, %r1, [c]

ba Y

X : jmpl %r15 + 4, %r0

k : 40

5. An ARC program calls the subroutine foo, passing it three arguments, a, b and c. The subroutine has two local variables, m and n. Show the position of the stack pointer and the contents of the relevant stack elements for a stack-based calling convention at the points in the program shown below. Note that subroutine foo does not return anything.

a. Just before executing the call at label x

b. When the stack frame for foo is completed

c. Just before executing the ld at label z (i.e. when the calling routine resumes)

Use the stack notation shown in textbook Figure 4-27. ( 3 points )

! Push the arguments a, b and c

x : call foo

z : ld %r1, %r2

. . .

foo: ! subroutine starts here

. . .

y : jmpl %r15 + 4, %r0

6. A program compile for a SPARC ISA writes the 32-bit unsigned integer 0xABCDEF01 to a file, and reads it back correctly. The same program complied for a Pentium ISA also works correctly. However, when the file is transferred between machines, the program incorrectly read the integer from the file as 0x01EFCDAB. What is going wrong? ( 1 point )

7. Why does sethi only load the high 22 bits of a register? It would be more useful if sethi loaded all 32 bits of a register. What is the problem with having sethi load all 32 bits? (2 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!