The Editors and
Readers of COMPUTE!
If you have any questions, comments, or suggestions you would like to see addressed in this column, write to "Readers' Feedback," COMPUTE!, P.O. Box 5406, Greensboro, NC 27403. Due to the volume of mail we receive, we regret that we cannot provide personal answers to technical questions.
I have recently written a program in 6502 machine language for the VIC-20. I want to have a one- or two-second pause between the title screen and the main program, but I don't know how to make one.
One way to create a delay in machine language (ML) is to use a do-nothing loop much as you would in BASIC. For instance, the BASIC loop shown here pauses for about one second on a VIC:
FOR TD=1 TO 1000:NEXT
A similar machine language loop looks like this:
This loop creates a delay, but only for a fraction of a second. To produce a longer delay, you could use two nested loops:
This loop delays for about a second. For longer delays you can use more nested loops combining different memory locations and registers. Some computers have a built-in clock that's available for the same purpose. On the Commodore 64 and VIC-20, for instance, location 162 is incremented every 1/60 second by the computer's hardware interrupt routine. To create a delay with the built-in clock, store a zero in location 162, then wait until it reaches the number of seconds you want to delay divided by 60. This short routine creates a three-second delay:
WAIT LDA 162