6 (a) Write a MIPS program fragment for the following high-level language statem
ID: 3586256 • Letter: 6
Question
6 (a) Write a MIPS program fragment for the following high-level language statement: B [350]-gt B [350];/ Assume B is an int array with each element taking 4 bytes Assume that g is in register Ssland that the base address of the array B is in register Ss2. Assume that registers Ss0 through Ss7 map to register numbers 16 through 23, and registers StO through St7 map to register numbers 8 through 15. Use the instruction format information provided below to convert your instructions in Part (a) to machine language code. First express your machine language code using decimal numbers for the fields and then convert into Binary and eventually into hexadecimal representation for each instruction. (b) Instructions for the program in Part (a) converted into Decimal (c) Conversion of Part (b) into Binary (d) Conversion of Part (c) into Hexadecimal Instruction Format of relevant MIPS instructions 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits add rd, rs, rt rs rt rd 32 6 bits 35 43 5 bits 5 bits 16 bits 16-bit displacement d 16-bit displacement d lw rt, d (rs) rs rt sw rt, d (rs) rs rtExplanation / Answer
(a)
lw $t0,350($s2)
add $t1,$s1,$t0
sw $t1,350($s2)
(b)
lw $t0,350($s2)
Instruction format = 35 18 8 350
add $t1,$s1,$t0
Instruction format= 0 17 8 9 0 32
sw $t1,350($s2)
Instruction format = 35 18 9 350
(c)
lw $t0,350($s2)
Instruction format = 100011 10010 01000 0000000101011110
add $t1,$s1,$t0
Instruction format= 000000 10001 01000 01001 00000 100000
sw $t1,350($s2)
Instruction format = 100011 10010 01001 0000000101011110
(d)
lw $t0,350($s2)
Instruction format = 0x23 0x12 0x8 0x15E
add $t1,$s1,$t0
Instruction format= 0x0 0x11 0x8 0x9 0x0 0x20
sw $t1,350($s2)
Instruction format = 0x23 0x12 0x9 0x15E
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.