@@ -77,12 +77,7 @@ T4RUPT XCH ARUPT
7777
7878# Initialize the stack pointer to be 0.
7979# This is the offset from the starting stack position.
80- START CAF STACK-EB # Switch to stack memory bank.
81- TS EB
82- CA NUM0
83- TS STACKPTR
84- CAF MAIN-EB # Switch to main memory bank.
85- TS EB
80+ START TCR STACKINI
8681 # Clear the DSKY.
8782 TCR FLSHDSP
8883 # Initialize the random number generator with seed
@@ -100,7 +95,10 @@ $Blockly.agc
10095AGCEND CA A
10196 TCF AGCEND
10297
98+ # Place all the framework code into bank 00.
99+ SETLOC 10000
103100# Code modules.
101+ $Stack.agc
104102$Boolean.agc
105103$List.agc
106104$Math.agc
@@ -156,53 +154,11 @@ SLEEPBZF CA SLEEPING
156154SLEEPEND RETURN
157155
158156
159- # Push the contents of the 'A' register onto the stack.
160- PUSH TS STACKTMP
161- CAF STACK-EB # Switch to stack memory bank.
162- TS EB
163- CAE STACKTMP
164- INCR STACKPTR
165- INDEX STACKPTR
166- TS STACK
167- CAF MAIN-EB # Switch back to main memory bank.
168- TS EB
169- RETURN
170-
171-
172- # POP: Pop the last value on the stack into the 'A' register.
173- POP CAF STACK-EB # Switch to stack memory bank.
174- TS EB
175- INDEX STACKPTR
176- CAE STACK
177- TS STACKTMP
178- EXTEND
179- DIM STACKPTR
180- CAF MAIN-EB # Switch back to main memory bank.
181- TS EB
182- CAE STACKTMP
183- RETURN
184-
185-
186- # PEEK: Read the last value on the stack into the 'A' register.
187- PEEK CAF STACK-EB # Switch to stack memory bank.
188- TS EB
189- INDEX STACKPTR
190- CAE STACK
191- TS STACKTMP
192- CAF MAIN-EB # Switch back to main memory bank.
193- TS EB
194- CAE STACKTMP
195- RETURN
196-
197157
198158# Variables in memory.
199159SLEEPING = 061 # Flag indicating if we are busy-sleeping.
200160INPUTING = 062 # Waiting for a DSKY key press.
201- QPOP = 063 # Temporary spot for Q.
202- STACKTMP = 064 # Temp value for stack operations.
203161
204- STACKPTR = 1400 # Stack pointer, starts at 0.
205- STACK = 1400 # Start address of stack (minus one).
206162
207163# Constants.
20816410MS OCT 37777 # 2^14-1 is 10 ms to T4/T5 overflow.
@@ -222,7 +178,6 @@ NUM16 DEC 16
222178NUM9601 DEC 9601 # Random number seed.
223179
224180MAIN-EB OCT 1400 # E3 is the default user erasable memory bank.
225- STACK-EB OCT 2000 # E4 erasable memory bank used by stack.
226181
227182# System Address Locations
228183A = 00
0 commit comments