Reputation:
I am currently learing MIPS for a class and wrote the below sample code.
# UNTITLED PROGRAM
.data # Data declaration section
.text
main: # Start of code section
li $t1, 72
move $a0, $t1
li $v0,1
exit:
li $v0, 10
syscall
# END OF PROGRAM
As shown the value of '72' is stored in register $t1. Now, how do I parse out the '7' and '2' out?
Upvotes: 0
Views: 2988
Reputation:
Not a mips expert... but:
72 / F = 7 "7"
7 * F = 70
72 - 70 = 2 "2"
You can apply this logic using F * (number of total digits - 1) to get each individual digit.
-r
Upvotes: 0
Reputation: 4944
Divide by 10, the modulo is your next digit, repeat until the result of division is 0. This assuming you're not working with floating point numbers.
Upvotes: 1