Re: LZ: NEW Z80 INSTRUCTION FOUND!!


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

Re: LZ: NEW Z80 INSTRUCTION FOUND!!



On Thu, 26 Sep 1996, Jimmy Mardell wrote:


> I call it new since it doesn't work on all Z80 models, and it's not in
> tasm80.tab, but it works! The instruction is called SLS and works like SLA
> except that instead of putting a 0 at bit 0, 1 is put there instead. So
> SLL A will do A=A*2+1. I don't know when it could be useful (you'll save
> some byte in some programs I guess) though.
> 
> I checked the emulator source, where it's called SLL (Shift Left Logically
> I guess, but I can't see why it's logical...) so I don't know if it should
> be SLS or SLL.


That SLS instruction is short for Sticky Left Shift, or Shift Left Sticky
depending on who you ask.


It's an SLA where... well I'll draw it here.


ld a,00000001b    ;
sla a             ;returns 00000010


ld a,00000001b    ;
sls a             ;returns 10000011


ld a,00000010b    ;
sla a             ;returns 00000100


ld a,00000010b    ;
sls a             ;returns 00000100


So it' really and SLA and then a bit copy from the (2^1) column to the
(2^0) column.  There should be a corresponding right shift version that
does an SRA and then copies bit 6 to bit 7  (numbered 7-0, left to right
[MSBF] )


This instruction has practical applications in cryptography, where in
order to speed up huge multiplications (ie RSA en-/de- cryption) bit
shifts are used to shuffle things around instead of composing a giant
multiprecision integer math library.


Chris


References: