I give the code that has the problem and the use of the stack can not work.
Can anyone ask me to fix this?
.data. Allven 2 array: .space 100.text .globl Main main: li $ t0,10 addi $ sp, $ sp, -12 # stack self $ RA, 0 ($ sp) sw $ s0.4 ($ sp) $ self S1,8 ($ sp) jal function addi $ sp, $ sp, 12 lw $ ra, 0 ($ sp) #hello Stack alad $ s0.4 ($ sp) lw $ s1,8 ($ sp) li $ v0 , Add 1 $ a0, $ t6, $ 0 syscall li $ v0,10 syscall function: move to $ s0, moves $ a2, $ s1, $ a1 li $ s0,10101 # s0, s1 its prices have never changed $ Li1,20202 li $ t6777 $ $ v0, $ t6 jr $ ra
Have you heard about the "delay slot" in the MIPS processor? After any "branch" instructions the next instruction is placed in "delay slot". This means that this instruction will be implemented in any way, even if the branch is done. Then in the next part of the code:
jal function addi $ sp, $ sp, 12 you nop code> jal After the command because addi is executed immediately after the call but not after returning from function . It also remains for the Jr. code.
Comments
Post a Comment