> Hello fellow-MSX'ers!
>
> I need FAST division and multiplication routines in assembler and I hope
> some of you can help me.
> I need an integer division (rests should be ignored) that does DE / B (or
> similar). Where E is always zero (maybe that helps?).
> I also need routine that does DE * B (the lower 8bit are discarded, if that
> helps).
>
> The catch with these routines is: You CAN NOT use exchange instructions
> (EXX, EX AF,AF') and you CAN NOT use IX or IY.
>
> I need both of these routines to draw a line between 2 coordinates. If
> someone has such a routine (and if its FAST) I'd be interested also.
I took quite a fast division routine from XBASIC. I used it just like you,
because I wanted to make a texture mapped box for MSX2. If you like to see
that box, you can look from : www.clinet.fi/~nyke
I don't have multiply routine here just now, but I can't stand why you
need it for line draw ???
Anyway here is the routine :
; HL = HL / DE
push de
push hl
bit 7,d
jr nz,.0
xor a
sub e
ld e,a
sbc a,a
sub d
ld d,a
.0: ld c,e
ld b,d
bit 7,h
jr z,.1
xor a
sub l
ld l,a
sbc a,a
sub h
ld h,a
.1: ex de,hl
xor a
.4: ld l,a
ld h,a
ld a,e
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.2
inc sp
.6: inc sp
jr nc,.0
.2 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.3
inc sp
.8: inc sp
jr nc,.4
.3 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.5
inc sp
.10: inc sp
jr nc,.6
.5 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.7
inc sp
.12: inc sp
jr nc,.8
.7 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.9
inc sp
.14: inc sp
jr nc,.10
.9 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.11
inc sp
.16: inc sp
jr nc,.12
.11 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.13
inc sp
.18: inc sp
jr nc,.14
.13 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.15
inc sp
.20: inc sp
jr nc,.16
.15 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.17
inc sp
.22: inc sp
jr nc,.18
.17 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.19
inc sp
.24: inc sp
jr nc,.20
.19 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.21
inc sp
.26: inc sp
jr nc,.22
.21 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.23
inc sp
.28: inc sp
jr nc,.24
.23 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.25
inc sp
.30: inc sp
jr nc,.26
.25 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.27
inc sp
.32: inc sp
jr nc,.28
.27 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.29
inc sp
inc sp
jr nc,.30
.29 equ $-1
rla
rl d
adc hl,hl
push hl
add hl,bc
jp nc,.31
inc sp
inc sp
jr nc,.32
.31 equ $-1
rla
rl d
ld e,a
ex de,hl
pop af
and a
jp p,.33
xor a
sub e
ld e,a
sbc a,a
sub d
ld d,a
ld a,80h
.33: pop bc
xor b
ret p
xor a
sub l
ld l,a
sbc a,a
sub h
ld h,a
ret
,_____.
_=_=_=_=!_MSX_!=_=_=_=_=_=_=_=_,
! A1ST ~--- - I ( o o o o o o )i
/--------------------------------`,
/ .::::::::::::::::::::::;::; ::::.,
/ :::.:.:.:::____________:::::!. -=- `,
~======================================
NYYRIKKI : [EMAIL PROTECTED]
****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****