I wrote this simple program just to try and check if slt
or any other comparing instruction can tell me if the value inside the string and the integers it represent are bigger then the other one. It's not working and I don't know why.
- Is this comparison legal or should I turn the strings to real integers?
- Why doesn't it work? from my understanding the address of each string+offset should move the correct value too
$t0
and$t1
. - How do I turn this strings to the integers they represent?
- what can I do in case their are more then 4 integers inside the string? how can I turn "123456" to be the integer in decimal inside the memory? (hex is good too of course)
here's the code: (exited badly after doing the second lw
)
.data
str1: .asciiz "1234"
str2: .asciiz "1222"
.text
.globl main
main:
lw $t0, str1($t0)
lw $t1, str2($t1)
slt $t2, $t0, $t1
li $v0, 10
syscall