我做错了什么/尝试运行 MIPS 程序来构建/绘制一个盒子

发布于 2024-09-29 20:10:00 字数 1159 浏览 1 评论 0原文

这是我写的MIPS程序。但我的程序不会构造/绘制一个盒子。

.data
 button:   .struct
 xleft:    .byte    0
 ytop:     .byte    0
 size:     .byte    0
 state:    .byte    0
 label:    .space   4
 action:   .word

           .data
 box:      .struct
 ulc:      .byte
 top:      .byte
 urc:      .byte
 left:     .byte
 right:    .byte
 llc:      .byte
 bottom:   .lrc

           .data
 pressed:  .byte 201,205,184,186,174,211,196,217 #ASCII codes for program

 drawBox(box *a0,byte left,byte top, size a3);

           .code
 drawBox:  addi  $sp,$sp,-1
           sw    $a0,($sp)
           sw    $a1,4($sp)
           addi  $t0,$a3,0xf
           srl   $t9,$a3,4
           move  $$a0,$a1
           move  $a1,$a2
           syscall $xy
           lw $t7,($sp)
           syscall $print_char
           lbu $a0,box.top($t7)
           move $t1,$t8
           b     2f

 1:        syscall $print_char
           addi $t1,$t1,-1

 2:        bnez $t1,1b
           lbu $a0,box.urc($t7)
           syscall $print_char
           move $t1,$t9
           b     2f
           syscall $print_char
           addi    

 99:       addi $sp,$sp,8
           jr   $ra

Here is the MIPS program i've written. But my program won't construct/draw a box.

.data
 button:   .struct
 xleft:    .byte    0
 ytop:     .byte    0
 size:     .byte    0
 state:    .byte    0
 label:    .space   4
 action:   .word

           .data
 box:      .struct
 ulc:      .byte
 top:      .byte
 urc:      .byte
 left:     .byte
 right:    .byte
 llc:      .byte
 bottom:   .lrc

           .data
 pressed:  .byte 201,205,184,186,174,211,196,217 #ASCII codes for program

 drawBox(box *a0,byte left,byte top, size a3);

           .code
 drawBox:  addi  $sp,$sp,-1
           sw    $a0,($sp)
           sw    $a1,4($sp)
           addi  $t0,$a3,0xf
           srl   $t9,$a3,4
           move  $a0,$a1
           move  $a1,$a2
           syscall $xy
           lw $t7,($sp)
           syscall $print_char
           lbu $a0,box.top($t7)
           move $t1,$t8
           b     2f

 1:        syscall $print_char
           addi $t1,$t1,-1

 2:        bnez $t1,1b
           lbu $a0,box.urc($t7)
           syscall $print_char
           move $t1,$t9
           b     2f
           syscall $print_char
           addi    

 99:       addi $sp,$sp,8
           jr   $ra

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不醒的梦 2024-10-06 20:10:00

这个程序充满了错误——语法错误等等。 bottom: 后面的 .lrc 看起来像是下一行中的变量名称,在编辑过程中意外上移。 drawBox(box *a0,...) 也不是有效的 MIPS 汇编语法 - 看起来它本来是一条注释,但您忘记了 #。堆栈帧设置代码 (addi $sp,$sp,-1) 未对齐堆栈指针,并将导致存储失败(有趣的是,标签 99:< 之后的堆栈帧恢复代码/code> 看起来不错)。还有其他错误。

整个程序看起来像是复制和复制的。从几个不同的来源粘贴在一起,完全不了解 MIPS 汇编语言,这个问题听起来像是一个家庭作业。首先尝试一个更简单的程序(将几个整数加在一起,然后编写一个简单的循环,然后编写一个函数来打印以零结尾的字符串,类似的东西) - 很明显,您已经超出了您的深度现在这个问题。

This program is full of errors - syntax errors and otherwise. The .lrc following bottom: looks like it's a variable name from the following line that got accidentally moved up during editing. The drawBox(box *a0,...) isn't valid MIPS assembly syntax either - looks like it was intended to be a comment, but you forgot the #. The stack frame setup code (addi $sp,$sp,-1) misaligns the stack pointer and will cause the stores to fail (interestingly, the stack frame restore code following label 99: looks OK). There's other errors as well.

The whole program looks like it was copy & pasted together from several different sources with absolutely no understanding of MIPS assembly language, and the problem sounds like a homework assignment. Try your hands at a simpler program first (add a couple integers together, then write a simple loop, then write a function to print a zero-terminated string, something like that) - it's fairly obvious that you're out of your depth with this problem right now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文