[A83] Re: Rotate 16 bits?


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

[A83] Re: Rotate 16 bits?



> Is there an instruction to rotate a sixteen-bit register, or do I have to
> do something like rotate the low byte and high byte seperately, and then
> increment the high byte if the low byte produced a carry? (rotating left)
>
> Along the same lines, is the ADC instruction the same as the x86, where
you
> add if carry, or is it different?

There is no 16-bit rotate instruction.

Info on ADC:
<copied>
                         Add with carry

                           8 bit group

This set of instructions are essentially the same as the ADD set,
but add the carry flag as well. The instruction is ADC instead of
ADD.  Thus  LD A 4:ADC A 3 would give an answer of 7 if the carry
flag was 0, but an answer of 8 if the carry flag was 1 before the
instruction.

The  ADC instruction allows multiple precision adding.  The least
most significant bytes are added,  and the carry is propogated to
the next most significant bytes by using ADC.

For the 8 bit ADC's using th A register the flags are affected

C or carry flag          1 if answer >255 else 0
Z or zero flag           1 if result = 0 else 0
P flag                   1 if TC <-128 or >127 else 0
S or sign flag           1 if 127 < n < 256 else 0
N flag                   0
H or half carry flag     1 if carry from bit 3 to bit 4 else 0

                     8 bit ADC instructions

ADC A,A        ADC A,B        ADC A,C        ADC A,D
ADC A,E        ADC A,H        ADC A,L        ADC A,n
ADC A,(HL)     ADC A,(IX+d)   ADC A,(IY+d)

                        16 bit ADC group

The 16 bit ADC instructions use the HL register instead of the  A
register. The flags are affected as follows

C or carry flag          1 if answer >65536 else 0
Z or zero flag           1 if result = 0 else 0
P flag                   1 if TC <-32768 or >32767 else 0
S or sign flag           1 if 32767 < n < 65536 else 0
N flag                   0
H or half carry flag     1 if carry from bit 11 else 0

                        16 bit ADC group

ADC HL,BC      ADC HL,DE      ADC HL,HL      ADC HL,SP

</copied>

Hope this helps!

Jeff



References: