<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Sat, 21 Oct 1989 11:53:26 GMT
From   : mcsun!unido!altger!snoopy@uunet.uu.net (Mathias Niemz)
Subject: Division by Z80

Someone was looking for multiplikation/division with a Z80. Here is a
routine for a 16-bit-division:

.z80
;
; in: bc=divisor de=divident
; out: bc unveraendert, de=rest, hl=quotient
;
divi:
       ld      bc,111h
       ld      de,7000h        ; 7000/111= ????
       xor a
       ld      h,a
       ld      l,a
       ld      a,16
dloop: rl      e
       rl      d
       adc     hl,hl
       sbc     hl,bc
       jr      nc,diffok
       add     hl,bc
diffok:        ccf
       dec     a
       jr      nz,dloop
       rst     38h
       end
-- 
uucp: ...!pyramid!netmbx!altger!snoopy or ...!uunet!altnet!altger!snoopy
Snailmail: Mathias Niemz, Preussenallee 23, D-1000 Berlin 19
Phone (Voice !) D-030 305 50 60   Fax (on vacancy only !): 49 5121 15405
Datex-P: (0262)44 3000 90345 (no uucp yet)   GEO1:M.Niemz  bix:m.niemz

<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>