最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin5PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far