PAGE 01 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 002 ORG :DEB5 003 * 004 * 005 * 006 * =================================== 007 *** BASIC EXECUTION / RUN-TIME MODULE *** 008 * =================================== 009 * 010 * Generally, BC is used as entry pointer to the 011 * textbuffer. 012 * 013 ******************** 014 * RUN basiccmd NEW * 015 ******************** 016 * 017 * Sets up heap, empty textbuffer and symboltable, 018 * sets pointers of textbuffer and symboltable 019 * correctly. Old buffer contents is not destroyed, 020 * (except 4 locations), but not useable. 021 * Valid as direct command only. 022 * 023 * Exit: A=1, CY=1. 024 * 025 DEB5 00 RNEW NOP 026 DEB6 00 NOP 027 DEB7 00 NOP 028 DEB8 2A9B02 LHLD :029B Get startaddr heap 029 DEBB 229F02 SHLD :029F Set start textbuf=start heap 030 DEBE 3600 MVI M,:00 Store 00 in 1st addr. 031 DEC0 23 INX H 032 DEC1 22A102 SHLD :02A1 Set start symtab 033 DEC4 3600 MVI M,:00 00 in 1st addr. 034 DEC6 23 INX H 035 DEC7 22A302 SHLD :02A3 Set end symtab 036 037 * Entry from scratch/edit: 038 039 DECA 2A9D02 HRINIT LHLD :029D Get heap size 040 DECD EB XCHG in DE 041 DECE CD95D1 CALL :D195 Init heap to all available 042 DED1 3E01 MVI A,:01 Code for 'buffer crunched' 043 DED3 37 STC 044 DED4 C9 RET 045 * 046 ********************* 047 * RUN basiccmd CONT * 048 ********************* 049 * 050 * Resets step flag, decr. CONFL (error if it was 051 * 0), restores FRAME from stack, restores stack- 052 * pointer and continues program execution. 053 * Valid as direct command only. 054 * 055 DED5 AF RCONT XRA A 056 DED6 321601 RCN10 STA :0116 Reset step flag 057 DED9 212601 LXI H,:0126 Get pntr suspended program 058 DEDC 35 DCR M Update it 059 DEDD 3E19 MVI A,:19 060 DEDF FAF5D9 JM :D9F5 Evt. run error 'CAN'T CONT' 061 DEE2 2A2701 LHLD :0127 Get current base stack level 062 DEE5 EB XCHG in DE 063 DEE6 211500 LXI H,:0015 FRAME length PAGE 02 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 064 DEE9 19 DAD D Top of FRAME in stack 065 DEEA E5 PUSH H Save it 066 DEEB 010001 LXI B,:0100 Addr SYSBOT 067 DEEE CD4FDE CALL :DE4F Load FRAME from stack 068 DEF1 E1 POP H Get addr FRAME top in stack 069 DEF2 222701 SHLD :0127 Update current base stack 070 level 071 DEF5 F9 SPHL Update stackpointer 072 DEF6 2A0201 LHLD :0102 Get start current command 073 DEF9 44 MOV B,H 074 DEFA 4D MOV C,L Store it in BC 075 DEFB C37FC8 JMP :C87F Run BASIC line 076 * 077 ********************* 078 * RUN basiccmd STEP * 079 ********************* 080 * 081 DEFE 3EFF RSTEP MVI A,:FF Init value STEP flag 082 DF00 C3D6DE JMP :DED6 Set STEP flag and continu 083 * 084 ********************* 085 * RUN basiccmd STOP * 086 ********************* 087 * 088 * Entry: No conditions. 089 * Exit: A=03, CY=1. HL points after string. 090 * 091 DF03 CDFFDA RSTOP CALL :DAFF Print 'STOPPED' 092 DF06 C9DB DBL :DBC9 093 DF08 3E03 MVI A,:03 Code for 'susp. execution' 094 DF0A 37 STC 095 DF0B C9 RET 096 * 097 ******************** 098 * RUN basiccmd END * 099 ******************** 100 * 101 * Entry: No conditions. 102 * Exit: A=01, CY=1. HL points after string. 103 * 104 DF0C CDFFDA REND CALL :DAFF Print 'END PROGRAM' 105 DF0F CFDB DBL :DBCF 106 DF11 3E01 MVI A,:01 Code for 'stop execution' 107 DF13 37 STC 108 DF14 C9 RET 109 * 110 ******************* 111 * RUN basiccmd IF * 112 ******************* 113 * 114 * Used for IF .. GOTO and for 115 * IF .. THEN . 116 * 117 *RIFG 118 DF15 CD63E7 RIFTL CALL :E763 (0) Run logical expression 119 DF18 3C INR A 120 DF19 CA63DF JZ :DF63 Run GOTO if condition true 121 122 * If condition false: 123 124 DF1C 03 INX B 125 DF1D 03 INX B Skip linenr PAGE 03 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 126 DF1E B7 ORA A No special action 127 DF1F C9 RET 128 * 129 *************************************** 130 * RUN basiccmd IF .. THEN * 131 *************************************** 132 * 133 DF20 CD63E7 RIFTC CALL :E763 (0) Run logical expression 134 DF23 3C INR A 135 DF24 C28FE1 JNZ :E18F (0) Ignore rest if false 136 137 * If condition true: 138 139 DF27 03 INX B Skip length line 140 DF28 B7 ORA A No special action 141 DF29 C9 RET Execute rest of line 142 * 143 ****************** 144 * basiccmd GOSUB * 145 ****************** 146 * 147 * Saves current program state on the interpreter 148 * stack and branches to a named line. The running 149 * FOR loop (if any) is saved in order to avoid 150 * problems if any unpaired NEXT is encountered. 151 * The stackpointer at the subroutine-entry is held 152 * to enable breaking out of a FOR-NEXT loop. 153 * 154 DF2A CDEDE6 RGOSUB CALL :E6ED (0) Get linenr and find it 155 156 * Entry from ON - GOSUB: 157 158 DF2D D1 RGS10 POP D Kill return addr 159 DF2E 221901 SHLD :0119 Save new PC 160 DF31 CD3CE1 CALL :E13C (0) Save FOR loop contents 161 DF34 C5 PUSH B Save program position 162 DF35 2A1901 LHLD :0119 Get new PC 163 DF38 44 MOV B,H ) Is new text position 164 DF39 4D MOV C,L ) 165 DF3A 2A1301 LHLD :0113 Get stack level last GOSUB 166 DF3D E5 PUSH H Save evt link to previous 167 subroutine entry 168 DF3E 210000 LXI H,:0000 169 DF41 220401 SHLD :0104 No running loop 170 DF44 39 DAD SP SP in HL 171 DF45 221301 SHLD :0113 SP in STKGOS for return 172 173 * Entry on return: 174 175 DF48 B7 RGS20 ORA A No special action 176 DF49 C38FC8 JMP :C88F Into Basic monitor 177 * 178 *********************** 179 * RUN basiccmd RETURN * 180 *********************** 181 * 182 * Reverses the effect of a previous 'GOSUB'. 183 * 184 DF4C D1 RRET POP D Kill returnaddr 185 DF4D 2A1301 LHLD :0113 Get stack level last GOSUB 186 DF50 7C MOV A,H 187 DF51 B5 ORA L 0 if no active call PAGE 04 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 188 DF52 3E01 MVI A,:01 189 DF54 CAF5D9 JZ :D9F5 Then run error 'RETURN 190 WITHOUT GOSUB' 191 DF57 F9 SPHL Else: re-instate old stack 192 DF58 E1 POP H 193 DF59 221301 SHLD :0113 Link back to previous 194 GOSUB 195 DF5C C1 POP B Restore text pntr 196 DF5D CD67E1 CALL :E167 (0) Pop FRAME 197 DF60 C348DF JMP :DF48 Back to Basic monitor 198 * 199 ********************* 200 * RUN basiccmd GOTO * 201 ********************* 202 * 203 * Simply transfers control to a named line. 204 * 205 * Entry from IF - GOTO: 206 * 207 DF63 CDEDE6 RGOTO CALL :E6ED (0) Get linenr and find it 208 209 * Entry from ON - GOTO: 210 211 DF66 44 RGT10 MOV B,H ) Set textpointer to line 212 DF67 4D MOV C,L ) 213 DF68 B7 ORA A No special action 214 DF69 C9 RET 215 * 216 *************************** 217 * RUN basiccmd ON .. GOTO * 218 *************************** 219 * 220 DF6A CD78DF RONGT CALL :DF78 Process command 221 DF6D DA66DF JC :DF66 Use GOTO if OK 222 DF70 C9 RET If outside list 223 * 224 **************************** 225 * RUN basiccmd ON .. GOSUB * 226 **************************** 227 * 228 DF71 CD78DF RONGS CALL :DF78 Process command 229 DF74 DA2DDF JC :DF2D Use GOSUB if OK 230 DF77 C9 RET If outside list 231 * 232 *********************** 233 * COMMON 'ON ..' CODE * 234 *********************** 235 * 236 * Exit: CY=1: OK. 237 * CY=0: Outside list. 238 * 239 DF78 CD1DE7 RONFN CALL :E71D ) (0) Get index of number 240 DF7B 5F MOV E,A ) in list in E 241 DF7C 0A LDAX B Get nr of linenrs in list 242 DF7D 03 INX B 243 DF7E 6F MOV L,A 244 DF7F 2600 MVI H,:00 245 DF81 29 DAD H 246 DF82 09 DAD B Pointer after list 247 DF83 E5 PUSH H Save pointer 248 DF84 1D DCR E 249 DF85 1C INR E PAGE 05 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 250 DF86 CA9BDF JZ :DF9B Index of 0: outside list 251 DF89 BB CMP E 252 DF8A DA9BDF JC :DF9B If index too large 253 DF8D 1600 MVI D,:00 254 DF8F 1B DCX D 255 DF90 EB XCHG 256 DF91 29 DAD H 257 DF92 09 DAD B Pntr to reqd linenr 258 DF93 44 MOV B,H ) in BC 259 DF94 4D MOV C,L ) 260 DF95 CDEDE6 CALL :E6ED (0) Find reqd line 261 DF98 C1 POP B 262 DF99 37 STC CY=1: OK 263 DF9A C9 RET 264 265 * If outside list: 266 267 DF9B C1 ROF10 POP B 268 DF9C B7 ROF11 ORA A CY=0: outside list 269 DF9D C9 RET 270 * 271 ******************** 272 * RUN basiccmd RUN * 273 ******************** 274 * 275 * No linenumber is given. 276 * 277 DF9E 210000 RRUN LXI H,:0000 278 DFA1 221501 SHLD :0115 Reset trace/step flag 279 DFA4 2A9F02 LHLD :029F Get start textbuf 280 DFA7 44 RRN10 MOV B,H ) 281 DFA8 4D MOV C,L ) Store it in BC 282 DFA9 CD01E4 CALL :E401 (0) Run RESTORE; Set data 283 pntr to start program 284 DFAC 3100F9 LXI SP,:F900 Reset stackpointer 285 DFAF AF XRA A 286 DFB0 322601 STA :0126 No suspended program 287 DFB3 CD23CB CALL :CB23 Empty HEAP + symtab 288 DFB6 B7 ORA A No special action 289 DFB7 C38FC8 JMP :C88F Run program 290 * 291 ***************************** 292 * RUN basiccmd RUN * 293 ***************************** 294 * 295 * After RUN, a line number is given. 296 * 297 DFBA CDEDE6 RRUNN CALL :E6ED (0) Read linenr and find 298 it in textbuf 299 DFBD C3A7DF JMP :DFA7 Process RUN 300 * 301 ********************* 302 * RUN basiccmd POKE * 303 ********************* 304 * 305 DFC0 CDF8E6 RPOKE CALL :E6F8 (0) Get addr in HL 306 307 * Entry for other modules: 308 309 DFC3 CD1DE7 RPEN CALL :E71D (0) Get argument in A 310 DFC6 77 MOV M,A Store it 311 DFC7 B7 ORA A No special action PAGE 06 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 312 DFC8 C9 RET 313 * 314 ******************** 315 * RUN basiccmd OUT * 316 ******************** 317 * 318 DFC9 CD1DE7 ROUT CALL :E71D (0) Get portnr in A 319 DFCC 57 MOV D,A and in D 320 DFCD CD1DE7 CALL :E71D (0) Get data in A 321 DFD0 5F MOV E,A and in E 322 DFD1 B7 ORA A 323 DFD2 C3C8D8 JMP :D8C8 Output to DCE-bus 324 * 325 ********************* 326 * RUN basiccmd WAIT * 327 ********************* 328 * 329 * WAIT I,J,K reads the status of Real World port 330 * I, EXOR's it with K and AND's it with J until 331 * a result equal to J is obtained. 332 * 333 DFD5 CD1DE7 RWAIT CALL :E71D (0) Get portnr 334 DFD8 57 MOV D,A in D 335 DFD9 CD1DE7 CALL :E71D (0) Get bits needed high 336 DFDC 67 MOV H,A in H 337 DFDD 0A LDAX B Get next byte from text 338 DFDE 03 INX B 339 DFDF D6FF SUI :FF Check if only 2 arguments 340 DFE1 00 NOP 341 DFE2 C4DACE CNZ :CEDA If 3 arg: Get XOR mask 342 DFE5 6F MOV L,A in L 343 DFE6 CDE0D8 RWT20 CALL :D8E0 Input from DCE-bus 344 DFE9 7B MOV A,E into A 345 DFEA AD XRA L XOR with mask 346 DFEB A4 ANA H AND with bits needed high 347 DFEC BC CMP H Correct value reached? 348 DFED C8 RZ Then abort 349 DFEE CDA5D6 CALL :D6A5 Check keyb for new inputs 350 DFF1 D2E6DF JNC :DFE6 Next DCE-input if no Break 351 352 * If suspended: 353 354 DFF4 C312E0 JMP :E012 (0) Quit: 'cmd broken in' 355 * 356 ************************* 357 * RUN basiccmd WAIT MEM * 358 ************************* 359 * 360 * As WAIT, but with I is a memory location. 361 * 362 DFF7 CDF8E6 RWTEM CALL :E6F8 (0) Get memory addr in HL 363 DFFA CD1DE7 CALL :E71D (0) Get bit mask 364 DFFD 57 MOV D,A in D 365 DFFE 0A LDAX B Get next byte from text 366 DFFF 03 INX B 367 E000 D6FF SUI :FF Check if only 2 arguments 368 E002 00 NOP 369 E003 C4DACE CNZ :CEDA If 3 arg: Get XOR mask 370 E006 5F MOV E,A in E 371 E007 7B RWM20 MOV A,E XOR mask in A 372 E008 AE XRA M XOR with memory 373 E009 A2 ANA D AND with bit mask PAGE 07 DAI FIRMWARE DEB5-0E015 V1.0 Rev.1 374 E00A BA CMP D Correct value reached? 375 E00B C8 RZ Then abort 376 E00C CDA5D6 CALL :D6A5 Check keyb for inputs 377 E00F D207E0 JNC :E007 Cont if no Break pressed 378 379 * If suspended: 380 381 E012 3E02 RWT30 MVI A,:02 Code 'command broken in' 382 E014 37 STC 383 E015 C9 RET 384 * 385 * 386 * 390 E016 END *************************** * S Y M B O L T A B L E * *************************** HRINIT DECA RCN10 DED6 RCONT DED5 REND DF0C RGOSUB DF2A RGOTO DF63 RGS10 DF2D RGS20 DF48 RGT10 DF66 RIFG DF15 RIFTC DF20 RIFTL DF15 RNEW DEB5 ROF10 DF9B ROF11 DF9C RONFN DF78 RONGS DF71 RONGT DF6A ROUT DFC9 RPEN DFC3 RPOKE DFC0 RRET DF4C RRN10 DFA7 RRUN DF9E RRUNN DFBA RSTEP DEFE RSTOP DF03 RWAIT DFD5 RWM20 E007 RWT20 DFE6 RWT30 E012 RWTEM DFF7