Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note: Please post your homework to ICS232 D2L on or before the due date. If you do not post your homework on or before the

Note: Please post your homework to ICS232 D2L on or before the due date.

If you do not post your homework on or before the due data, please post your late homework when complete (Late Homework: -15% Penalty).

1. (3 pts) Write a working ARCTool assembly code that emulates the logical programming construct :

IF (a = b)

THEN

C = A + B

ELSE

C = A B

Answer:

2. (3 pts) Multiple Choice. Which machine code listed below is represented by the assembly code: addcc %r5, %r5, %r6 {Answer: a, or b, or c}

Answer:

a.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1

b.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1

c.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0

3. (3 pts) Problem 4.12 Write an ARC subroutine that performs a swap operation on the 32-bit operands x=25 and y=50, which are stored in memory. Use as few registers as you can.

4. (3 pts) Chapter 5 pg191 Problem 5.1: Refer to the diagram in Figure 5.26.

Design a one-bit arthimatic logic unit (ALU) using the circuit shown below. (Figure 5.26).

On the on-bit inputs A and B your circuit must perform:

bitwise addition

AND, OR, and NOT logic

5. (3 points) Review the code and answer the following questions:

Note: ArcTool throws a syntax error when there is not a return after .end. File must end in a blank line.

.begin

main: add %r0, %r0, %r1

ld [k], %r5

call Y

halt

.org 1024

Y: subcc %r5, %r1, %r6

st %r6, [k]

bneg X

ld %r1, [a], %r2

ld %r1, [b], %r3

add %r2, %r3, %r4

st %r4, %r1, [c]

addcc %r1, 4, %r1

ba Y

X: jmpl %r15 +4, %r0

.org 1096

k: 40

.org 2048

a: 0, 1, 1, 1, 2, 3, 5, 8, 13

.org 2176

b: 0, 0, 0, 1, 1, 2, 3, 5, 8

.org 2304

c: -1, -1, -1, -1, -1, -1, -1, -1, -1

.end

a. Highlight the correct parameter passing method used to call the subroutine Y

i. Data link area

ii. Stack parameter passing

iii. Register parameter passing

b. What is the range of memory addresses for array c?:

6. (3 pts) Given the following assembly code:

.begin

LOC .org 2048

2048 prog1: ld[v], %r1 ! Load v into %r1

2052 ld[w], %r2 ! Load w into %r2

2056 ld[x], %r3 ! Load x into %r3

2060 call sub_1 ! Call subtraction subroutine

2064 st %r4, [y] ! Store v-w into y

2068 halt ! Halt instruction execution

2072 sub_1: subcc %r1, %r2, %r4 ! Subtract v-w and put in y

2076 jmpl %r15+4, %r0 ! Return

.org 4096

4096 v: 12

4100 w: 3

4104 x: 7

4108 y: 0

.end

a. Circle which of the three sub-routine parameter passing methods does this code use?

i. register method

ii. data link area method

iii. stack point method

b. Describe why the assembler uses a two pass method.

Answer:

c. Write the symbol table for the code above.

Answer:

--- Symbol Table ---

?

7. (3 pts) Compiler Ch 6.1-6.2

Define the following terms:

a. Compilation

b. Assembly

c. Forward Referencing

d. Location Counter

e. Assembly Process

f. Cross Compilation

g. Mapping Specification

8. (3 pts) List the final 6 tasks of the assembler.

a.

b.

c.

d.

e.

f.

?

9. (3 points) Write a working assembly code that uses stack parameter passing linkage to call a subroutine labeled sub_1 to subtract two numbers and return the results to the main routine. Your main routine must load r: 12 and s: 5 from memory and store the result from your subroutine into memory label t: . Please initialize t: 0 to start your code. t = (r s)

Use care not to let your memory stack step on your code.

Answer:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago