Design, write, and test a program which is capable of disassembling MIPS machine
ID: 3573948 • Letter: D
Question
Design, write, and test a program which is capable of disassembling MIPS machine code into the assembly language code for any of your proceeding programs. Input the machine code from one file and output the assembly language code to another file. If you program read "0x3c011001" then your program should output "lui $1.4097" or something similar like "lui $at, 4097" (the first line of code in the figure). Your code should then continue to read in the code value column from the file and interpret them to match the basic column. Addresses can simply be output as addresses, not labels. When your program is no longer able to read code values from the input file, your program should close both files and terminate.Explanation / Answer
Solution:
Start:
add $t5, $t5, $zero #ival=zero
add $t0, $t0, $zero #jval=zero
Main:
lp1:
slt $t1, $t5, $s3 #ival
beq $t1, $zero, EXIT #if $t1==zero, Exit
add $t0, $zero, $zero #jval=0
add $t5, $t5,one #ival++
endlp1
lp2:
slt $t2, $t0, $s0 #jval<bval
beq $t2, $zero, lp1 #if $t2 ==zero, goto lp1
add $t3, $t5, $t0 #$t3=ival+jval
multi $t4, $t0, four #$t4=$t0 * four
sll $t4, $t4, two #$t4<two
add $t4, $t4, $s1 #Dval + $t4
sw $t3, $t4($s1) # store the word
addi $t5, $t0, one #jval++
jval lp2
endlp2
endmain
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.