MIPS: how to manipulate strings stored in program arguments?

0

So basically the input of the program is 2 separate strings in the program arguments section. They can either be 0x... (hex), or 0b... (binary). The code I have so far is :

li $v0, 36
lw $t1, ($a1)
lb $t2, 2($t1)
syscall

li $v0, 36
lw $t3, 4($a1)
lb $t4, 2($t3)
syscall

The li $v0, 36's are just prints to check if I got the value.
The main problem is that $t1 and $t3 have the correct memory address. I can see that in $a1's memory address there are stored two separate memory addresses for the string location. $t1 and $t3 contain those, while $t2 and $t4 are supposed to shift over and read the second character.

For some reason, no matter what the input of the program arguments, this always prints 2. If I change the syscall to 34 it will print 0x00000002 and if I change it to 11 to print a char, as usual, it will print a box. I just need to identify if it is an x for hex or b for binary, so I can edit the inputs accordingly. Any help would be awesome.

EDIT : Even if I do syscall 11 on either a 2 shift OR a 1 shift, it prints a box. Like a [] instead of an actual character.

assembly
memory-management
mips
asked on Stack Overflow Mar 3, 2019 by Asagely • edited Mar 4, 2019 by Asagely

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0