How do C.LH and C.LHU differ?
Both read 16 bits at base plus 0 or 2 bytes. C.LH sign-extends and C.LHU zero-extends: on RV64, 0x8001 gives 0xffffffffffff8001 and 0x8001 respectively.
RV32/RV64 Zcb 16-bit halfword load: offset 0 or 2 bytes; sign-extend the 16-bit value to XLEN.
C.LH (Zcb, CLH format) loads a halfword from rs1' + zero-extended offset into rd', sign-extended to XLEN. rd' and rs1' limited to x8-x15. Expands to lh rd',uimm(rs1'). Offset is 1-bit unsigned ×2. Part of Zcb, depends on Zca.
Shows only official 16-bit fields, address/immediate calculation, and architectural state; it does not simulate a pipeline, cache, endianness implementation, or timing.
RV32 / RV64 Zcb (requires Zca)
An address divisible by 2 is naturally aligned, so the address-misaligned option does not apply; access faults remain possible. The EEI defines misaligned completion. Memory values are already interpreted using EEI endianness.
RV32/RV64 Zcb 16-bit halfword load: offset 0 or 2 bytes; sign-extend the 16-bit value to XLEN.
RV64 Zcb, x10=0x2000 and mem16[0x2002] = 0x8001, with a completed access: c.lh x9, 2(x10) gives x9 = 0xffffffffffff8001; RV32 gives 0xffff8001.
Both read 16 bits at base plus 0 or 2 bytes. C.LH sign-extends and C.LHU zero-extends: on RV64, 0x8001 gives 0xffffffffffff8001 and 0x8001 respectively.
No. An odd base makes the effective address misaligned; even naturally aligned accesses must meet the EEI memory-region and permission rules.