[A83] Re: Rotate 16 bits?


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

[A83] Re: Rotate 16 bits?



> shl h
> shl l
> adc h,0
> 
> But indeed it is impossible, so I should rotate the low byte left, then 
> rotate the high byte left with the carry (I think that's what had been 
> suggested) I don't, however, get the ones with the jumping.
> 
x86's SHL is called SLA on the Z80... Anyway, you don't need such ADC
tricks, because you can rotate the carry into any general purpose
register.

What's the problem with a conditional jump?

Let's see and example with DE (same goes for BC and HL):

...
SLA E ; Shifting E to the left, padding with zero from the right
RL D ; Shifting D to the left, padding with carry (the former MSB of E)
from the right
JR NC, NoOverflow ; Jumping if the carry is not set, i. e. D was <128
before the shift
INC E ; Since the LSB of E is zero, this will work perfectly
NoOverflow:
...
If you want shifting without rotation, just drop the jump and the
increment.

PG

-- 
http://www.fastmail.fm - mmm... Fastmail...



References: