开发者

what am i doing wrong/ trying to run MIPS program to construct/draw a box

开发者 https://www.devze.com 2023-01-23 15:25 出处:网络
Here is the MIPS program i\'ve written. But my program won\'t construct/draw a box. .data button:.struct

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消