尝试将.ASCIIZ字符串复制到MIPS中的分配空间
我试图制作一个简单的程序,将字符串soplas
复制到.Space指令称为buffer
。我会遇到错误,但我不确定我在哪里出错,beq
语句将将字节与0 ASCII字符进行比较,因为那是如何终止字符串,对吗?使用JAL调用复制
copy:
lb $t1, soplas($t0)
nop
sb $t1, buffer($t0)
nop
addi $t0, $t0,1
beq $t1, 0x00, done
j copy
nop
nop
done:
jr $ra
nop
nop
im trying to make a simple program that copies a string soplas
to a .space directive called buffer
. im getting errors but im not sure where im going wrong, the beq
statement would be comparing the byte to the 0 ascii character since thats how strings are null terminated, right? copy is called using jal, hence the jr $ra
in the done subroutine
copy:
lb $t1, soplas($t0)
nop
sb $t1, buffer($t0)
nop
addi $t0, $t0,1
beq $t1, 0x00, done
j copy
nop
nop
done:
jr $ra
nop
nop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的C代码看起来像这样:
您可以看到汇编版本中缺少的C代码的哪一行?
另外,如果您使用带有分支延迟插槽的MIPS,即使
BEQ
和bne
需要nop
s,而不仅仅是j
j 代码>和JR
。Let's say your C code would look like this:
Can you see which line of the C code you're missing in the assembly version?
Also, if you're using MIPS with branch delay slots, even
beq
andbne
neednop
s, not justj
andjr
.