----------------------------------------------------------------------------------
@MSGID:
<b7ddafab-f0a8-421a-9fdc-0ddc33f71d1fn@googlegroups.com> a641bcd4
@REPLY:
<59d24b8d-aec5-4917-b2f9-fa79b1c6162bn@googlegroups.com> 5c4dfe75
@REPLYADDR Mark Ogden <ogdenpm@gmail.com>
@REPLYTO 2:5075/128 Mark Ogden
@CHRS: CP866 2
@RFC: 1 0
@RFC-References: 1@dont-email.me>
<59d24b8d-aec5-4917-b2f9-fa79b1c6162bn@googlegroups.com>
@RFC-Message-ID:
<b7ddafab-f0a8-421a-9fdc-0ddc33f71d1fn@googlegroups.com>
@TZUTC: -0700
@PID: G2/1.0
@TID: FIDOGATE-5.12-ge4e8b94
On Saturday, 12 August 2023 at 19:57:57 UTC+1, George Phillips wrote:
> If you`re willing to alter the count you can do the 16 bit
loop as two 8 bit tests which will be faster. For example, suppose your
16 bit loop count is in DE. This code will execute the loop DE
times:
>
> ; transform DE to split count
> dcx d
> inr d
> inr e
> loop:
> ; ... processing here
> dcr e
> jnz loop
> dcr d
> jnz loop
>
> To see how it works consider the two cases going in where E is
zero and not zero. Or, equivalently, when DE is a exact multiple of 256
or not. Note that the value of E never changes. If E is not zero
then 1 is added to D. The inner loop will do E iterations and then
after that it will do 256 iterations D times (the original value of D).
Check it with $0003 and $0103 to get the idea.
>
> If E is zero then D is not altered either. The inner loop will
always be 256 iterations and will be executed D times. Checking $0100 and
$0000 will show the correctness. Like with a conventional 16 bit loop,
$0000 means 65536 iterations.
If a count of zero is valid, then the tests need to be moved to
the start of the loop
; de = count
inr d ; or lxi d, count + 101h
inr e
endtest:
dcr e
jnz loop
dcr d
jz done
loop:
; processing here
jmp endtest
--- G2/1.0
* Origin: usenet.network (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5075/128
@PATH: 5075/128 5020/1042 4441