I am trying to write a program in assembly using MIPS instruction set to change a string from lower case to upper case. I have a bulk of the code, but I am new to assembly and don't know what else to do to get the string to print out. I am trying to compare the ASCII value to see if it is lowercase. If it is then it is converted, but if not the character is copied into the target. If anyone has suggestions please let me know. Thanks. here is the code:


# -----------------------------------------------------------------------------
# wrk5.s

# Example of procedure calls for Worksheet 5

# -----------------------------------------------------------------------------

.data
.align 0
A: .asciiz "Assembly code is cool"
B: .asciiz " "
.text
.align 2

# P R O C E D U R E D E F I N I T I O N S
# -----------------------------------------------------------------------------
# Module Name: main
# Description: Displays a string as all upper case.
# Input: None
# Output: None
# -----------------------------------------------------------------------------
main: la $a0, A
la $a1, B
jal upper
li ($a1),11
j EXIT


# -----------------------------------------------------------------------------
# Module Name: upper
# Description: Copies a source to a target, and converts
# target to upper case. The number of characters
# copied (not converted) is returned.
#
# Input: $a0 : memory address of source string
# $a1 : memory address of target string
# Output: $v0 : number of bytes copied
# -----------------------------------------------------------------------------
upper: jal strcpy ;jump and link to strcpy method
addi $t3, $zero, 97
addi $t4, $zero, 122

LOOP: lb $t2, O($t1) ;load the address of the string into $t2(temp register)

slt $t5, $t3, $t2 ;compare the upper case A(ASCII value 97) with the byte

blez $t5, O($ra) ;
slt $t6, $t2, $t4 ;compare the lower case z(ASCII value of 122) with the byte
blez $t6,O($ra)
addi $t2, $t2, -32 ;translate the byte into caps in ASCII by subtracting 32
sb $t2, O($t1) ;store the string into the temp reg.
addi $t1, $t1, 1 ;increment the position in the string $t1
bnez $t1, LOOP ;branches if $t1 <> 0
jr $ra ;return to caller




# -----------------------------------------------------------------------------
# Module Name: strcpy
# Description: Copies a source to a target
# Input: $a0 : memory address of source string
# $a1 : memory address of target string
# Output: $v0 : none
# -----------------------------------------------------------------------------
#;; t0 - current address of source
#;; t1 - current address of target
#;; t2 - tmp value

strcpy:
add $t0,$a0,$zero ; copy $a0 to $t0
add $t1,$a1,$zero ; copy $a1 to $t1
LOOP3: lb $t2,0($t0) ; load src word into $t2
sb $t2,0($t1) ; store $t2 into target
addi $t0, $t0, 1 ; increment addr. by 1
addi $t1, $t1, 1 ; increment addr. by 1
bnez $t2,LOOP3 ; branch if $t2 <> 0x00
jr $ra ; return to caller