MIPS: Lower to uppercase
12,624
I hope the following code works for you. I used the 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
Test
mips lowercase
MIPS LOWERCASE
Author by
Aewend
Updated on June 04, 2022Comments
-
Aewend almost 2 years
I really need help with this one. I'm trying to make a function that converts all lower case to upper. Example: "Hi everyone!" -> "HI EVERYONE!
This is what I have so far (I know it's not much but I just don't know how to move on from here, been trying for hours)
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
-
Aewend about 7 yearsPerfect! Thank you so much :D