Rev Author Line No. Line
4985 kaklik 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title> words/intx.asm </title>
6 <meta name="keywords" content="amforth programming language Forth ATmega ATMEL">
7 <meta name="description" content="amforth - laguage Forth for ATMEL ATmega">
8 <!-- AUTOINCLUDE START "Page/Head.en.ihtml" DO NOT REMOVE -->
9 <link rel="StyleSheet" href="../../../../Web/CSS/MLAB.css" type="text/css" title="MLAB Basic Style">
10 <link rel="StyleSheet" href="../../../../Web/CSS/MLAB_Print.css" type="text/css" media="print">
11 <link rel="shortcut icon" type="image/x-icon" href="../../../../Web/PIC/MLAB.ico">
12 <script type="text/javascript" src="../../../../Web/JS/MLAB_Menu.js"></script>
13 <!-- AUTOINCLUDE END -->
14 </head>
15  
16 <body lang="en">
17  
18 <!-- AUTOINCLUDE START "Page/Header.en.ihtml" DO NOT REMOVE -->
19 <!-- ============== HEADER ============== -->
20 <div class="Header">
21 <script type="text/javascript">
22 <!--
23 SetRelativePath("../../../../");
24 DrawHeader();
25 // -->
26 </script>
27 <noscript>
28 <p><b> JavaScript is required for including of the header </b></p>
29 </noscript>
30 </div>
31 <!-- AUTOINCLUDE END -->
32  
33 <!-- AUTOINCLUDE START "Page/Menu.en.ihtml" DO NOT REMOVE -->
34 <!-- ============== MENU ============== -->
35 <div class="Menu">
36 <script type="text/javascript">
37 <!--
38 SetRelativePath("../../../../");
39 DrawMenu();
40 // -->
41 </script>
42 <noscript>
43 <p><b> JavaScript is required for including of the menu </b><p>
44 </noscript>
45 </div>
46 <!-- AUTOINCLUDE END -->
47  
48 <!-- ============== TEXT ============== -->
49 <div class="Text">
50  
51 <h1> words/intx.asm </h1>
52  
53 <p>
54 <input type=button onClick="history.back()" value="Back">
55 <input type=button onClick="history.forward()" value="Forward">
56 <a href="../WordList.en.html">Jump to Vocabulary</a>
57 </p>
58  
59 <pre>
60  
61 .set intcur = heap ; current interrupt
62 .set heap = heap + 1
63 .set intvec = heap ; forth interrupt vector (contain the XT)
64 .set heap = heap + INTVECTORS * CELLSIZE
65  
66 ; interrupt routine gets called (again) by rcall! This gives the
67 ; address of the int-vector on the stack.
68 isr:
69 st -Y, r0
70 in r0, SREG
71 st -Y, r0
72 pop r0
73 pop r0 ; = intnum * intvectorsize + 1 (address following the rcall)
74 dec r0
75 .if intvecsize == 1 ;
76 lsl r0
77 .endif
78 sts intcur, r0
79 ld r0, Y+
80 out SREG, r0
81 ld r0, Y+
82 set ; set the interrupt flag for the inner interpreter
83 reti ; returns the interrupt, the rcall stack frame is removed!
84  
85 ; ( xt i -- ) Interrupt
86 ; R( -- )
87 ; stores XT as interrupt vector i
88 VE_INTSTORE:
89 .db $04, &quot;int!&quot;,0
90 .dw VE_HEAD
91 .set VE_HEAD = VE_INTSTORE
92 XT_INTSTORE:
93 .dw DO_COLON
94 PFA_INTSTORE:
95 .dw XT_2STAR
96 .dw XT_DOLITERAL
97 .dw intvec
98 .dw XT_PLUS
99 .dw XT_STORE
100 .dw XT_EXIT
101  
102 ; ( i -- xt ) Interrupt
103 ; R( -- )
104 ; fetches XT from interrupt vector i
105 VE_INTFETCH:
106 .db $04, &quot;int@&quot;,0
107 .dw VE_HEAD
108 .set VE_HEAD = VE_INTFETCH
109 XT_INTFETCH:
110 .dw DO_COLON
111 PFA_INTFETCH:
112 .dw XT_2STAR
113 .dw XT_DOLITERAL
114 .dw intvec
115 .dw XT_PLUS
116 .dw XT_FETCH
117 .dw XT_EXIT
118  
119 ; ( -- n ) Interrupt
120 ; R( -- )
121 ; number of interrupt vectors (0 based)
122 VE_NUMINT:
123 .db $04, &quot;#int&quot;,0
124 .dw VE_HEAD
125 .set VE_HEAD = VE_NUMINT
126 XT_NUMINT:
127 .dw PFA_DOVARIABLE
128 PFA_NUMINT:
129 .dw INTVECTORS
130  
131  
132 ; ( -- sreg ) Interrupt
133 ; R( -- )
134 ; turns off all interrupts and leaves SREG in TOS
135 VE_INTOFF:
136 .db $04, &quot;/int&quot;,0
137 .dw VE_HEAD
138 .set VE_HEAD = VE_INTOFF
139 XT_INTOFF:
140 .dw PFA_INTOFF
141 PFA_INTOFF:
142 savetos
143 clr tosh
144 in tosl, SREG
145 cli
146 jmp_ DO_NEXT
147  
148 ; ( -- ) Interrupt
149 ; R( -- )
150 ; turns on all interrupts
151 VE_INTON:
152 .db $03, &quot;int&quot;
153 .dw VE_HEAD
154 .set VE_HEAD = VE_INTON
155 XT_INTON:
156 .dw PFA_INTON
157 PFA_INTON:
158 sei
159 jmp_ DO_NEXT
160  
161 ; ( sreg -- ) Interrupt
162 ; R( -- )
163 ; restores SREG from TOS (
164 ;VE_INTRESTORE:
165 ; .db $0B, &quot;int_restore&quot;
166 ; .dw VE_HEAD
167 ; .set VE_HEAD = VE_INTRESTORE
168 XT_INTRESTORE:
169 .dw PFA_INTRESTORE
170 PFA_INTRESTORE:
171 out SREG, tosl
172 loadtos
173 jmp_ DO_NEXT
174 </pre>
175  
176 <p>
177 <input type=button onClick="history.back()" value="Back">
178 <input type=button onClick="history.forward()" value="Forward">
179 <a href="../WordList.en.html">Jump to Vocabulary</a>
180 </p>
181  
182 </div>
183  
184 <!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE -->
185 <!-- ============== FOOTER ============== -->
186 <div class="Footer">
187 <script type="text/javascript">
188 <!--
189 SetRelativePath("../../../../");
190 DrawFooter();
191 // -->
192 </script>
193 <noscript>
194 <p><b> JavaScript is required for including of the footer </b></p>
195 </noscript>
196 </div>
197 <!-- AUTOINCLUDE END -->
198  
199 </body>
200 </html>