Re: A83: Signed Division


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

Re: A83: Signed Division




Will this work?  If it does, I don't know if it would be faster than the other routine, but it is smaller.

Div: ; hl = bc/de, a = ???
 ld a,d
 or e
 scf
 ret z
 ld h,b
 ld l,c
DivLoop:
 or a
 sbc hl,de
 jr nc,DivLoop
 add hl,de
 res 7,h
 ld a,b
 xor d
 and 10000000b
 or h
 ld h,a
 ret

-Kouri
http://kouri.cjb.net

On Sun, 02 Jan 2000 04:55:56   Robin Kay wrote:
>Div:               ; HL=BC/DE,AF=0,BC=0,DE=0
> ld a,d
> or e
> scf
> ret z
> xor a
> bit 7,b
> jr z,div3
> inc a
> ld hl,0
> sbc hl,bc
> ld b,h
> ld c,l
>div3:
> bit 7,d
> jr z,div4
> inc a
> ld hl,0
> sbc hl,de
> ld d,h
> ld e,l
>div4:
> ld h,b
> ld l,c
> ld bc,0
>DivLoop:
> or a
> sbc hl,de
> jr c,FixSign
> inc bc
> jr DivLoop
>FixSign:
> ld h,b
> ld l,c
> or a
> res 7,h
> bit 0,a
> ret z
> ld hl,0
> sbc hl,bc
> or a
> ret


HotBot - Search smarter.
http://www.hotbot.com


Follow-Ups: