assembly - MIPS: Lower to uppercase -
i need one. i'm trying make function converts lower case upper. example: "hi everyone!" -> "hi everyone!
this have far (i know it's not don't know how move on here, been trying hours)
to_upper: #pseudocode: # load byte # send ascii-function # check if ascii upper or lower # store/save somewhere - if upper # if lower, subtract 20 in hexadecimal , store other upper # print #### 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
i hope following code works you. used 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
Comments
Post a Comment