3. Assemble the following assembly-language code by writing out the correspondin
ID: 3876322 • Letter: 3
Question
3. Assemble the following assembly-language code by writing out the corresponding machine language instructions. 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 as17_-, 2000 slt $s1, $s2, $s3 Instruction breakdown by binary bit 5 bits 6 bits 5 bits 6 bits 4 2 5 bits 5 bits Dec Bin lol0lolo 0/0110 01 01110 011 100 0110l0l0l0 01110110110 Hex 2 3 2 2004 and Sto, Ss3, St4 Instruction breakdown by binary bit 5 bits 6 bits 5 bits 5 bits 5 bits 6 bits Dec Bin Hex 2008 add to, $t4, $s0 Dec Bin Hex 200C addi St1, St2, 1234 #1234 is a decimal number Dec Bin Hex 2010 lw Ss4, 200($t2) #200 is a decimal number Dec Bin HexExplanation / Answer
3.)
and $t0, $s3, $t4
R type instruction:
Format: AND rd, rs, rt
Most significant 6 bits corresponds to R type: 000000
least significant 6 bits corresponds to and instruction: 100100
rs = $s3 = 10011, rt = $t4 = 01100, rd = $t0 = 01000, shamt = 00000
Binary = 000000 10011 01100 01000 00000 100100
Decimal = 0 19 12 8 0 36
HexaDecimal = 0 2 6 C 4 0 2 4 = 0x026C4024
.
.
add $t0, $t4, $s0
R type instruction:
Format: ADD rd, rs, rt
Most significant 6 bits corresponds to R type: 000000
least significant 6 bits corresponds to add instruction: 100000
rs = $t4 = 01100, rt = $s0 = 10000, rd = $t0 = 01000, shamt = 00000
Binary = 000000 01100 10000 01000 00000 100000
Decimal = 0 12 16 8 0 32
HexaDecimal = 0 1 9 0 4 0 2 0 = 0x01904020
.
.
addi $t1, $t2, 1234
I type instruction:
Format: ADDI rt, rs, immediate
Most significant 6 bits corresponds to addi = 001000
rs = $t2 = 01010
rd = $t1 = 01001
1234 is in 16 bits: 0000 0100 1101 0010
Binary = 001000 01010 01001 0000010011010010
Decimal = 8 10 9 ---1234---
Hexadecimal = 2 1 4 9 0 4 D 2 = 0x214904D2
.
.
lw $s4, 200($t2)
I type instruction
Format: LW rt, offset(base)
Most significant 6 bits corresponds to lw: 100011
base = $t2 = 01010
rt = $s4 = 10100
200 in 16 bits = 0000 0000 1100 1000
Binary = 100011 01010 10100 0000000011001000
Decimal = 35 10 20 ---200---
HexaDecimal = 8 D 5 4 0 0 C 8 = 0x8D5400C8
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.