ISA & Assembly
On little-endian RISC-V, a register holding 0x12345678 is stored with sw to address 0x100. What value does lbu then read from address 0x101?
- A0x34
- B0x56
- C0x78
Show answer and explanation
Answer: B. 0x56
Little-endian places the bytes of a value in ascending addresses starting from the least significant. For 0x12345678, address 0x100 holds 0x78, 0x101 holds 0x56, 0x102 holds 0x34 and 0x103 holds 0x12. So the byte at 0x101 is 0x56. In big-endian the order would be 0x12, 0x34, ... from 0x100, and 0x101 would hold 0x34. The difference matters when handling network or file formats.
- A. 0x34 is at address 0x102.
- B. Correct. It is the second-lowest byte.
- C. 0x78 is at address 0x100.