MIPS - 移动图表

时间:2018-03-13 07:44:10

标签: assembly mips mips32

以下是我的绘制图像和检查输入功能。弹出并推送火星中的宏,这些宏旨在简化序言和尾声。我想在键盘中使用向左,向右,向上和向下来控制绘制的图形的移动。我可以使用当前代码向左,向右移动。向下移动是我的问题。如果包含## 1,我无法显示图表。 ## 2让图表自动向下移动直到结束。我怎么能让图表像其他3个动作一样向下移动?另外,有没有办法限制有限部分内的动作?比如,将x和y坐标限制在3和5之间。(inc表示增量,dec表示减量)

 draw:
 push ra
 lw a0, xCoordinate
 lw a1, yCoordinate
 la a2, image
 jal    display
 pop ra
 jr ra

 check_input:
 push ra    
 jal    inputKeys
 lw s0, xCoordinate
 lw s1, yCoordinate
 moveLeft:
 and    t0, v0, KEY_LEFT
 beq    t0, 0, moveRight
 dec    s0
 moveRight:
 and    t0, v0, KEY_RIGHT
 beq    t0, 0, moveUp
 inc    s0
 moveUp:
 and    t0, v0, KEY_UP
 beq    t0, 0, moveDown
 dec    s1
 moveDown:
 and    t0, v0, KEY_DOWN
 beq    t0, 0, moveLeft   ##1
 inc    s1                ##2

 sw s0, xCoordinate
 sw s1, yCoordinate

 pop ra
 jr ra

0 个答案:

没有答案