Question: ?I need a Complete solution for this please. in written please. its from Mars and computer architect/assembly lang prog 8. (20 points) Read the following
?I need a Complete solution for this please. in written please. its from Mars and computer architect/assembly lang prog
8. (20 points) Read the following MIPS code and take advantage of the information from the MARS execute view to answer the following questions (a). Assume that $sp register has the value 0x7fffeffc before the procedure func is called. Fill in the content of these addresses in the table right after the jal func instruction is done. Use hexadecimal format. addi $a0, $zero, 5 jal func 2 4 5 li $v0, 10 sysca l 7 func: addi $sp, $sp, Sw $ra, 4($sp) SW $a0, 0($sp) s1t? $t0, $a0, 1 beq $t0, $zero, L1 add Sv0, $zero, $zero addi $sp, $sp, 8 -8 # adjust stack for 2 items # save return address # save argument # test for n 1 9 10 12 13 14 15 # if so, result is 0 # pop 2 items from stack # and return # else decrement n # recursive call # restore original n # and return address # pop 2 items from stack # add to get result # and return r $ra 16 L1: addi $a0, $a0,-1 17 18 19 20 21 jal func lw $a0, 0($sp) Lw $ra, 4($sp) addi $sp, $sp, 8 add $v0, $a0, $v0 ra 23 Bkpt Addss Code Basic Source addi $al, Szero, 5 jal func li ?v, 10 syscall addresscontent 0x7fffeff8 0x7fffeff4 0x00400000 0x20040005 addi $4,$0,0x30000005 1: 8x00400004 8x0c100004 jal 0x09490818 0x80400008 0x2402000a addiu $2,$0,8x0000000a 4: 8x8040000c 8x0000000c syscall 8x00400010 0x23bdfff8 addi $29, $29,0xffff 8: addi $sp, $sp, -8 8x00400014 0xafbf0004 sw $31, 0x00000004($29) 9: sw $ra, 4($sp) 0x00400018 0xafa40000 sw $4, 0x00000000($29) 10: sw $a0, 0($sp) 0x0040001c 0x28880001 siti $8,$4, 0x00000001 11: slt? $t0, aB, 1 8x00400020 0x11000003 beq $8, $0,0x80000003 12:beq $t0, $zero, L1 8x80400024 0x00001020 add $2,$0, $0 0x00400028 0x23bd0008 addi $29,$29,0x0000 14: addi $sp, sp, 8 8x0040002c 0x03e00008 jr $31 0x00400030 0x2084ffff addi $4, $4,0xffffffff 16: L1: addi $a0,?0, -1 8x00400034 0x0c100004 jal 0x00480810 0x00400038 0x8fa40000lw $4,0x00000000 ($29) 18: 8x0040003c 0x8fbf0004 lw $31,0x00000004($29) 19: 0x00400040 0x23bd0008 addi $29,$29,0x0000 20: 8x00400044 0x00821020 add $2,$4,$2 8x00400048 0x03e00008 jr $31 2: 5: # adjust stack for 2 items | #save return address # save argument # test for n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
