[A83] Re: Division


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

[A83] Re: Division




> Divide:
>  push bc  ; save bc
>  sub a    ; clear a
>  ld b,8   ; 8 shifts
> DivideL:
>  sla d    ; shift left d
>  rla    ; into a
>  cp c    ; is a >= c
>  jr c,DivideS ; skip if not
>  sub c
>  inc d   ; a = a-c, set bit in d
> DivideS:
>  djnz DivideL  ; loop
>  pop bc   ; restore bc
>  ret   ; done
> 
I have two problems with this routine:

1. It should be unrolled, if speed is important.
(if not, the rom routine is undoubtedly the best choice)

2. the dividend can only be 8 bits long,
which is basically useless for general
purposes.

PG






References: