mondi wrote: check the hex value of each character, if its between 0x61 (a) and 0x7A (z)... then subtract 0x20 (A-Z = 0x41 -> 0x5A) that should do it. m
Comments
that should do it.
m
any chance you could elaborate on that?? How do you read the hex value and alter it??
thank you much!!
heres a quick example of what you'd want, bear in mind that my MIPS is terribly rusty, but it seems to work in pcspim alright ...
[PHP]
# vars
.data
ask_for_input: .asciiz "enter a string: "
thestring: .asciiz ""
.text
main:
# prompt
li $v0,4
la $a0, ask_for_input
syscall
# get input
li $v0,8
li $a1,30
la $a0,thestring
syscall
li $v0,4
li $t0,0
# loop and check ...
loop: lb $t1,thestring($t0)
beq $t1,0,finished
bgt $t1,122,continue #if $t1 > "z" (0x7A) skip subtraction
blt $t1,97,continue #if $t1 < "a" (0x61) skip subtraction
sub $t1,$t1,32 #else subtract 32 (0x20)
sb $t1,thestring($t0)
continue:
addi $t0,$t0,1
j loop
finished:
li $v0,4
la $a0,thestring
syscall
li $v0,10
syscall
[/PHP]