In: Computer Science
a) Fill out the following table with the values in R0 and R1 after each instruction is executed. Please use hexadecimal. The first line is completed for you. (4 pts)
|
Address |
Instruction |
R0 |
R1 |
|
010016 |
1110 0001 1111 1100 |
00FD16 |
000016 |
|
010116 |
0001 0010 0011 1101 |
||
|
010216 |
0011 0011 1111 0100 |
||
|
010316 |
0101 0010 0110 0000 |
||
|
010416 |
0010 0001 1111 0110 |
b) Explain what the instruction at each of the following addresses does. (4 pts)
c) What is the value stored in PC when the instruction at address 010216 is executed? (1 pt)
Answer a
|
Address |
Instruction |
R0 |
R1 |
|
010016 |
1110 0001 1111 1100 |
00FD16 |
000016 |
|
010116 |
0001 0010 0011 1101 |
00FD16 | 00FA16 |
|
010216 |
0011 0011 1111 0100 |
00FD16 | 00FA16 |
|
010316 |
0101 0010 0110 0000 |
00FD16 | 00FA16 |
|
010416 |
0010 0001 1111 0110 |
Mem[00FB16] | 00FA16 |
Answer b
|
Address |
Instruction |
Description |
|
010016 |
1110 0001 1111 1100 |
PC = 010116 LEA R0, FD 1110 - LEA (Load Effective Address) 000 - R0 1 1111 1100 - PC Offset R0 = PC + Sign Extended Offset = = 0000 0001 0000 0001 + 1111 1111 1111 1100 = 0000 0000 1111 1101 = 00FD16 |
|
010116 |
0001 0010 0011 1101 |
PC = 010216 0001 - ADD 001 - R1 000 - R0 1 1101 - Immed5 R1 = R0 + sign extended Immed5 = 0000 0000 1111 1101 + 1111 1111 1111 1101 = 0000 0000 1111 1010 = 00FA16 |
|
010216 |
0011 0011 1111 0100 |
PC = 010316 0011 - ST (Store) 001 - R1 1 1111 0100 - PC Offset [PC + Sign extended PC offset] = R1 [0000 0001 0000 0011 + 1111 1111 1111 0100] = 00FA16 [00F716] =00FA16 |
|
010316 |
0101 0010 0110 0000 |
PC = 010416 0101 - AND 001 - R1 001 - R1 0 0000 - Immed5 R1= R1 AND Sign Exteneded Immed 5 = 00FA16 + 000016 = 00FA16 |
|
010416 |
0010 0001 1111 0110 |
PC = 010516 0010 - LD (Load) 000 - R0 1 1111 0110 - PC Offset R0 = Mem[PC + Sign Extended PC Offset] = Mem[010516 + FFF616] = Mem[00FB16] |
Answer c
PC = 010316