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(): 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_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
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
(Critical Sections)
m (Protected "Introducing Interrupts" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite)))
 
Line 79: Line 79:
         when we return from the interrupt.
         when we return from the interrupt.
     </LI>
     </LI>
-
     <LI>The CPU then jumps to location $1004.  The hardware determines
+
     <LI>The CPU then jumps to location $1004.  The hardware sets
         this address, and there's no easy way to change this address on
         this address, and there's no easy way to change this address on
         the Intellivision.
         the Intellivision.
Line 438: Line 438:
interrupts and read the time with interrupts off.  This copy of the time  
interrupts and read the time with interrupts off.  This copy of the time  
is guaranteed to be consistent no matter what.  For the purposes of this
is guaranteed to be consistent no matter what.  For the purposes of this
-
example, we'll read the time and put a copy of it on the stack with [[PSHR]].
+
example, we'll read the time and put a copy of it on the stack with <CODE>[[PSHR]]</CODE>.
         [[DIS]]                    ; Disable ints (begin critical section)
         [[DIS]]                    ; Disable ints (begin critical section)
Line 465: Line 465:
To display the time, we'll use the [http://sdk-1600.spatula-city.org/ SDK-1600]
To display the time, we'll use the [http://sdk-1600.spatula-city.org/ SDK-1600]
routine <CODE>PRNUM16</CODE>, found  
routine <CODE>PRNUM16</CODE>, found  
-
[http://sdk-1600.spatula-city.org/examples/library/prnum16.asm here].  The
+
[[prnum16.asm|here]].  The
<CODE>PRNUM16.z</CODE> routine prints the number in R0 in a fixed width field,
<CODE>PRNUM16.z</CODE> routine prints the number in R0 in a fixed width field,
complete with leading zeroes.  It prints the value to the screen, starting at  
complete with leading zeroes.  It prints the value to the screen, starting at  
Line 676: Line 676:
with 0 as well.  It seems like we should be able to combine the two acts.
with 0 as well.  It seems like we should be able to combine the two acts.
<br/><br/>
<br/><br/>
-
It turns out we can.  Addresses $01F0 - $01FF refer to the [[Programmable
+
It turns out we can.  Addresses $01F0 - $01FF refer to the [[Programmable Sound Generator]] (aka. PSG).  We can safely write 0s to all of its locations.
-
Sound Generator]] (aka. PSG).  We can safely write 0s to all of its locations.
+
In fact, this is the preferred way to initialize the PSG when its state is
In fact, this is the preferred way to initialize the PSG when its state is
otherwise unknown.  Thus, we can combine the <CODE>FILLZERO</CODE> and  
otherwise unknown.  Thus, we can combine the <CODE>FILLZERO</CODE> and  
Line 691: Line 690:
us already.)
us already.)
<br/><br/>
<br/><br/>
 +
=== Setting up the Interrupt Handler ===
=== Setting up the Interrupt Handler ===
Line 709: Line 709:
and INCLUDE directives for all of the library functions.  This particular
and INCLUDE directives for all of the library functions.  This particular
example needs  
example needs  
-
<CODE>[http://sdk-1600.spatula-city.org/examples/library/fillmem.asm fillmem.asm]</CODE>  
+
<CODE>[[fillmem.asm]]</CODE>  
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>[[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>elapsed.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
Line 947: Line 947:
for the number of tics specified in the word after the <CODE>[[CALL]]</CODE>.
for the number of tics specified in the word after the <CODE>[[CALL]]</CODE>.
(See  
(See  
-
[http://intelliwiki.kylesblog.com/index.php/Introducing_the_Instruction_Set_Part_3#Passing_Arguments_via_Return_Address the branch tutorial] for an explanation of this technique.)  The second entry
+
[[Introducing_the_Instruction_Set_Part_3#Passing_Arguments_via_Return_Address|the branch tutorial]] for an explanation of this technique.)  The second entry
point expects the number of tics to wait to be in R0.
point expects the number of tics to wait to be in R0.
Line 976: Line 976:
         [[JR]]      R5                  ; return
         [[JR]]      R5                  ; return
         ENDP
         ENDP
-
 
== The Rest ==
== The Rest ==
Line 983: Line 982:
as we did previously in the [[Hello World Tutorial]].  We'll also use the  
as we did previously in the [[Hello World Tutorial]].  We'll also use the  
an infinite loop.  We'll reuse [http://sdk-1600.spatula-city.org/ SDK-1600's]
an infinite loop.  We'll reuse [http://sdk-1600.spatula-city.org/ SDK-1600's]
-
[http://sdk-1600.spatula-city.org/examples/library/print.asm PRINT] and [http://sdk-1600.spatula-city.org/examples/library/fillmem.asm CLRSCR]
+
[[print.asm|PRINT]] and [[fillmem.asm|CLRSCR]]
functions.  This results in the following code:
functions.  This results in the following code:
Line 1,027: Line 1,026:
The source listing below puts all the fragments above into a complete program.
The source listing below puts all the fragments above into a complete program.
Mainly, this just adds the cartridge header, the <CODE>INCLUDE</CODE>
Mainly, this just adds the cartridge header, the <CODE>INCLUDE</CODE>
-
directives to include  
+
directives to include [[print.asm]] and [[fillmem.asm]]
-
[http://sdk-1600.spatula-city.org/examples/library/print.asm print.asm] and
+
-
[http://sdk-1600.spatula-city.org/examples/library/fillmem.asm fillmem.asm]
+
from SDK-1600, and assigns <CODE>WTIMER</CODE> a location in 8-bit memory.   
from SDK-1600, and assigns <CODE>WTIMER</CODE> a location in 8-bit memory.   
The bold portions are the new portions.
The bold portions are the new portions.

Latest revision as of 08:42, 4 December 2010

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox