Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 700

Warning: Invalid argument supplied for foreach() in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 701

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 705

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 700

Warning: Invalid argument supplied for foreach() in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 701

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 705

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 700

Warning: Invalid argument supplied for foreach() in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 701

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 705

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 700

Warning: Invalid argument supplied for foreach() in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 701

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 705

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722
Introducing Interrupts - Intellivision Wiki

Introducing Interrupts


Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/content/30/6867330/html/intellivision/wiki/includes/MagicWord.php on line 722
From Intellivision Wiki

Jump to: navigation, search
m (Further Things to Contemplate)
(Example Using Interrupts: A simple timer)
Line 285: Line 285:
<br/><br/>
<br/><br/>
-
= Example Using Interrupts:  A simple timer =  
+
= Example 1:  A simple "elapsed time" clock =  
The following example attempts to demonstrate how interrupts work without
The following example attempts to demonstrate how interrupts work without
getting caught up in too many details of how the rest of the system works.
getting caught up in too many details of how the rest of the system works.
-
This example shows a simple timer onscreen that shows how many hours,
+
This example shows a simple elapsed-time clock on screen that shows how many hours,
minutes, seconds and 60<SUP>th</SUP>s of a second (tics) have elapsed  
minutes, seconds and 60<SUP>th</SUP>s of a second (tics) have elapsed  
since the program started.  It uses an interrupt handler to keep track of  
since the program started.  It uses an interrupt handler to keep track of  
Line 693: Line 693:
Finally, all that's left is setting up the interrupt handler to point to
Finally, all that's left is setting up the interrupt handler to point to
-
the timer code we wrote above.  Recall that our routine is called  
+
the time counting code we wrote above.  Recall that our routine is called  
<CODE>MYISR</CODE>.  The following code sets that up:
<CODE>MYISR</CODE>.  The following code sets that up:
Line 711: Line 711:
and  
and  
<CODE>[http://sdk-1600.spatula-city.org/examples/library/prnum16.asm prnum16.asm]</CODE> from SDK-1600.  Download these files and put them in a directory.
<CODE>[http://sdk-1600.spatula-city.org/examples/library/prnum16.asm prnum16.asm]</CODE> from SDK-1600.  Download these files and put them in a directory.
-
Then put the following source code in a new file named <CODE>timer.asm</CODE>
+
Then put the following source code in a new file named <CODE>elapsed.asm</CODE>
in the same directory.  This source code contains all of the snippets from
in the same directory.  This source code contains all of the snippets from
above, along with a ROM header to make it work.  The added portions are in  
above, along with a ROM header to make it work.  The added portions are in  
Line 744: Line 744:
  ;----------------------------------------------------------------------------
  ;----------------------------------------------------------------------------
   
   
-
  TITLE  STRING  $107, "Timer Demo", 0  ; Title string and date (2007)
+
  TITLE  STRING  $107, "Elapsed Time Demo", 0  ; Title string and date (2007)
   
   
  MAIN    PROC
  MAIN    PROC
Line 846: Line 846:
To assemble the code above, type:
To assemble the code above, type:
-
     as1600 -o timer -l timer.lst timer.asm
+
     as1600 -o elapsed -l elapsed.lst elapsed.asm
And that's it.
And that's it.
Line 855: Line 855:
the main program loop.
the main program loop.
<br/><br/>
<br/><br/>
-
In the background, the interrupt handler updates the time every timer tic.
+
In the background, the interrupt handler updates the elapsed time with every interrupt from the STIC.
This causes the <CODE>@@wait_time</CODE> loop in the main program to exit,
This causes the <CODE>@@wait_time</CODE> loop in the main program to exit,
and the rest of the code to update the displayed time. Wash, rinse, repeat.
and the rest of the code to update the displayed time. Wash, rinse, repeat.
<br/><br/>
<br/><br/>
-
== Further Things to Contemplate About the Timer Demo ==
+
== Further Things to Contemplate About the Elapsed Time Demo ==
This timer is a pretty simple piece of code.  It's also specific to NTSC
This timer is a pretty simple piece of code.  It's also specific to NTSC

Revision as of 20:49, 21 November 2007

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox