This instruction selects one of the bytes of the source register and puts it in the lower byte of the destination register. The byte is sign-extended : its Most Significant Bit is copied in the higher bytes of the destination register. It is an equivalent to the SAR instruction that works on bytes, not bits.
For the YASEP16, the instruction selects on byte out of two, while the YASEP32 selects one byte out of four, like on the following diagram:
This instruction is designed to load a signed byte from memory so it performs aligment and sign extension in a single cycle. However, the memory is accessed through the D registers, one word at a time, this instruction only performs byte-related adjustments of the word.
Usually, the bytes come from a D register, (containing data read from memory) and the offset of the byte is held in a A register (the address register) but any other register can be used. The offset can also be given with an immediate value (Imm4 or Imm16) hence it is written first.
; Load the byte located at address 123h into register R1: MOV 123h A1 ESB A1 D1 R1
• The instruction EZB is similar but works with unsigned bytes and extends the result with zeros.
• The instruction ESH is similar but works with signed half-words (16 bits).