
PAGE 01    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

002                         ORG   :E1F5
003                 *
004                 *
005                 *
006                 *********************
007                 * RUN basiccmd EDIT *
008                 *********************
009                 *
010                 * The editbuffer is set up by moving the program
011                 * to the end of the free RAM space. All memory
012                 * between heapstart and textbegin is used as
013                 * editbuffer.
014                 * On break + space: The edited area is deleted
015                 * from the textbuffer and the program is moved
016                 * to just after the end of the edited text by
017                 * changing the heapsize.
018                 * EFSW is set for input from editbuffer.
019                 *
020 E1F5 CD65E2     REDIT   CALL  :E265     Init. edit buffer
021 E1F8 CD9FE1             CALL  :E19F     List into edit buffer
022 E1FB AF         RED05   XRA   A
023 E1FC 323101             STA   :0131     Set output to screen
024 E1FF 32B902             STA   :02B9     Enable complete keyb.scan
025 E202 CD75DD             CALL  :DD75     0 on end of buffer
026 E205 210000             LXI   H,:0000
027 E208 22B400             SHLD  :00B4     Clear tab table pntr
028 E20B EF                 RST   5         Init screen editor
029 E20C 2A                 DATA  :2A
030 E20D CDBED6     RED10   CALL  :D6BE     Get char from keyboard
031 E210 DA1BE2             JC    :E21B     If break pressed
032 E213 CA0DE2             JZ    :E20D     Wait for inputs
033 E216 EF                 RST   5         Obey character
034 E217 2D                 DATA  :2D
035 E218 C30DE2             JMP   :E20D     Get next input
036                             
037                 * If Break pressed:
038                             
039 E21B 3E0C       RED19   MVI   A,:0C
040 E21D EF                 RST   5         Clear screen
041 E21E 03                 DATA  :03
042 E21F CDBED6     RED20   CALL  :D6BE     Get char from keyboard
043 E222 DA4DE2             JC    :E24D     If again Break
044                             
045                 * Break followed by any character:
046                             
047 E225 CA1FE2             JZ    :E21F     Wait for a char typed in
048 E228 3E02               MVI   A,:02
049 E22A 323501             STA   :0135     EFSW: input from buffer
050 E22D 2A1B01             LHLD  :011B     Get end listed area
051 E230 EB                 XCHG            in DE
052 E231 2A1901             LHLD  :0119     Get start listed area
053 E234 CD1ADE             CALL  :DE1A     Calc. length listed area
054 E237 00                 NOP 
055 E238 CDD1C9             CALL  :C9D1     Delete edited area in txtbuf
056 E23B 2A9B02             LHLD  :029B     Get start HEAP
057 E23E EB                 XCHG            in DE
058 E23F 2AA400             LHLD  :00A4     Get input pntr editbuf
059 E242 CD1ADE             CALL  :DE1A     Calc length used edit area
060 E245 23                 INX   H
061 E246 23                 INX   H
062 E247 EB                 XCHG            DE: length edit area +2
063 E248 CD95D1             CALL  :D195     Program to end of editbuf

PAGE 02    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

064 E24B B7                 ORA   A         No special conditions
065 E24C C9                 RET 
066                             
067                 * Break followed by 2nd break:
068                             
069 E24D CDCADE     RED30   CALL  :DECA     Restore original Heap +
070                                         program buffers
071 E250 B7                 ORA   A         No special conditions
072 E251 C9                 RET 
073 E252 00                 NOP 
074                 *
075                 ******************************
076                 * RUN basiccmd EDIT <linenr> *
077                 ******************************
078                 *
079 E253 CD65E2     REDI1   CALL  :E265     Init edit buffer
080 E256 CDAAE1             CALL  :E1AA     List one line
081 E259 C3FBE1             JMP   :E1FB     Into Run edit
082                 *
083                 *****************************
084                 * RUN basiccmd EDIT <range> *
085                 *****************************
086                 *
087 E25C CD65E2     REDI2   CALL  :E265     Init edit buffer
088 E25F CDB6E1             CALL  :E1B6     List part of program
089 E262 C3FBE1             JMP   :E1FB     Into Run edit
090                 *
091                 ****************************
092                 * INITIALISE SCREEN EDITOR *
093                 ****************************
094                 *
095                 * Sets up a mode 0 screen, clears all variables
096                 * and arrays. Moves Basic program to top of free
097                 * memory, initialises edit pointers.
098                 *
099                 * Exit: BC preserved. AFDEHL corrupted.
100                 *
101 E265 3EFF       REDIN   MVI   A,:FF
102 E267 EF                 RST   5         Change screen to mode 0
103 E268 18                 DATA  :18
104 E269 CD6DD8             CALL  :D86D     Run 'OUT OF MEMORY' error
105                                         if insufficient space. Else
106                                         empty HEAP + variables
107 E26C CD51EB             CALL  :EB51     Calc free RAM space
108 E26F EB                 XCHG            in DE
109 E270 2A9D02             LHLD  :029D     Get HEAPsize
110 E273 19                 DAD   D
111 E274 EB                 XCHG            Total 'free' RAM in DE
112 E275 CD95D1             CALL  :D195     Program to end free RAM
113 E278 2A9F02             LHLD  :029F     Get startaddr. textbuf
114 E27B 2B                 DCX   H
115 E27C 2B                 DCX   H         Minus 2
116 E27D 22A600             SHLD  :00A6     Store end available space
117 E280 2A9B02             LHLD  :029B     Get startaddr HEAP
118 E283 23                 INX   H
119 E284 23                 INX   H         Plus 2
120 E285 22A200             SHLD  :00A2     Store startaddr. editbuf
121 E288 22A400             SHLD  :00A4     Set input pntr editbuf
122 E28B 213101             LXI   H,:0131
123 E28E 3602               MVI   M,:02     Set output to editbuf
124 E290 C9                 RET 
125                             

PAGE 03    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

126                 **************************
127                 * INPUT FROM EDIT BUFFER *
128                 **************************
129                 *
130                 * Entry: A=0, CY=0.
131                 *
132 E291 F5         IFBNL   PUSH  PSW
133 E292 2AA200             LHLD  :00A2     Get startaddr. editbuf
134 E295 223201             SHLD  :0132     Store it in EFEPT
135 E298 7E         IFB10   MOV   A,M       Get char from editbuf
136 E299 B7                 ORA   A         Char is 0?
137 E29A CAAAE2             JZ    :E2AA     Then editbuf empty
138 E29D 23                 INX   H
139 E29E FE0D               CPI   :0D       Car.ret?
140 E2A0 C298E2             JNZ   :E298     Get next char if not
141                             
142                 * If char is car.ret:
143                             
144 E2A3 22A200             SHLD  :00A2     Update startaddr. editbuf
145 E2A6 0E00               MVI   C,:00     1st pos on line
146 E2A8 F1                 POP   PSW       No special action
147 E2A9 C9                 RET 
148                             
149                 * If buffer empty:
150                             
151 E2AA 323501     IFB20   STA   :0135     Set input from keyboard
152 E2AD CDCADE             CALL  :DECA     Organise HEAP + buffers
153 E2B0 F1                 POP   PSW       special action
154 E2B1 37                 STC             CY=1
155 E2B2 C9                 RET 
156                 *
157                 **********************
158                 * RUN basiccmd PRINT *
159                 **********************
160                 *
161                 * Entry: BC: Position in textbuffer.
162                 *
163 E2B3 0A         RPRINT  LDAX  B         Get length
164 E2B4 03                 INX   B
165 E2B5 57                 MOV   D,A       Count of expr in D
166 E2B6 B7                 ORA   A
167 E2B7 CAF7E2             JZ    :E2F7     Jump if only car.ret
168 E2BA D5         RPR10   PUSH  D         Save nr of expressions
169 E2BB 0A                 LDAX  B         Get expr type
170 E2BC 03                 INX   B
171 E2BD FE20               CPI   :20
172 E2BF CAD2E2             JZ    :E2D2     Jump if string
173                             
174                 * If INT/FPT number:
175                             
176 E2C2 FE00               CPI   :00
177 E2C4 CD08E8             CALL  :E808     Eval expr. Result in MACC
178 E2C7 F5                 PUSH  PSW       Save flags on expr.type
179 E2C8 C453DB             CNZ   :DB53     If INT: print INT number
180 E2CB F1                 POP   PSW
181 E2CC CC59DB             CZ    :DB59     If FPT: print FPT number
182 E2CF C3E3E2             JMP   :E2E3
183                             
184                 * If string:
185                             
186 E2D2 CD91E7     RPR40   CALL  :E791     Evaluate string expr
187 E2D5 E5                 PUSH  H

PAGE 04    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

188 E2D6 EF                 RST   5         Ask cursor pos and size
189 E2D7 0C                 DATA  :0C       char screen
190 E2D8 7B                 MOV   A,E       X-size of screen in A
191 E2D9 95                 SUB   L         Minus X-coord cursor pos
192 E2DA 3C                 INR   A         +1
193 E2DB E1                 POP   H
194 E2DC BE                 CMP   M         (not used further: off
195 E2DD 00                 NOP             screen printing possible)
196 E2DE 00                 NOP             (should be: CC :DD5E)
197 E2DF 00                 NOP 
198 E2E0 CD32DB             CALL  :DB32     Print string pntd by HL
199                 *
200 E2E3 0A         RPR50   LDAX  B         Get byte after string
201 E2E4 03                 INX   B
202 E2E5 FEFF               CPI   :FF       End marker?
203 E2E7 CAF6E2             JZ    :E2F6     Then quit with car.ret
204 E2EA FE3B               CPI   :3B       ';' ?
205 E2EC C40DDB             CNZ   :DB0D     Cursor to next column if
206                                         not (must be ',')
207 E2EF D1                 POP   D         Get nr of expr to print
208 E2F0 15                 DCR   D         Update expr count
209 E2F1 C2BAE2             JNZ   :E2BA     Loop if more expressions
210 E2F4 B7                 ORA   A         No special action
211 E2F5 C9                 RET 
212                             
213                 * If end of print statement:
214                             
215 E2F6 D1         RPR70   POP   D
216 E2F7 CD5EDD     RPR80   CALL  :DD5E     Print 'CR'
217 E2FA B7                 ORA   A
218 E2FB C9                 RET 
219                 *
220                 **********************
221                 * RUN basiccmd INPUT *
222                 **********************
223                 *
224                 * Runs an input statement with a prompt ('?').
225                 * RINPQ:  Input with a string.
226                 * RINPUT: Input without a string.
227                 *
228 E2FC CD91E7     RINPQ   CALL  :E791     Evaluate stringexpression
229 E2FF CD32DB             CALL  :DB32     Print string pntd by HL
230 E302 210200     RINPUT  LXI   H,:0002
231 E305 39                 DAD   SP
232 E306 CD47E4             CALL  :E447     Update ERSSF, print '?' and
233                                         ask for inputs
234 E309 D464E3             CNC   :E364     If no break: store inputs
235 E30C F5                 PUSH  PSW       Save last input
236 E30D AF                 XRA   A
237 E30E 321701             STA   :0117     Reset flag running inputs
238 E311 F1                 POP   PSW       Get last input
239 E312 DA20E3             JC    :E320     Abort if break
240 E315 1C                 INR   E
241 E316 CA1EE3             JZ    :E31E     Quit if correct nr of inputs
242 E319 CDFFDA             CALL  :DAFF     Else: Print
243 E31C 08D2               DBL   :D208     'SOME INPUT IGNORED'
244 E31E B7         RIP10   ORA   A         No special action
245 E31F C9                 RET 
246                             
247                 * If suspended:
248                             
249 E320 3E02       RIP20   MVI   A,:02     Code 'cmd broken in'

PAGE 05    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

250 E322 C9                 RET 
251                 *
252                 *********************
253                 * RUN basiccmd READ *
254                 *********************
255                 *
256 E323 3E01       RREAD   MVI   A,:01
257 E325 323501             STA   :0135     Set input from string
258 E328 3A2301             LDA   :0123     Get offset next char to en-
259 E32B 5F                 MOV   E,A       code and store it in E
260 E32C 2A9102             LHLD  :0291     Get DATAQ addr
261 E32F 7E                 MOV   A,M       Get length of string
262 E330 323401             STA   :0134     Store it in EFECT
263 E333 23                 INX   H         Pnts to 1st char
264 E334 223201             SHLD  :0132     Addr 1st char in EFEPT
265 E337 CD64E3             CALL  :E364     Store data
266 E33A 7B                 MOV   A,E       Get offset next char
267 E33B 322301             STA   :0123     Store it
268 E33E 2A3201             LHLD  :0132     Get EFEPT
269 E341 2B                 DCX   H         Pnts to next dataline
270 E342 229102             SHLD  :0291     Store it in DATAQ
271 E345 AF                 XRA   A
272 E346 323501             STA   :0135     Set input from keyboard
273 E349 C9                 RET 
274                 *
275                 *********************
276                 * DATA - (not used) *
277                 *********************
278                 *
279 E34A 21         L0E351  DATA  :21
280 E34B 01                 DATA  :01
281 E34C 60                 DATA  :60
282 E34D 69                 DATA  :69
283 E34E 22                 DATA  :22
284 E34F 1F                 DATA  :1F
285                 *
286                 *****************
287                 * RESTART INPUT *
288                 *****************
289                 *
290                 * Error handling if running inputs.
291                 *
292 E350 2A1D01     INPRS   LHLD  :011D     Get saved stackpntr
293 E353 F9                 SPHL            Reload stackpntr
294 E354 2A0201             LHLD  :0102     Get start current command
295 E357 44                 MOV   B,H       ) Store it in BC
296 E358 4D                 MOV   C,L       )
297 E359 CDFFDA             CALL  :DAFF     Print 'RETYPE LINE'
298 E35C 93DB               DBL   :DB93
299 E35E C37FC8             JMP   :C87F     Re-execute input statement
300                 *
301                 **********************************
302                 * STORE DATA IN CORRECT LOCATION *
303                 **********************************
304                 *
305                 * Entry L0E56 not used.
306                 *
307                 * Stores data read from datastatements or gotten
308                 * from an input line on the correct location.
309                 *
310                 * Entry: E : Offset next character to encode
311                 *            (#0291).

PAGE 06    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

312                 *        HL: Startaddress data line.
313                 *
314 E361 CD36E4     L0E56   CALL  :E436     (not used)
315                 *
316 E364 0A         RRDIP   LDAX  B         Get nr of data reqd
317 E365 03                 INX   B
318 E366 57                 MOV   D,A       Into D
319 E367 15         RRI10   DCR   D
320 E368 FAC1E3             JM    :E3C1     Jump if ready
321 E36B 1C         RRI20   INR   E         Offset nex char
322 E36C CAA8E3             JZ    :E3A8     Jump if at end of line
323 E36F 1D                 DCR   E
324 E370 CD63E9     RRI30   CALL  :E963     Get varptr in HL
325 E373 C5                 PUSH  B
326 E374 D5                 PUSH  D
327 E375 4B                 MOV   C,E       Offset in C
328 E376 E5                 PUSH  H         Save varptr
329 E377 213E01             LXI   H,:013E   Startaddr EBUF
330 E37A E5                 PUSH  H         Save it on stack
331 E37B E630               ANI   :30
332 E37D CF                 RST   1         Encode a constant
333 E37E 06                 DATA  :06
334 E37F 59                 MOV   E,C       Offset in E
335 E380 C1                 POP   B
336 E381 E1                 POP   H         Get varptr
337 E382 FE20               CPI   :20       String type ?
338 E384 7B                 MOV   A,E       Offset in A
339 E385 CAA2E3             JZ    :E3A2     Jump if string type
340 E388 CDB4E4             CALL  :E4B4     Perform LET (INT/FPT)
341                             
342                 * Check separator/terminator:
343                             
344 E38B 4F         RRI40   MOV   C,A       Offset in C
345 E38C CDD2DD             CALL  :DDD2     Get char from line, neglect
346                                         tab and space
347 E38F 0C                 INR   C         Offset +1
348 E390 FE2C               CPI   :2C       ',' ?
349 E392 CA99E3             JZ    :E399
350 E395 FE0D               CPI   :0D       CR ?
351 E397 0EFF               MVI   C,:FF     Dummy offset for end of
352                                         line
353 E399 D1         RRI50   POP   D
354 E39A 59                 MOV   E,C       Offset in E
355 E39B C1                 POP   B
356 E39C C2C3E3             JNZ   :E3C3     Error if char not ',' or
357                                         car.ret
358 E39F C367E3             JMP   :E367     Read next data line
359                             
360                 * If string type:
361                             
362 E3A2 CDB8E4     RRI60   CALL  :E4B8     Perform LET (STR)
363 E3A5 C38BE3             JMP   :E38B     Check terminator/separator
364                             
365                 * If end of line reached ('CR'):
366                             
367 E3A8 3A1701     RRI70   LDA   :0117     Get flag for running inputs
368 E3AB B7                 ORA   A
369 E3AC CABBE3             JZ    :E3BB     Quit if not running inputs
370 E3AF CD55DD             CALL  :DD55     Cursor to begin next line
371 E3B2 CDD0E3             CALL  :E3D0     Print '?', read input line
372 E3B5 DAC2E3             JC    :E3C2     Abort if break pressed
373 E3B8 C370E3             JMP   :E370     Cont reading

PAGE 07    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

374                             
375                 * If whole line read:
376                             
377 E3BB CDDCE3     RRI80   CALL  :E3DC     Find next dataline in txtbuf
378 E3BE C370E3             JMP   :E370     Cont reading
379                             
380                 * If reading done:
381                             
382 E3C1 B7         RRI90   ORA   A         No special action
383 E3C2 C9         RRI99   RET 
384                             
385                 * If error:
386                             
387 E3C3 2A3201     RRISN   LHLD  :0132     Get EFEPT
388 E3C6 11FCFF             LXI   D,:FFFC
389 E3C9 19                 DAD   D         EFEPT-4
390 E3CA 220001             SHLD  :0100     Store start current line
391 E3CD C30BDA             JMP   :DA0B     Run 'SYNTAX ERROR'
392                 *
393                 **************************
394                 * PREPARE GETTING INPUTS *
395                 **************************
396                 *
397                 * Continuation of OE447.
398                 * Prints a prompt ('?') on the screen and gets a
399                 * textline from input.
400                 *
401 E3D0 D5         INPGT   PUSH  D
402 E3D1 EF                 RST   5         Ask cursor pos. and size
403 E3D2 0C                 DATA  :0C       char. screen
404 E3D3 D1                 POP   D
405 E3D4 3E3F               MVI   A,:3F
406 E3D6 CDA0C6             CALL  :C6A0     Print '?'; input a textline
407 E3D9 5D                 MOV   E,L
408 E3DA 1C                 INR   E         E pnts after last char of
409                                         input
410 E3DB C9                 RET 
411                 *
412                 ************************************
413                 * FIND NEXT DATALINE IN TEXTBUFFER *
414                 ************************************
415                 *
416 E3DC F5         DATAF   PUSH  PSW
417 E3DD D5                 PUSH  D
418 E3DE E5                 PUSH  H
419 E3DF 2A2401             LHLD  :0124     Get addr current dataline
420 E3E2 7E         DTF10   MOV   A,M       Get length data string
421 E3E3 B7                 ORA   A
422 E3E4 3E02               MVI   A,:02
423 E3E6 CAF5D9             JZ    :D9F5     Run error 'OUT OF DATA' if
424                                         no data available
425 E3E9 54                 MOV   D,H       ) Addr dataline in DE
426 E3EA 5D                 MOV   E,L       )
427 E3EB CD39DE             CALL  :DE39     Calc end dataline
428 E3EE 222401             SHLD  :0124     Store it in DATAP
429 E3F1 EB                 XCHG            End in DE, start in HL
430 E3F2 23                 INX   H
431 E3F3 23                 INX   H
432 E3F4 23                 INX   H         Pnts to token
433 E3F5 7E                 MOV   A,M       Get token
434 E3F6 FEA2               CPI   :A2       Is it DATA?
435 E3F8 EB                 XCHG

PAGE 08    DAI FIRMWARE 0E1F5-0E400  V1.0  Rev.1

436 E3F9 C2E2E3             JNZ   :E3E2     Check next textline if not
437 E3FC EB                 XCHG
438 E3FD C336E4             JMP   :E436     Continu
439                 *
440 E400 FF                 DATA  :FF
441                 *
442                 *
443                 *
444 E401                    END 
 
***************************
* S Y M B O L   T A B L E *
***************************
 
DATAF  E3DC   DTF10  E3E2   IFB10  E298   IFB20  E2AA   
IFBNL  E291   INPGT  E3D0   INPRS  E350   L0E351 E34A   
L0E56  E361   RED05  E1FB   RED10  E20D   RED19  E21B   
RED20  E21F   RED30  E24D   REDI1  E253   REDI2  E25C   
REDIN  E265   REDIT  E1F5   RINPQ  E2FC   RINPUT E302   
RIP10  E31E   RIP20  E320   RPR10  E2BA   RPR40  E2D2   
RPR50  E2E3   RPR70  E2F6   RPR80  E2F7   RPRINT E2B3   
RRDIP  E364   RREAD  E323   RRI10  E367   RRI20  E36B   
RRI30  E370   RRI40  E38B   RRI50  E399   RRI60  E3A2   
RRI70  E3A8   RRI80  E3BB   RRI90  E3C1   RRI99  E3C2   
RRISN  E3C3
