Re: A83: Slowing down a program


[Prev][Next][Index][Thread]

Re: A83: Slowing down a program




Why not just do something like:
ld b,5
ei
loop:
halt
djnz loop

I use it all the time! and if you want to use only one:
ei
halt
One halt is probably longer than a 257x djnz loop... I could be wrong
but.... halt takes 1/200 of a second (assuming you're using all the default
settings set up at the start of your program for the timer and you just did
an ei). 1/200 of a second.... that's a vacation in asm!

For an even better delay that is actually helpful, try calling TI's buffer
copy routine, or maybe a key detect loop multiple times... but that's
getting a little off the subject I suppose.

-----Original Message-----
From: Linus Akesson <lairfight@softhome.net>
To: Ahmed El-Helw <assembly-83@lists.ticalc.org>
Date: Tuesday, June 23, 1998 3:58 PM
Subject: Re: A83: Slowing down a program


>
>Halt will block the processor until an interrupt occurs. This is fine if
that
>interrupt occurs exactly where you want it to, but normally it doesn't.
You'll
>have to: Enable interrupts, Mask out all interrupts except the timer
>interrupts,  Set the speed of the timer interrupts, AND normally one halt
is
>too fast anyway. Doing a busywait is _much_ better, because if you've
disabled
>interrupts aswell, you always get exactly the same delay.
>
>Let us not end there, but instead make a size comparison.
>
>elhelw_init:  ei                 fb
>              ld    a,1110b      3e0e
>              out   (3),a        d303
>              ld    a,0110b      3e06
>              out   (4),a        d304 (total: 9 bytes)
>
>Every time you need to wait, you use a 1-byte halt instruction.
>
>akesson:      di                 f3
>
>akesson_wait: ld    b,00h        0600
>.loop:        djnz .loop         10fe
>              ret                c9   (total: 6 bytes)
>
>Every time you need to wait, you use a 3-byte call instruction.
>
>This, together with the fact that my routine can be easily trimmed to any
>speed by changing the constant put in b, rather makes me turn myself to
you,
>and ask: why all that? just do djnz!
>
>Linus
>
>
>
>On 22-Jun-98, Ahmed El-Helw wrote:
>
>
>>why all that?
>>just do halt.
>
>>                                        -Ahmed
>
>>-----Original Message-----
>>From: Olle Hedman <oh@hem.passagen.se>
>>To: assembly-83@lists.ticalc.org <assembly-83@lists.ticalc.org>
>>Date: Monday, June 22, 1998 4:27 PM
>>Subject: Re: A83: Slowing down a program
>
>
>>>
>>>At 15:38 1998-06-22 -0400, you wrote:
>>>>
>>>>Heh...I got my fade thing to work, thanks to Harper Maddox but it goes
>>>>so fast that the fade is impossible to see.  Is there a way to have the
>>>>calc wait for just a fraction of a second, so the fade is slow enough to
>>>>be seen?  Thanks.
>>>>
>>>>   Mark Allen
>>>>
>>>
>>>
>>>just make a litle "do-nothing" delay-loop..
>>>
>>>like:
>>>
>>> ld b,0ffh
>>>loop nop
>>> djnz loop
>>>
>>>
>>>or if you want a longer delay:
>>>
>>> ld b,0ffh
>>>loop push hl
>>> pop hl
>>> djnz loop
>>>
>>>or something similar..
>>>
>>>I guess you get the idea.. :)
>>>
>>>//Olle
>>>
>>>
>
>
>