Question:
Write down the corresponding MIPS machine language of the following assembly language code.
lw $S0, 64($S1)
add $t0,$S0,$S1
sub $t1,$S3,$S4
sw $t1,100($S1)
addi $S4,$S6,100
The machine code of mips instruction is of 32 bit. The converstions and machine codes are as below
1) lw $S0, 64($S1)
Syntax: |
lw $t, offset($s) |
Encoding: |
|
$s = $S1 = 17 = 10001
$t = $S0 = 16 = 10000
Offset = 64 = 0000000001000000
Machine code = 1000 1110 0011 0000 0000 0000 0100 0000 = 0x8E300040
So the machine code according to above is 0x8E300040
2) add $t0,$S0,$S1
Syntax: |
add $d, $s, $t |
Encoding: |
|
$s = $S0 = 16 = 10000
$t = $S1 = 17 = 10001
$d = $t0 = 8 = 01000
Machine code = 0000 0010 0001 0001 0100 0000 0010 0000 = 0x02114020
So the machine code according to above is 0x02114020
3) sub $t1,$S3,$S4
Syntax: |
sub $d, $s, $t |
Encoding: |
|
$s = $S3 = 19 = 10011
$t = $S4 = 20 = 10100
$d = $t1 = 9 = 01001
Machine code = 0000 0010 0111 0100 0100 1000 0010 0010 = 0x02744822
So the machine code according to above is 0x02744822
4) sw $t1,100($S1)
Syntax: |
sw $t, offset($s) |
Encoding: |
|
$s = $S1 = 17 = 10001
$t = $t1 = 19 = 01001
Offset = 100 = 0000000001100100
Machine code = 1010 1110 0010 1001 0000 0000 0110 0100 = 0xAE290064
So the machine code according to above is 0xAE290064
5) addi $S4,$S6,100
Syntax: |
addi $t, $s, imm |
Encoding: |
|
$s = $S6 = 22 = 10110
$t = $S4 = 20 = 10100
Offset = 100 = 0000000001100100
Machine code = 0010 0010 1101 0100 0000 0000 0110 0100 = 0x22D40064
So the machine code according to above is 0x22D40064
Get Answers For Free
Most questions answered within 1 hours.