Nios/bswap

From ASMBits

When communicating multi-byte (hword or word) values between machines of different endianness, it is sometimes necessary to swap the byte ordering. Write a function that will reverse the byte ordering in a 32-bit word. (Note that only bytes are swapped. The 8 bits within each byte are still in the same order.)

The function has one parameter: The input number.

Expected solution length: Around 10 lines.

Sample Input

0x11223344

Sample Output

r2=0x44332211

Write your solution here

x
 
1
# A test case to test your function with
2
.global _start
3
_start:
4
    movia r4, 0x11223344
5
    call bswap
6
    br _start        # End of testing code
7
8
# Byte swap
9
bswap:
10
    
11
    
Upload a source file...