The sequence of instructions is given and you need to find out the hexadecimal memory contents of all the instructions in the given table except which is not required, accordingly.
| Label | Address | Value |
| k | 300 | Unknown |
| g | 302 | Unknown |
| h | 304 | Unknown |
| f | 306 | Unknown |
| Memory Address | Memory Contents | Hexadecimal Memory Contents |
| 400 | ld R1,g | |
| 402 | ld R2,h |
Not Required
|
| 404 | sub R3,R1,R2 | |
| 406 | shl R7,R3,4 | |
| 408 | ld R4,k |
Not Required
|
| 410 | addi R6,R4,32 |
Not Required
|
| 412 | shl R8,R6,2 |
Not Required
|
| 414 | add R9, R8,R7 | |
| 416 | st R9,f |
Solution:
First of all note the SRC instruction format and its type then according to thiis find the fields in that format. first come opcode of every instruction which is alway of five bits note down it from SRC instruction table then come registers all 5 bits. see it from register table then constants (in case of variables addresser are given simply convert then in to hexadecimal) covert thenm into hexadecimal and any unsued bits as remaning 0s if there are any.
e.g for instruction “st R9, f”. it is type C instruction of the following format
opcode ra(R9) rb(R0) c2(f)
00011 01001 00000 00000 0001 0011 0010
total instruction becomes 00011 01001 00000 00000 0001 0011 0010
converting in hexadecimal we obtain 1A400132h the ‘h’ at the end is showing it is hexadecimal number is 8 digit number showing no of total bits are 32 bits.
Memory Contents Hexadecimal Memory Contents
ld R1,g 0840012Eh
sub R3,R1,R2 70C22000h
shl R7,R3,4 E1C60004h
add R9, R8,R7 62507000h
st R9,f 1A400132h