Search code examples
mipsmips32qtspim

Swap .byte Data using MIPS (QTSPIM)


I have a .byte data let's say

num1: .byte 0x5a 

I want num1 to be 0xa5 using rotate and shift operations.

I'm new to MIPS. Pls Help. Thank You


Solution

  • 0xfa got converted to 0xaf

    .data
    data1: .byte 0xfa
    
    .text
    .globl main
    .ent main
     main:
    
    lbu $t0, data1
    ror $t1,$t0,4
    
    sll $t2,$t1,4
    
    ror $t6,$t2,4
    srl $t3,$t1,4
    ror $t4,$t3,20
    add $t5,$t4,$t6
    li $v0,10
    syscall
    .end main