ECE 330 Due: 2/9/2011 Homework 3 Spring 2011 1. Create macros that implement the following instructions. These macros should not use any registers other than those specified as operands. a. decr decrement Operation: Assembler Syntax: Example: b. rA ← rA - 1 decr rA decr r6 rori rotate right immediate Operation: Assembler Syntax: Example: c. rB ← rA rotated right IMM5 bit positions rori rB, rA, IMM5 rori r6, r7, 3 halt halt execution Operation: Assembler Syntax: Example: d. PC ← PC halt halt comp one’s complement Operation: Assembler Syntax: Example: rB ← ~rA comp rB, rA comp r2, r8 Page 1 of 3 ECE 330 Due: 2/9/2011 Homework 3 Spring 2011 2. For the memory and registers shown below, show the values for registers that change with each single step of execution. Make sure that you show the value of the program counter (pc) for each step. Values must be shown in hexadecimal notation. Registers pc zero r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 et bt gp sp fp ea ba ra status estatus bstatus ienable ipending cpuid Step 0 Step 1 Step 2 0x00000000 0x00000000 0x00000000 0x0000000C 0x00000030 0x00000044 0x0000FFFC 0x000186A0 0x0001E242 0x0000005C 0x00000066 0x000015B2 0x0000092A 0x00004000 0x00002000 0x00000152 0x0001234A 0x0001234C 0x00000048 0x35363738 0x000004D2 0x0000162E 0x000022B8 0x0000115C 0x000008AE 0x00000000 0xFFFFFFFF 0x00000000 0x00000000 0x00000000 0x00000000 0xFFFFFFFF 0x00000000 0x00000000 0x00000000 0xFFFFFFFF 0x00000000 0x00000000 0x00000000 Page 2 of 3 Step 3 Step 4 Step 5 Step 6 ECE 330 Due: 2/9/2011 Homework 3 Spring 2011 3. For the assembly code, memory and registers shown below, answer the following questions. # file: hw3_3.s .text .global _start _start: movia ldw r8,COUNT r8,0(r8) movia r9,LIST mov r2,r0 LOOP: beq r8,r0,LOOP_END ldw add subi addi r3,0(r9) r2,r2,r3 r8,r8,1 r9,r9,4 br LOOP LOOP_END: movia r9,SUM stw r2,0(r9) br . .data .word 0xaaaaaaaa COUNT: .word (LIST_END-LIST)/4 LIST: .word 2,3,5,7,11,13,17 LIST_END: SUM: .word 0 .word 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