- #1
ACLerok
- 194
- 0
I'm trying to write a program that will have the user enter in an expression in the form: A (operation) B (operation) C and print out the result. After the user enters in the expression, I want to parse out each individual digit or expression by reading the ASCII code of each individual character by storing each digit or operation in its own register. I'm having trouble reading each separate character after the user enters the expression.
li $v0, 8
la $a0, expr
li $a1, 20
syscall
How do I store each character? Something like the code below? (I know the code below will not work.) Am i supposed to store the string in a new register before reading each separate byte?
sb 0(expr), $t0
Also, since I'm only working with numbers between 20 and 99, and the operations + and *, is it ok to reserve only 5 bytes for the entire expression since 1 byte can represent one ASCII character?
li $v0, 8
la $a0, expr
li $a1, 20
syscall
How do I store each character? Something like the code below? (I know the code below will not work.) Am i supposed to store the string in a new register before reading each separate byte?
sb 0(expr), $t0
Also, since I'm only working with numbers between 20 and 99, and the operations + and *, is it ok to reserve only 5 bytes for the entire expression since 1 byte can represent one ASCII character?
Last edited: