我编写了一个练习但是我发现了一个小问题...我的练习问我转换一个字符(键盘输入):
没有MIPS系统调用。 3点上的2点现在已经解决,但在第2点我发现了我的问题...例如,当我插入一个字母时,二进制代码被反转(见下文)
给我一个角色:a ASCII:97 二进制10000110(真实是01100001)
存在一种简单的方法来反转这个数字?我留下下面的代码。
print_binary:
#move the function parameter in t0
move $t0, $a0
#Show a message
li $v0, 4
la $a0, m3
syscall
while:
#check if my counter is 8(conversion on 8 bit)
beq $t2, 8, end_loop
#Divide the number
div $t1, $t0, 2
#move hi in t4 to show in video
mfhi $t4
#Counter
add $t2, $t2, 1
#move for another division
move $t0, $t1
#Show hi for every division
li $v0, 1
move $a0, $t4
syscall
j while
end_loop:
jr $ra
我没有很好地使用数组,所以如果可能的话我会避免这种方法...
谢谢