admin管理员组文章数量:1026134
This function should return the pointer to the first letter character in the next word of the string and if there is no next word, it should return 0. The input is a pointer to a string that isn't null. So if the input were to be the pointer to "fat; !1guys []rock", then the output should be the pointer to "guys []rock".
I have a function already called isletter that returns 1 if the input is a letter and 0 if it is not.
I am mainly having trouble with using lb
when loading the value of $t0
into $t1
, and getting an address out of range error with it.
nextword:
move $t0, $a0
j find_letters
find_letters:
lb $t1, ($t0)
beqz $t1, no_next_word
jal isletter
bnez $v0, skip_letter
addi $t0, $t0, 1
j skip_non_letters
skip_letter:
addi $t0, $t0, 1
j find_letters
skip_non_letters:
lb $t1, ($t0)
beqz $t1, no_next_word
jal isletter
beqz $v0, skip_non_letter
addi $t0, $t0, 1
j next_word_found
skip_non_letter:
addi $t0, $t0, 1
j skip_non_letters
next_word_found:
move $v0, $t0
jr $ra
no_next_word:
li $v0, 0
jr $ra
This is what I have so far.
This function should return the pointer to the first letter character in the next word of the string and if there is no next word, it should return 0. The input is a pointer to a string that isn't null. So if the input were to be the pointer to "fat; !1guys []rock", then the output should be the pointer to "guys []rock".
I have a function already called isletter that returns 1 if the input is a letter and 0 if it is not.
I am mainly having trouble with using lb
when loading the value of $t0
into $t1
, and getting an address out of range error with it.
nextword:
move $t0, $a0
j find_letters
find_letters:
lb $t1, ($t0)
beqz $t1, no_next_word
jal isletter
bnez $v0, skip_letter
addi $t0, $t0, 1
j skip_non_letters
skip_letter:
addi $t0, $t0, 1
j find_letters
skip_non_letters:
lb $t1, ($t0)
beqz $t1, no_next_word
jal isletter
beqz $v0, skip_non_letter
addi $t0, $t0, 1
j next_word_found
skip_non_letter:
addi $t0, $t0, 1
j skip_non_letters
next_word_found:
move $v0, $t0
jr $ra
no_next_word:
li $v0, 0
jr $ra
This is what I have so far.
本文标签: How to get the pointer of the next word in MIPS assemblyStack Overflow
版权声明:本文标题:How to get the pointer of the next word in MIPS assembly? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745630343a2160124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论