ECE 330 Homework 3 Fall 2010 Due: 9/13/2010

advertisement

ECE 330

Due: 9/13/2010 a.

b.

c.

d.

Homework 3 Fall 2010

1.

Create macros that implement the following instructions. These macros should not use any registers other than those specified as operands. Write a program that utilizes each of the following macros. Show before and after snapshots of registers that confirms validity.

decr

decrement

Operation: rA ←  rA - 1

Assembler Syntax: decr rA decr r6 Example:

rori

rotate right immediate

Operation: rB ←  rA rotated right IMM5 bit positions

Assembler Syntax: rori rB, rA, IMM5

Example: rori r6, r7, 3

halt

halt execution

Operation: PC ←  PC

Assembler Syntax: halt halt Example:

comp

one’s complement

Operation: rB ←  ~rA

Assembler Syntax: comp rB, rA

Example: comp r2, r8

Page 1 of 3

ECE 330 Homework 3 Fall 2010

Due: 9/13/2010

2.

Create macros that implement the following instructions. These macros may require the usage of additional registers. When a temporary register is needed for temporary values use register r1 . Write a program that utilizes each of the following macros. Show before and after snapshots of registers that confirms validity. a.

b.

togglebiti

toggle bit immediate

Operation: rB ←  rA

31..IMM5+1

: ~rA

IMM5

: rA

IMM5-1..0

Assembler Syntax: togglebiti rB, rA, IMM5 togglebiti r2, r8, 7 Example:

clearbiti

clear bit immediate

Operation: rB ←  rA

31..IMM5+1

: 0 : rA

IMM5-1..0

Assembler Syntax: clearbiti rB, rA, IMM5

Example: clearbiti r2, r8, 7 c.

setbiti

set bit immediate

Operation: rA

IMM5

←  1

Assembler Syntax: setbiti rA, IMM5

Example: setbiti r2, 7 d.

testbiti

test for bit set immediate

Operation: if rA

IMM5

= 1 then rB ≠ 0 other wise rB = 0

Assembler Syntax: testbiti rB, rA, IMM5

Example: testbiti r2, r8, 7

Page 2 of 3

ECE 330 Homework 3 Fall 2010

Due: 9/13/2010

3.

For the assembly code, memory and registers shown below, answer the following questions.

# file: hw3_3.s

.text

.global _start

_start: r8,COUNT r8,0(r8) r9,LIST r2,r0

LOOP: r8,r0,LOOP_END

ldw

add r8,r8,1

addi r2,r2,r3

subi r9,r9,4

LOOP

LOOP_END: r9,SUM r2,0(r9)

.

.data

0xaaaaaaaa

COUNT:

LIST: .word 2,3,5,7,11,13,17

LIST_END:

SUM:

0xffffffff

.end a.

What is the value of the label LOOP ? b.

What is the value of the label LOOP_END ? c.

What is the value of the label COUNT ? d.

What is the value of the label LIST ? e.

What is the value of the label LIST_END ? f.

What is the value of the label SUM ? g.

What is the next assembly instruction to be executed? h.

What is the memory address referenced by the label COUNT ? i.

What is the value of memory (word) referenced by the label COUNT ? j.

What is the address of memory that will change as a result of running this program? k.

What is the new value (word) in memory that changes? l.

What is the machine instruction referenced by the label LOOP ?

__________

__________

__________

__________

__________

__________

__________

__________

__________

__________

__________

__________

Page 3 of 3

Download