MIPS:小写到大写

MIPS: Lower to uppercase

我真的需要这方面的帮助。我正在尝试制作一个将所有小写字母转换为大写字母的函数。 示例:"Hi everyone!" -> “大家好!

这就是我目前所拥有的(我知道这并不多,但我只是不知道如何从这里继续前进,已经尝试了几个小时)

to_upper:
    #PSEUDOCODE:
    # load byte
    # send to the ASCII-function
    # check if the ASCII is a upper or lower
    # store/save is somewhere - if upper
    # if lower, subtract 20 in hexadecimal  and then store it together with the other upper
    # print back

    #### MY CODE:
la $t0, STR_str
j check_if_upper

check_if_upper:
lb $t1, 0($t0)
ble $t1, 96, is_upper
j is_lower

is_upper:

is_lower:

exit_to_upper:
jr $ra

希望以下代码对您有用。我用了 MARS MIPS simulator.

.data
input: .space 20
newline: .asciiz "\n"

.text
main:
    li $v0, 8
    li $a1, 20
    la $a0, input
    syscall

    li $v0, 4
    li $t0, 0

loop:
    lb $t1, input($t0)
    beq $t1, 0, exit
    blt $t1, 'a', case
    bgt $t1, 'z', case
    sub $t1, $t1, 32
    sb $t1, input($t0)

case: 
    addi $t0, $t0, 1
    j loop

exit:
    li $v0, 4
    la $a0, input
    syscall

    li $v0, 10
    syscall

测试

mips lowercase
MIPS LOWERCASE