[A83] Re: Rotate 16 bits?


[Prev][Next][Index][Thread]

[A83] Re: Rotate 16 bits?



I would like to propose the following code for 16-bit 
rotates. These are "in-place" rotates, with the carry
bit set to the value of bit 15 for a rotate left, and 
the value of bit 0 for a rotate right, i.e. analogous
to the behavior of the RLC and RRC instructions.

; rotate left, i.e. "RLC HL"

RLC H      ; rotate H left, CF = MSB of H
RRC H      ; restore H by rotating right, CF = MSB of H
ADC HL, HL ; LSB of L = old MSB of H, CF = old MSB of HL

; rotate right, i.e. "RRC HL"

RRC L      ; rotate L right, CF = LSB of L
RLC L      ; restore L by rotating left, CF = LSB of L
RR  H      ; MSB of H = old LSB of L, CF = LSB of H
RR  L      ; MSB of L = old LSB of H, CF = LSB of HL


-- Norbert





Follow-Ups: