I am attempting to convert the number 0x20014924 to a binary number. I am getting an unexpected binary readout:
0000 0001 0011 0001 0110 0111 0100 1100
actual output
0010 0000 0000 0001 0100 1001 0010 0100
expected output.
Any suggestions on debugging or where I am going wrong would be greatly appreciated!
.data #start to define user data
myStr: .asciiz "the answer = " # define a user string
myNum: .word 20014924 # define a user data word
.text # indicate that user program starts
.globl main
main: # the main routine
li $v0, 4 # system call number 4 is for printing strings
la $a0, myStr # load the starting address of myStr to $a0
syscall # now print the string
lw $t1, myNum
addiu $t0, $zero, 31 # initialized counter
addi $t2, $zero, 1 # adds 1 to the LSB
sll $t2, $t2, 31 # moves 1 to the MSB
li $v0, 1 # system call number 1 is for printing integers
loop:
beq $t0, -1, exit # checks the counter
and $t3, $t2, $t1 # $t2 AND $t1 saves to $t3
beq $t3, $0, post_shift # if the AND results in 0 skip to post shift
srl $t3, $t3, $t0 # if the AND results in 1 srl by counter
post_shift:
move $a0, $t3 # moves value of AND to arg resgister
syscall # now print the integer
sub $t0, $t0, 1 # decrements counter
srl $t2, $t2, 1 # shifts comparer 1 to the right
j loop
exit:
jr $ra # main routine returns through jump register