在一定范围内移动图形 - MIPS



图形应该向右、向下、向左、向上、连续移动,然后再次循环这个过程 ->无限,直到程序结束。当我按如下方式尝试我的 mips 代码时,图像可以向右移动,然后向下移动,但卡在move_left部分。

 move:
push ra
lw      t7, frame_counter           
li      t4, 10                  
rem     t3, t7, t4                   
bne     t3, 0, _move_image_exit 
_move_image_right:
    lw  t1, image_x                 
    inc t1                  
    bgt t1, 17, _move_image_down            
    sw  t1, image_x
    j   _move_image_exit
_move_image_down:
    lw  t0, image_y
    inc t0
    bgt     t0, 5, _move_image_left
    sw  t0, image_y
    j   _move_image_exit
_move_image_left:
    lw  t1, image_x
    dec t1
    blt     t1, 5, _move_image_up
    sw  t1, image_x
    b   _move_image_exit
_move_image_up:
    lw  t0, image_y
    dec t0
    blt t0, 2, _move_image_right
    sw  t0, image_y
    b   _move_image_exit
#_store_image_coordinates:
    #sw     t1, image_x
    #sw     t0, image_y
_move_image_exit:   
 pop ra
 jr ra

这不是一个答案,但我没有足够的声誉来评论......

如果我理解正确,当你到达_move_image_left时,你的image_x值大于 17,否则你就不会到达块,所以 blt 不会分支,你直接进入_move_image_exit

最新更新