A83: Re: Re: Re: Re: Problem with a program
[Prev][Next][Index][Thread]
A83: Re: Re: Re: Re: Problem with a program
What do you mean djnz is 16-bit? That it is a 16-bit instruction?
Anyway, if you want a really, really, really long loop, why stop with 2 registers? :)
xor a
ld b,a
ld c,b
ld d,c
ld e,d
ld h,e
ld l,h
Loop:
djnz Loop
dec a \ jr nz,Loop
dec c \ jr nz,Loop
dec d \ jr nz,Loop
dec e \ jr nz,Loop
dec h \ jr nz,Loop
dec l \ jr nz,Loop
:)
----- Original Message -----
From: "Laurens Holst" <laurensh1@yahoo.com>
To: <assembly-83@lists.ticalc.org>
Sent: Friday, December 10, 1999 7:15 AM
Subject: A83: Re: Re: Re: Problem with a program
And DJNZ is 16-bit.
But using a trick (see below), you can make 16-bit loops which are almost as
fast as DJNZ.
Trick: input=nr. of loops in BC
ld a,c ;preloop-part
ld c,b
ld b,a
dec bc
inc b
inc c
Loop: ;the loop itself
xxx
xxx
xxx
djnz Loop
dec c
jr nz,Loop
Ofcourse you can shorten this by precalculating BC.
~Grauw
Follow-Ups:
References: