Assemble the following assembly-language code by writing out the corresponding m
ID: 3875963 • Letter: A
Question
Assemble the following assembly-language code by writing out the corresponding machine language instructions. You may find instruction definitions in Appendix A or in the Wikipedia article on MIPS. The hex address of each instruction is given to the left of each instruction. Print this page and fill in the decimal values for each field, convert to binary, and then convert the whole instruction to hexadecimal. The first one is done for you as an example. For longer fields, such as the immediate data in I-type instructions, draw a line connecting the fields, such as 6. 4000 slt Ss1, Ss2, Ss3 Instruction breakdown by binary bit 5 bits 6 bits 4 2 5 bits 5 bits 5 bits 6 bits Dec Bin lol0lolo 0 0 10 0101 01011100 0 10000 0 101 0 10 Hex 8 8 2 2 4004 or $s1, $s2, $s3 Instruction breakdown by binary bit 5 bits 5 bits 5 bits 5 bits 6 bits 6 bits Dec Bin Hex 4008 addi $to, $t4,17 Dec Bin Hex 400C add $s1, $s1, $s3 Dec Bin Hex 4010 sw $s0, 100($t2)#100 is a decimal number Dec Bin HexExplanation / Answer
6.:
or $s1, $s2, $s3
R type instruction:
Most significant 6 bits corresponds to r type: 000000
least significant 6 bits corresponds to or instruction: 100101
rs = $s2 = 10010, rt = $s3 = 10011, rd = $s1 = 10001, shamt = 00000
Binary = 000000 10010 10011 10001 00000 100101
Decimal = 0 18 19 17 0 37
HexaDecimal = 0 2 5 3 8 8 2 5 = 0x02538825
addi $t0, $t4, 17
I type instruction:
Most significant 6 bits corresponds to addi = 001000
rs = $t4 = 01100
rd = $t0 = 01000
17 is in 16 bits: 0000 0000 0001 0001
Binary = 001000 01100 01000 0000000000010001
Decimal = 8 12 8 ---17---
Hexadecimal = 2 1 8 8 0 0 1 1 = 0x21880011
add $s1, $s1, $s3
R type instruction:
Most significant 6 bits corresponds to R type: 000000
Least significant 6 bits corresponds to add : 100000
rs = $s1 = 10001, rt = $s3 = 10011, rd = $s1 = 10001, shamt = 00000
Binary = 000000 10001 10011 10001 00000 100000
Decimal = 0 17 19 17 0 32
HexaDecimal = 0 2 3 3 8 8 2 0 = 0x02338820
sw $s2, 100($t2)
I type instruction
Most significant 6 bits corresponds to sw: 101011
base = $t2 = 01010
rt = $s2 = 10010
100 in 16 bits = 0000 0000 0110 0100
Binary = 101011 01010 10010 0000000001100100
Decimal = 43 10 18 ---100---
HexaDecimal = A D 5 0 0 0 6 4 = 0xAD500064
7.
0x110A17CC
Binary = 000100 01000 01010 0001011111001100
Decimal = 4 8 10 ---6092---
First 6 bits = 000100 = beq
rs = 01000 = $t0
rt = 01010 = $2
offset = 0001011111001100 = 6092 in decimal = 17CC in Hexadecimal
Instruction: beq $t0, $t2, 6092 or beq $t0, $t2, 0x17CC
0x0800AA23
Binary = 00001000000000001010101000100011
First 6 bits = 000010 = J (jump)
Last 26 bits = 00000000001010101000100011 = 43555 in decimal = 0x000AA23 in hexadecimal
Decimal = 2 ----43555---
Instruction: j 43555 or j 0x000AA23
0x8D1400C4
Binary = 100011 01000 10100 0000000011000100
First 6 bits = 100011 = lw (load word)
base = 01000 = $t0
rt = 10100 = $s4
offset = 0000000011000100 = 196 in decimal = 0x00C4
Decimal = 35 8 20 ---196---
Instruction = lw $s4, 196($t0) or lw $s4, 0x00C4($t0)
0x01505020
Binary: 000000 01010 10000 01010 00000 100000
Decimal = 0 10 16 10 0 32
First 6 bits = R type
Least 6 bits = 100000 = ADD
rs = 01010 = $t0
rt = 10000 = $s0
rd = 01010 = $t0
shamt = 00000
Instruction = add $t2, $t2, $s0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.