How to get the pointer of the next word in MIPS assembly? - Stack Overflow

This function should return the pointer to the first letter character in the next word of the string an

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745630345a4637069.html

相关推荐

  • How to get the pointer of the next word in MIPS assembly? - Stack Overflow

    This function should return the pointer to the first letter character in the next word of the string an

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信