I’m not sure what’s wrong with my algorithm here, it seems like my $t3 register is almost always 9 or less so I just get a ton of 48s in a row.
Here is the code:
.data
prompt: .asciiz "Please enter value: "
ans: .asciiz "Hex: "
#*****************
.text
.globl main
main:
la $a0, prompt
li $v0, 4
syscall
li $v0, 5
syscall
move $t2, $v0
la $a0, ans
li $v0, 4
syscall
Loop:
rol $t4, $t2, 4
and $t3, $t4, 0xf
ble $t3, 9, Add
addi $t3, $t3, 55
j Print
Add:
addi $t3, $t3, 48
Print:
li $v0, 1
move $a0, $t3
syscall
beqz $t2, EndLoop
srl $t2, $t2, 4
j Loop
EndLoop:
li $v0, 10
syscall
Any help is greatly appreciated
I honestly don’t exactly know what
rol $t4, $t2, 4
and $t3, $t4, 0xf
exactly does but I think this is where the error is. I’ve messed with it a bit but it still doesn’t work.
New contributor
prod jetskiii is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.