1. Use the following program for this question data .halfword 7, 3 num: .word 9
ID: 3727916 • Letter: 1
Question
1. Use the following program for this question data .halfword 7, 3 num: .word 9 globl .text main mairn lui t0, 0x1001 top: lw $t1, -4 ($t0) beq $s0, $s2, end jal func add $s0, $s1, $t0 andi $s0, $0, 0xFFFF top bne $s0, $0, top end: func sll $v0, $t1, 4 ra a. There are 5 labels in this code. If the .data section starts at 0x10010000 and the .text starts at Ox00400400, what is the value of each label? Include all labels from the program. 2.5 points b. What is the addressing mode for each instruction? There are 10 unique instructions. 2.5 points c. "Assemble" the program by converting it to the machine code (hex). 15 pointsExplanation / Answer
Answer :
a) The above program has five labels :- num,main,top,end and func
Values of label:-
num=0x10010004
main=0x00400400
top=0x00400404
end=0x00400420
func=0x00400420
Since, labels always replaced with the memory address .
b) Addressing modes:-
lui $t0,0x1001 :- Immediate addressing mode.
lw $t1,-4($t0) :- Base addressing mode
beq $s0,$s2,end :- PC relative addressing mode
jal func :- pseudo direct addressing mode
add $s0,$s1,$t0 :- Register addressing mode
andi $s0,$0,0xFFFF :- Immediate adressing model
j top :- pseudo direct addressing mode
bne $s0,$0,top :- PC relative addressing mode
sll 4v0,$t1,4 :- Immediate adressing model
jr $ra :- Register direct addressing mode
c) machine code in hex
lui $t0,0x1001 --> 0x3c081001
lw $t1,-4($t0) --> 0x8d09fffc
beq $s0,$s2,end --> 0x12120005
jal func --> 0x0c100008
add $s0,$s1,$t0 --> 0x02288020
andi $s0,$0,0xFFFF -- >0x3010ffff
j top --> 0x081000001
bne $s0,$0,top--> 0x1600fff9
sll 4v0,$t1,4 --> 0x00091100
jr $ra --> 0x03e00008
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.