assembly - 无法将答案存储在 MIPS 中
问题描述
我正在尝试在 MIPS 中编写一个函数,该函数将接收一个字符串并返回字符串中的字符数。这是我到目前为止所拥有的
# Program to calculate string length of any given string
.data
mystring: .asciiz "Hello, World!"
answer: .word 0
.text
.globl main
main: la $a0, mystring # Load base adress of the string into function argument
jal strlen # jump to strlen and save position to $ra
sw $vo, answer # Store the answer to memory
li $v0, 10 #exit
syscall
strlen: li $v0, 0 # Initialize counter = 0
stringLoop: lb $t0, 0($a0) # Load first word of the string
beq $t0, $zero, end # if $t0 == '\0' then exit the loop
addi $a0, $a0, 1 # Increment the address (go to the next character)
addi $v0, $v0, 1 # Increment the counter
b stringLoop
end: jr $ra # Return to main program
每次我尝试使用 QtSpim 运行它时,都会在“sw $vo, answer”行出现语法错误。有人可以告诉我我的程序有什么问题吗?谢谢
解决方案
语法错误通常是由拼写错误引起的,就像您的情况一样。你不小心写成vo
了v0
.
推荐阅读
- xml - Linux 上带有中文字符的 XML UTF-8/ISO-8859-1 编码问题
- react-native-gifted-chat - 在 react-native-gifted-chat 中设置悬停样式
- php - PHP:如何将部分日期(dd-mm)转换为时间?
- dax - 从 SUMMARIZECOLUMNS 表中检索最大值
- ruby-on-rails - 导入数据时出现postgresql错误
- jestjs - Jest 有没有办法根据输入有条件地返回一个值?
- c - 简化 C 中的多重相等检查
- python - 如何从 pandas Dataframe 创建单个字典?
- python - discord.py 检查用户是否具有特定角色
- javafx - derby 数据库打开和关闭连接