The YGREC8's Manual : the SA opcode

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

PRELIMINARY / WORK IN PROGRESS



Encoding

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

Description

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

SA gets a byte from the SND register, arithmetic-shifts it (preserves the sign bit like a signed division, depending on the value of the SRI operand) and writes it back to SND.

The shift amount from SRI is either a Imm4 or a register, the value is truncated to 4 bits and gives a 1s-complement signed integer. The sign (bit 3) determines the direction of the shift:

Effects

This instruction affects the Sign and Zero flags, but not the Carry flag.

Forms

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

Examples

SA 3 R1  ; R1 = R1 << 3

SA -3 R1 ; R1 = R1 >>> 3

SA R2 R1 ; R1 arithmetic-shifted depending on the 4 LSB of R2

; TODO : more numerical examples