Question: Here is a problem that asks to write the corresponding MIPS ASM instructions from the hexadecimal format. The problem and solution are in the picture
Here is a problem that asks to write the corresponding MIPS ASM instructions from the hexadecimal format. The problem and solution are in the picture below. I understand how to obtain the MIPS ASM instruction from the hexadecimal format. However, I do not understand why addi $s1,$s1,$1 corresponds to LabelA and add $s0,$0,$s1 to LabelB? In the first place, why there is a Label with add $s0,$0,$s1????? How do you know that we have to jump to LabelB and not to LabelA??? Finally, what is the purpose of the address I do not understand how to link the labels, the instructions and the address?

3. The following codes are a set of MIPS instructions (hexadecimal form) and their corresponding addresses in the memory. For each line, the information is [Address] Instruction [00400024] 00008020 [00400028] 20110003 [0040002c 20120014 [00400030] 16120002 [00400034] 2231ffff [00400038] 08100010 [0040003c] 22310001 [00400040] 00118020 (1) Write down the corresponding MIPS ASM instructions (2 points x 8) (2) Write down the corresponding C codes (4 points) Solution: add $so, $o,$0 addi $s1, $o, 3 addi $s2,$0, 20 bne $so, $s2, LabelA addi $s1, $s1,-1 j LabelB LabelA: addi $s1, $s1, 1 LabelB: add $s0, $0, $s1 int a-0; int b-3; if (a!=20) { else b-b-1; [00400024] [00400028] [0040002c] [00400030] 00008020 20110003 20120014 16120002 0000 0000 0000 0000 1000 0000 0010 0000 0010 0000 0001 0001 0000 0000 0000 0011 0010 0000 0001 0010 0000 0000 0001 0100 0001 0110 0001 0010 0000 0000 0000 0010 [00400038] 08100010 0000 1000 0001 0000 0000 0000 0001 0000 [0040003c 22310001 0010 0010 0011 0001 0000 0000 0000 0001 [00400040] 00118020 0000 0000 0001 0001 1000 0000 0010 0000 3. The following codes are a set of MIPS instructions (hexadecimal form) and their corresponding addresses in the memory. For each line, the information is [Address] Instruction [00400024] 00008020 [00400028] 20110003 [0040002c 20120014 [00400030] 16120002 [00400034] 2231ffff [00400038] 08100010 [0040003c] 22310001 [00400040] 00118020 (1) Write down the corresponding MIPS ASM instructions (2 points x 8) (2) Write down the corresponding C codes (4 points) Solution: add $so, $o,$0 addi $s1, $o, 3 addi $s2,$0, 20 bne $so, $s2, LabelA addi $s1, $s1,-1 j LabelB LabelA: addi $s1, $s1, 1 LabelB: add $s0, $0, $s1 int a-0; int b-3; if (a!=20) { else b-b-1; [00400024] [00400028] [0040002c] [00400030] 00008020 20110003 20120014 16120002 0000 0000 0000 0000 1000 0000 0010 0000 0010 0000 0001 0001 0000 0000 0000 0011 0010 0000 0001 0010 0000 0000 0001 0100 0001 0110 0001 0010 0000 0000 0000 0010 [00400038] 08100010 0000 1000 0001 0000 0000 0000 0001 0000 [0040003c 22310001 0010 0010 0011 0001 0000 0000 0000 0001 [00400040] 00118020 0000 0000 0001 0001 1000 0000 0010 0000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
