The YGREC8's Manual : the RC opcode

Created lun. 30 oct. 2023 19:36:09 CET by whygee@f-cpu.org

PRELIMINARY / WORK IN PROGRESS



Encoding

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

Description

RC is one of the 4 optional opcodes using the dedicated "shuffler unit" that performs shifts and rotations. See also SA, SH and RO for the other variations.

RC gets a byte from the SND register, rotates it (depending on the value of the SRI operand) through the Carry Flag and writes the result back to SND. The SND and Carry flag are processed together like a 9-bit register.

The rotation amount from SRI is either a Imm4 or a register, the value is truncated to the 3 lower bits (since a 4-bit signed integer would duplicate values).

Bit 6 of the instruction is not decoded or used and should be kept cleared for forward compatibility.

Effects

This instruction affects the Carry, Sign and Zero flags.

The carry flag will go to the (N-1)th bit of the destination register, and is overwritten byt the (8-N)th bit of the source register.

Forms

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

Examples

RC 3 R1  ; R1 = R1 rotated left by 3 bits

RC -3 R1 ; MUST_FAIL: legal(?) but pointless, 
         ; use RO 5 R1 instead (8-3=5)
         ; (issue a warning ?)

RC R2 R1 ; R1 rotated depending on the 3 LSB of R2

; TODO : more numerical	examples and diagrams.