The YGREC8's Manual : the LDCL opcode

Created lun. 30 oct. 2023 02:57:44 CET by whygee@f-cpu.org

PRELIMINARY / WORK IN PROGRESS



Encoding

15141312 111098 7654 3210
1 0 1 0 0 0 1 0 0 × SRI SND
1 Imm4

Description

LDCL is the complementary opcode to the LDCH opcode.

LDCL fetches data from the program memory space and writes the Least Significant Byte from the instruction to the SND register.

This instruction helps implement constant tables that could be read in-place or stored in an overly before being moved to data memory (for example). So it mostly makes sense when used with the SRI register operand along with the .BL pseudo-instruction.

Effects

This instruction does not affect the Carry, Sign and Zero flags.

Forms

This is an optional operation in the "extended opcode" range, which supports only 2 types of operand for SRI, without condition:

Examples

LDCL 3 R1 ; quite pointless since it
  ; could be directly done with SET

; this code sends 12 constant bytes to an IO register:
set start_string R1

  ldcl R1 R2 ; load the constant from program memory
  out 123 R2 ; send the constant to I/O
  add 1 R1
  cmpu end_string R1
  add -4 PC IFNZ

HLT

start_string:
  .BL 12, "hello world!\n"
end_string: