A83: Re: Re: Re: Re: Re: Re: Problem with a program


A83: Re: Re: Re: Re: Re: Re: Problem with a program

Geez, really nobody has a sense of humor here.
It seems to me that my loop would work, but it would repeat 256 + 256^2 + 256^3 + 256^4 + 256^5 + 256^6 + 256^7 or

n = 7
E 256^i
i = 1

= 72340172838076672 times, I think? Oh yeah, E stands for summation, if nobody figured that out already. :)

If you wanted a loop that went only 100h times then this would be fine:
ld b,0
ld c,b
djnz Loop
dec c \ jr nz, Loop

If you want to go 106h times, then you'd have to figure out something else. Sheesh.
BTW, what's fudeba?

----- Original Message ----- 
From: "Laurens Holst" <laurensh1@yahoo.com>
To: <assembly-83@lists.ticalc.org>
Sent: Saturday, December 11, 1999 11:37 AM
Subject: A83: Re: Re: Re: Re: Re: Problem with a program

> 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

Hmm that won't work. You will need to do some more precalculating.
Example (in the case of a 16-bit loop using the above):

What if you want to repeat #100 times, eh? You swap that, B=0, C=1. You
start DJNZ. At the end, you have done 256 loops. C will be decreased, is
zero, routine stops. So far so good. But what if you want to repeat #106
times, for example? Will be swapped, B=6, C=1, DJNZ will repeat six times, C
will be decreased, and oh no! It stops! Only 6 repeats, that's no good. At
first, I solved this problem by precalculating the value in BC and putting
it directly into it using LD BC,nnnn. However, this was not looking very
well, and besides, often the value of BC wasn't fixed. So I made a
construction using a conditional jump. After a while I put my routine on the
MSX Mailinglist, and then Maarten ter Huurne told me this could also be done
by simply issueing a DEC BC, INC B, INC C.

> :)

You're fudeba.


          email me: laurensh@geocities.com or ICQ: 10196372
             visit the Datax homepage at http://datax.cjb.net/
MSX fair Bussum / MSX Marathon homepage: http://msxfair.cjb.net/

Follow-Ups: References: