**** Final answer in MIPS not in a higher level language **** During 2017 Dallas
ID: 3811134 • Letter: #
Question
**** Final answer in MIPS not in a higher level language ****
During 2017 Dallas Hackathon, your company's server computer was crashed by a hacker (fabricated story). The hacker has left behind a paper with the following piece of information:
.data
.globl count
count: .word 8
.globl list
list: .word -2,3,12,0,10,-3,9,5
.globl str
str: .asciiz "The result is:"
.globl space
space: .asciiz " "
.globl newln
newln: .asciiz " "
.align 2
.text
.globl main
main:
[0x00400020] 0x3c011001
[0x00400024] 0x342b0004
[0x00400028] 0x3c011001
[0x0040002c] 0x8c2e0000
[0x00400030] 0x000e6080
[0x00400034] 0x000ca021
[0x00400038] 0x000e6843
[0x0040003c] 0x018b6020
[0x00400040] 0x000d6880
[0x00400044] 0x01ab6820
[0x00400048] 0x218cfffc
[0x0040004c] 0x8d6f0000
[0x00400050] 0x8d900000
[0x00400054] 0xad700000
[0x00400058] 0xad8f0000
[0x0040005c] 0x216b0004
[0x00400060] 0x016d8822
[0x00400064] 0x1620fff9
[0x00400068] 0x34020004
[0x0040006c] 0x3c011001
[0x00400070] 0x34240024
syscall
li $15, 0
print: li $v0, 4
la $a0, space
syscall
lw $a0, list($15)
li $v0, 1
syscall
addi $15, $15, 4
slt $8, $15, $20
bnez $8, print
li $v0, 4
la $a0, newln
syscall
li $v0, 10
syscall
As an acknowledged expert of MIPS assembly, you realize that this is the critical part of the server software with addresses (labels) on the left and machine code on the right. You now try to save the server by translating the machine code to make a complete and sensible MIPS program. (Your tasks: write down the sequence of equivalent MIPS assembly instructions, and state what will be printed on the console window if the complete program is executed).
Explanation / Answer
The goal is to find MIPS equivalent instruction for the Hexadecimal values.
------------------------------------------------------
The first instruction is 0x3c011001.
Convert the Hexadecimal to Binary form
0x3c011001 = 001111 00000 00001 0001000000000001
On seeing the Function Code, it is I - type instruction.
The correponding instruction is LUI (from MIPS green sheet)
The immediate value is 0001000000000001 = 0x1001 in Hexadecimal.
And, the value 00001 corresponds to $at register.
The instruction is LUI $at 0x1001
----------------------------------------------------
The second instruction is 0x342b0004.
Converting to Hexadecimal gives -> 001101 00001 01011 0000000000000100
On seeing the Function Code, it is I - type instruction.
The correponding instruction is ORI (from MIPS green sheet)
The rs value is 00001 = $at
The rt value is 01011 = $t3
Immediate value = 0000000000000100 = 4
The instruction is ORI $t3, $at, 4
------------------------------------------------------
The third instruction is same as first one.
------------------------------------------------------
The fourth instruction is 0x8c2e0000.
Converting to Binary => 100011 00001 01110 0000000000000000
On seeing the Function Code, it is I - type instruction.
The correponding instruction is LW.
The rs value is 00001 = $at
The rt value is 01110 = $t6
Immediate value = 0000000000000000 = 0
The instruction is LW $t6 0x0000 $at
------------------------------------------------------
Likewise, other Hexadecimal values can be decoded into instructions.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.