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?

  1. A0x34
  2. B0x56
  3. 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.
Practice this topic Back to topic

More ISA & Assembly questions

  1. In RISC-V, what can happen when the address of a 4-byte lw is not a multiple of 4 (misaligned)?
  2. The RISC-V instruction "slli t0, a0, 3" makes t0 how many times the value of a0 (ignoring overflow)?
  3. a0 holds the start address of an int (4-byte) array a, and a1 holds an index i. What does the code above load into a2?
  4. Which statement is correct about designs like x86, where an arithmetic instruction such as "add eax, [rbx]" can use a memory value directly?
  5. How do today's high-performance x86 CPUs execute complex instructions internally?