assembly - Address Out of Range. Hex to Decimal Mips -
i trying convert hex binary. stuck. storing bite returns error "address out of range". here code:
.data input: .word 0x12345678 buff: .space 40 la $a0, input la $a1, buff .text move $t2, $a0 li $t1, 0 loop: rol $t2, $t2, 1 , $t0, $t2, 1 add $t0, $t0, 48 move $a0, $t0 li $v0, 11 syscall sb $a1, 0($a0) # runtime exception @ 0x00400228: address out of range 0x000000030 subi $t1, $t1, 1 bne $t1, 32, loop jr $ra
i found out during compilation mips turns hex decimal form, meaning 0x12345678 should change 305419896 , code should output binary of 00010010001101000101011001111000. instead, getting output of 00010000000000010000000000000000. if figuring out why address out of range , why hex doesn’t seem changing proper decimal during compile, appreciated. thank you.
update: have changed move $t2, $a0
lw $t2, 0($a0)
. m able correct binary representation. however, still receiving address out of range error on sb line.
your address out of range, because accessing wrong register.
sb $a0, 0($a1)
store byte (48) memory buff
.
similarly instruction move $t2, $a0
copies address of input
1 register another, when should access memory. lb $t2, ($a0)
load first byte of input. lw
read word , ld
read double word.
Comments
Post a Comment