I have a school assignment that requires me to convert a word from little endian to big endian in three different ways. One of them is by using multiplication and division. I know that shifting to the left multiplies the number by 2 but i still cant figure out how to utilise that.
Here is me doing it using rotate. Can someone help me step on this and do it with division and multiplication?
.data
.text
.globl main
main: li $t0,0x11223344 #number to be converted in t0
rol $t1,$t0,8
li $t2,0xFF00FF00 #mask in $t2
and $t3,$t1,$t2
ror $t1,$t0,8
li $t2,0x00FF00FF #mask in $t2
and $t1,$t1,$t2
or $t3,$t3,$t1
ror $t3,$t3,16
li $v0,10
syscall
I cant seem to convert the rotates to shifts correctly. I am doing for rol $t1,$t0,8:
#rol $t1,$t0,8
loop: beq $t1,8,exit #branch to exit if t5=8
addi $t5,$t5,1 #t5++
srl $t1, $t0, 1 #shift original word 1 bit to the right
sll $t2, $t0, 31 #shift original word 31 bits to the left
or $t1, $t1, $t2
but it is not correct.
Help is appreciated, thanks.