2019-11-14 07:28:16 +11:00
|
|
|
; *** Variables ***
|
|
|
|
; Value of `SP` when basic was first invoked. This is where SP is going back to
|
|
|
|
; on restarts.
|
|
|
|
.equ BAS_INITSP BAS_RAMSTART
|
2019-11-21 07:44:13 +11:00
|
|
|
; Pointer to next line to run. If nonzero, it means that the next line is
|
|
|
|
; the first of the list. This is used by GOTO to indicate where to jump next.
|
|
|
|
; Important note: this is **not** a line number, it's a pointer to a line index
|
|
|
|
; in buffer. If it's not zero, its a valid pointer.
|
|
|
|
.equ BAS_PNEXTLN @+2
|
2019-11-25 02:24:15 +11:00
|
|
|
; Points to a routine to call when a command isn't found in the "core" cmd
|
|
|
|
; table. This gives the opportunity to glue code to configure extra commands.
|
|
|
|
.equ BAS_FINDHOOK @+2
|
2019-11-21 12:58:26 +11:00
|
|
|
.equ BAS_RAMEND @+2
|
2019-11-14 07:28:16 +11:00
|
|
|
|
|
|
|
; *** Code ***
|
2019-11-25 02:24:15 +11:00
|
|
|
basInit:
|
2019-11-14 07:28:16 +11:00
|
|
|
ld (BAS_INITSP), sp
|
2019-11-21 07:10:00 +11:00
|
|
|
call varInit
|
2019-11-20 07:14:04 +11:00
|
|
|
call bufInit
|
2019-11-14 07:28:16 +11:00
|
|
|
xor a
|
2019-11-21 12:58:26 +11:00
|
|
|
ld (BAS_PNEXTLN), a
|
|
|
|
ld (BAS_PNEXTLN+1), a
|
2019-11-25 02:24:15 +11:00
|
|
|
ld hl, unsetZ
|
|
|
|
ld (BAS_FINDHOOK), hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
basStart:
|
2019-11-14 07:28:16 +11:00
|
|
|
ld hl, .welcome
|
|
|
|
call printstr
|
|
|
|
call printcrlf
|
2019-11-21 02:49:23 +11:00
|
|
|
jr basLoop
|
2019-11-14 07:28:16 +11:00
|
|
|
|
|
|
|
.welcome:
|
2019-12-01 12:50:34 +11:00
|
|
|
.db "Collapse OS", 0
|
2019-11-14 07:28:16 +11:00
|
|
|
|
2019-11-21 02:49:23 +11:00
|
|
|
basLoop:
|
2019-11-14 07:28:16 +11:00
|
|
|
ld hl, .sPrompt
|
|
|
|
call printstr
|
|
|
|
call stdioReadLine
|
2019-11-21 02:49:23 +11:00
|
|
|
call printcrlf
|
2019-12-31 02:13:55 +11:00
|
|
|
call parseDecimalC
|
2019-11-14 07:28:16 +11:00
|
|
|
jr z, .number
|
2019-11-21 02:49:23 +11:00
|
|
|
ld de, basCmds1
|
2019-12-13 02:51:13 +11:00
|
|
|
call basCallCmds
|
2019-11-21 02:49:23 +11:00
|
|
|
jr z, basLoop
|
|
|
|
; Error
|
|
|
|
call basERR
|
|
|
|
jr basLoop
|
2019-11-14 07:28:16 +11:00
|
|
|
.number:
|
2019-11-21 12:58:26 +11:00
|
|
|
call rdSep
|
2019-11-20 07:14:04 +11:00
|
|
|
call bufAdd
|
|
|
|
jp nz, basERR
|
2019-11-21 02:49:23 +11:00
|
|
|
jr basLoop
|
2019-11-14 07:28:16 +11:00
|
|
|
.sPrompt:
|
|
|
|
.db "> ", 0
|
|
|
|
|
2019-11-25 02:24:15 +11:00
|
|
|
; Tries to find command specified in (DE) (must be null-terminated) in cmd
|
|
|
|
; table in (HL). If found, sets IX to point to the associated routine. If
|
|
|
|
; not found, calls BAS_FINDHOOK so that we look through extra commands
|
|
|
|
; configured by glue code.
|
|
|
|
; Destroys HL.
|
|
|
|
; Z is set if found, unset otherwise.
|
|
|
|
basFindCmd:
|
2019-11-14 07:28:16 +11:00
|
|
|
.loop:
|
2019-11-24 12:35:21 +11:00
|
|
|
call strcmp
|
2019-12-01 13:36:34 +11:00
|
|
|
call strskip
|
|
|
|
inc hl ; point to routine
|
|
|
|
jr z, .found ; Z from strcmp
|
|
|
|
inc hl \ inc hl ; skip routine
|
2019-11-14 07:28:16 +11:00
|
|
|
ld a, (hl)
|
2019-12-01 13:36:34 +11:00
|
|
|
inc a ; was it 0xff?
|
|
|
|
jr nz, .loop ; no
|
|
|
|
dec a ; unset Z
|
|
|
|
ret
|
2019-11-14 07:28:16 +11:00
|
|
|
.found:
|
|
|
|
call intoHL
|
2019-11-19 05:40:23 +11:00
|
|
|
push hl \ pop ix
|
2019-11-25 02:24:15 +11:00
|
|
|
ret
|
|
|
|
|
|
|
|
; Call command in (HL) after having looked for it in cmd table in (DE).
|
|
|
|
; If found, jump to it. If not found, try (BAS_FINDHOOK). If still not found,
|
|
|
|
; unset Z. We expect commands to set Z on success. Therefore, when calling
|
|
|
|
; basCallCmd results in NZ, we're not sure where the error come from, but
|
|
|
|
; well...
|
|
|
|
basCallCmd:
|
|
|
|
; let's see if it's a variable assignment.
|
|
|
|
call varTryAssign
|
|
|
|
ret z ; Done!
|
|
|
|
push de ; --> lvl 1.
|
|
|
|
ld de, SCRATCHPAD
|
|
|
|
call rdWord
|
|
|
|
; cmdname to find in (DE)
|
|
|
|
; How lucky, we have a legitimate use of "ex (sp), hl"! We have the
|
|
|
|
; cmd table in the stack, which we want in HL and we have the rest of
|
|
|
|
; the cmdline in (HL), which we want in the stack!
|
|
|
|
ex (sp), hl
|
|
|
|
call basFindCmd
|
|
|
|
jr z, .skip
|
|
|
|
; not found, try BAS_FINDHOOK
|
|
|
|
ld ix, (BAS_FINDHOOK)
|
|
|
|
call callIX
|
|
|
|
.skip:
|
|
|
|
; regardless of the result, we need to balance the stack.
|
2019-11-24 12:35:21 +11:00
|
|
|
; Bring back rest of the command string from the stack
|
|
|
|
pop hl ; <-- lvl 1
|
2019-11-25 02:24:15 +11:00
|
|
|
ret nz
|
|
|
|
; cmd found, skip whitespace and then jump!
|
2019-11-21 12:58:26 +11:00
|
|
|
call rdSep
|
2019-11-19 05:40:23 +11:00
|
|
|
jp (ix)
|
2019-11-14 07:28:16 +11:00
|
|
|
|
2019-12-13 02:51:13 +11:00
|
|
|
; Call a series of ':'-separated commands in (HL) using cmd table in (DE).
|
|
|
|
; Stop processing as soon as one command unsets Z.
|
|
|
|
basCallCmds:
|
|
|
|
; Commands are not guaranteed at all to preserve HL and DE, so we
|
|
|
|
; preserve them ourselves here.
|
|
|
|
push hl ; --> lvl 1
|
|
|
|
push de ; --> lvl 2
|
|
|
|
call basCallCmd
|
|
|
|
pop de ; <-- lvl 2
|
|
|
|
pop hl ; <-- lvl 1
|
|
|
|
ret nz
|
|
|
|
call toEnd
|
|
|
|
ret z ; no more cmds
|
|
|
|
; we met a ':', we have more cmds
|
|
|
|
inc hl
|
|
|
|
call basCallCmds
|
|
|
|
; move the the end of the string so that we don't run cmds following a
|
|
|
|
; ':' twice.
|
|
|
|
call strskip
|
|
|
|
ret
|
|
|
|
|
2019-11-19 05:40:23 +11:00
|
|
|
basERR:
|
|
|
|
ld hl, .sErr
|
2019-11-21 12:58:26 +11:00
|
|
|
call printstr
|
|
|
|
jp printcrlf
|
2019-11-19 05:40:23 +11:00
|
|
|
.sErr:
|
|
|
|
.db "ERR", 0
|
|
|
|
|
2019-11-14 07:28:16 +11:00
|
|
|
; *** Commands ***
|
2019-11-19 05:40:23 +11:00
|
|
|
; A command receives its argument through (HL), which is already placed to
|
|
|
|
; either:
|
|
|
|
; 1 - the end of the string if the command has no arg.
|
|
|
|
; 2 - the beginning of the arg, with whitespace properly skipped.
|
2019-11-21 02:49:23 +11:00
|
|
|
;
|
|
|
|
; Commands are expected to set Z on success.
|
2019-11-20 07:14:04 +11:00
|
|
|
basLIST:
|
|
|
|
call bufFirst
|
2019-11-25 06:26:32 +11:00
|
|
|
jr nz, .end
|
2019-11-20 07:14:04 +11:00
|
|
|
.loop:
|
|
|
|
ld e, (ix)
|
|
|
|
ld d, (ix+1)
|
2019-11-21 12:58:26 +11:00
|
|
|
ld hl, SCRATCHPAD
|
2019-11-20 07:14:04 +11:00
|
|
|
call fmtDecimal
|
|
|
|
call printstr
|
|
|
|
ld a, ' '
|
|
|
|
call stdioPutC
|
2019-11-20 12:43:01 +11:00
|
|
|
call bufStr
|
2019-11-20 07:14:04 +11:00
|
|
|
call printstr
|
|
|
|
call printcrlf
|
|
|
|
call bufNext
|
|
|
|
jr z, .loop
|
2019-11-25 06:26:32 +11:00
|
|
|
.end:
|
2019-11-21 02:49:23 +11:00
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
basRUN:
|
2019-11-21 07:44:13 +11:00
|
|
|
call .maybeGOTO
|
|
|
|
jr nz, .loop ; IX already set
|
2019-11-21 02:49:23 +11:00
|
|
|
call bufFirst
|
|
|
|
ret nz
|
|
|
|
.loop:
|
|
|
|
call bufStr
|
|
|
|
ld de, basCmds2
|
|
|
|
push ix ; --> lvl 1
|
2019-12-13 02:51:13 +11:00
|
|
|
call basCallCmds
|
2019-11-21 02:49:23 +11:00
|
|
|
pop ix ; <-- lvl 1
|
|
|
|
jp nz, .err
|
2019-11-21 07:44:13 +11:00
|
|
|
call .maybeGOTO
|
|
|
|
jr nz, .loop ; IX already set
|
2019-11-21 02:49:23 +11:00
|
|
|
call bufNext
|
|
|
|
jr z, .loop
|
|
|
|
cp a ; ensure Z
|
2019-11-20 07:14:04 +11:00
|
|
|
ret
|
2019-11-21 02:49:23 +11:00
|
|
|
.err:
|
|
|
|
; Print line number, then return NZ (which will print ERR)
|
|
|
|
ld e, (ix)
|
|
|
|
ld d, (ix+1)
|
2019-11-21 12:58:26 +11:00
|
|
|
ld hl, SCRATCHPAD
|
2019-11-21 02:49:23 +11:00
|
|
|
call fmtDecimal
|
|
|
|
call printstr
|
|
|
|
ld a, ' '
|
|
|
|
call stdioPutC
|
|
|
|
jp unsetZ
|
2019-11-20 07:14:04 +11:00
|
|
|
|
2019-11-21 07:44:13 +11:00
|
|
|
; This returns the opposite Z result as the one we usually see: Z is set if
|
|
|
|
; we **don't** goto, unset if we do. If we do, IX is properly set.
|
|
|
|
.maybeGOTO:
|
|
|
|
ld de, (BAS_PNEXTLN)
|
|
|
|
ld a, d
|
|
|
|
or e
|
|
|
|
ret z
|
|
|
|
; we goto
|
|
|
|
push de \ pop ix
|
|
|
|
; we need to reset our goto marker
|
|
|
|
ld de, 0
|
|
|
|
ld (BAS_PNEXTLN), de
|
|
|
|
ret
|
2019-11-20 07:14:04 +11:00
|
|
|
|
2019-11-19 05:40:23 +11:00
|
|
|
basPRINT:
|
2019-11-22 11:56:51 +11:00
|
|
|
; Do we have arguments at all? if not, it's not an error, just print
|
|
|
|
; crlf
|
|
|
|
ld a, (hl)
|
|
|
|
or a
|
|
|
|
jr z, .end
|
|
|
|
; Is our arg a string literal?
|
|
|
|
call spitQuoted
|
|
|
|
jr z, .chkAnother ; string printed, skip to chkAnother
|
2019-11-21 12:58:26 +11:00
|
|
|
ld de, SCRATCHPAD
|
|
|
|
call rdWord
|
|
|
|
push hl ; --> lvl 1
|
|
|
|
ex de, hl
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-11-22 11:56:51 +11:00
|
|
|
jr nz, .parseError
|
2019-11-21 12:58:26 +11:00
|
|
|
ld hl, SCRATCHPAD
|
2019-11-24 06:56:23 +11:00
|
|
|
call fmtDecimalS
|
2019-11-21 12:58:26 +11:00
|
|
|
call printstr
|
|
|
|
pop hl ; <-- lvl 1
|
2019-11-22 11:56:51 +11:00
|
|
|
.chkAnother:
|
2019-11-21 12:58:26 +11:00
|
|
|
; Do we have another arg?
|
|
|
|
call rdSep
|
|
|
|
jr z, .another
|
|
|
|
; no, we can stop here
|
2019-11-22 11:56:51 +11:00
|
|
|
.end:
|
2019-11-21 02:49:23 +11:00
|
|
|
cp a ; ensure Z
|
2019-11-21 12:58:26 +11:00
|
|
|
jp printcrlf
|
|
|
|
.another:
|
|
|
|
; Before we jump to basPRINT, let's print a space
|
|
|
|
ld a, ' '
|
|
|
|
call stdioPutC
|
|
|
|
jr basPRINT
|
2019-11-22 11:56:51 +11:00
|
|
|
.parseError:
|
|
|
|
; unwind the stack before returning
|
|
|
|
pop hl ; <-- lvl 1
|
|
|
|
ret
|
|
|
|
|
2019-11-19 05:40:23 +11:00
|
|
|
|
2019-11-21 07:44:13 +11:00
|
|
|
basGOTO:
|
2019-11-21 12:58:26 +11:00
|
|
|
ld de, SCRATCHPAD
|
|
|
|
call rdWord
|
|
|
|
ex de, hl
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-11-21 07:44:13 +11:00
|
|
|
ret nz
|
|
|
|
call bufFind
|
|
|
|
jr nz, .notFound
|
|
|
|
push ix \ pop de
|
|
|
|
; Z already set
|
|
|
|
jr .end
|
|
|
|
.notFound:
|
|
|
|
ld de, 0
|
|
|
|
; Z already unset
|
|
|
|
.end:
|
|
|
|
ld (BAS_PNEXTLN), de
|
|
|
|
ret
|
|
|
|
|
2019-12-13 03:17:10 +11:00
|
|
|
; evaluate truth condition at (HL) and set A to its value
|
|
|
|
; Z for success (but not truth!)
|
|
|
|
_basEvalCond:
|
2019-11-22 08:06:14 +11:00
|
|
|
push hl ; --> lvl 1. original arg
|
|
|
|
ld de, SCRATCHPAD
|
|
|
|
call rdWord
|
|
|
|
ex de, hl
|
|
|
|
call parseTruth
|
|
|
|
pop hl ; <-- lvl 1. restore
|
2019-12-13 03:17:10 +11:00
|
|
|
ret
|
|
|
|
|
|
|
|
basIF:
|
|
|
|
call _basEvalCond
|
|
|
|
ret nz ; error
|
2019-11-22 08:06:14 +11:00
|
|
|
or a
|
|
|
|
ret z
|
|
|
|
; expr is true, execute next
|
|
|
|
; (HL) back to beginning of args, skip to next arg
|
2019-12-13 02:51:13 +11:00
|
|
|
call toSepOrEnd
|
2019-11-22 08:06:14 +11:00
|
|
|
call rdSep
|
2019-12-13 02:51:13 +11:00
|
|
|
ret nz
|
2019-11-22 08:06:14 +11:00
|
|
|
ld de, basCmds2
|
2019-12-13 02:51:13 +11:00
|
|
|
jp basCallCmds
|
2019-11-22 08:06:14 +11:00
|
|
|
|
2019-12-13 03:17:10 +11:00
|
|
|
basWHILE:
|
|
|
|
push hl ; --> lvl 1
|
|
|
|
call _basEvalCond
|
|
|
|
jr nz, .stop ; error
|
|
|
|
or a
|
|
|
|
jr z, .stop
|
|
|
|
ret z
|
|
|
|
; expr is true, execute next
|
|
|
|
; (HL) back to beginning of args, skip to next arg
|
|
|
|
call toSepOrEnd
|
|
|
|
call rdSep
|
|
|
|
ret nz
|
|
|
|
ld de, basCmds2
|
|
|
|
call basCallCmds
|
|
|
|
pop hl ; <-- lvl 1
|
|
|
|
jr basWHILE
|
|
|
|
.stop:
|
|
|
|
pop hl ; <-- lvl 1
|
|
|
|
ret
|
|
|
|
|
2019-11-22 12:17:55 +11:00
|
|
|
basINPUT:
|
|
|
|
; If our first arg is a string literal, spit it
|
|
|
|
call spitQuoted
|
|
|
|
call rdSep
|
|
|
|
call stdioReadLine
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:59:55 +11:00
|
|
|
ld (VAR_TBL), de
|
2019-11-22 12:17:55 +11:00
|
|
|
call printcrlf
|
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
2019-11-24 08:07:10 +11:00
|
|
|
basPEEK:
|
|
|
|
call basDEEK
|
|
|
|
ret nz
|
2019-11-25 06:55:50 +11:00
|
|
|
; set MSB to 0
|
|
|
|
xor a ; sets Z
|
|
|
|
ld (VAR_TBL+1), a
|
2019-11-24 08:07:10 +11:00
|
|
|
ret
|
|
|
|
|
|
|
|
basPOKE:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
; peek address in IX. Save it for later
|
|
|
|
push ix ; --> lvl 1
|
|
|
|
call rdSep
|
|
|
|
call rdExpr
|
|
|
|
push ix \ pop hl
|
|
|
|
pop ix ; <-- lvl 1
|
|
|
|
ret nz
|
|
|
|
; Poke!
|
|
|
|
ld (ix), l
|
|
|
|
ret
|
|
|
|
|
|
|
|
basDEEK:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
; peek address in IX. Let's peek and put result in DE
|
|
|
|
ld e, (ix)
|
|
|
|
ld d, (ix+1)
|
2019-11-25 06:55:50 +11:00
|
|
|
ld (VAR_TBL), de
|
2019-11-24 08:07:10 +11:00
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
|
|
|
basDOKE:
|
|
|
|
call basPOKE
|
|
|
|
ld (ix+1), h
|
|
|
|
ret
|
|
|
|
|
2019-11-24 12:35:21 +11:00
|
|
|
basOUT:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
; out address in IX. Save it for later
|
|
|
|
push ix ; --> lvl 1
|
|
|
|
call rdSep
|
|
|
|
call rdExpr
|
|
|
|
push ix \ pop hl
|
|
|
|
pop bc ; <-- lvl 1
|
|
|
|
ret nz
|
|
|
|
; Out!
|
|
|
|
out (c), l
|
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
|
|
|
basIN:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
push ix \ pop bc
|
|
|
|
ld d, 0
|
|
|
|
in e, (c)
|
2019-11-25 06:55:50 +11:00
|
|
|
ld (VAR_TBL), de
|
|
|
|
; Z set from rdExpr
|
2019-11-24 12:35:21 +11:00
|
|
|
ret
|
|
|
|
|
2019-12-01 13:13:44 +11:00
|
|
|
basGETC:
|
|
|
|
call stdioGetC
|
|
|
|
ld (VAR_TBL), a
|
|
|
|
xor a
|
|
|
|
ld (VAR_TBL+1), a
|
|
|
|
ret
|
|
|
|
|
|
|
|
basPUTC:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
push ix \ pop hl
|
|
|
|
ld a, l
|
|
|
|
call stdioPutC
|
|
|
|
xor a ; set Z
|
|
|
|
ret
|
|
|
|
|
2019-12-10 06:15:43 +11:00
|
|
|
basPUTH:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
push ix \ pop hl
|
|
|
|
ld a, l
|
|
|
|
call printHex
|
|
|
|
xor a ; set Z
|
|
|
|
ret
|
|
|
|
|
2019-11-24 09:07:14 +11:00
|
|
|
basSLEEP:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
push ix \ pop hl
|
|
|
|
.loop:
|
|
|
|
ld a, h ; 4T
|
|
|
|
or l ; 4T
|
|
|
|
ret z ; 5T
|
|
|
|
dec hl ; 6T
|
|
|
|
jr .loop ; 12T
|
|
|
|
|
2019-11-25 07:39:36 +11:00
|
|
|
basADDR:
|
|
|
|
call rdWord
|
|
|
|
ex de, hl
|
|
|
|
ld de, .specialTbl
|
|
|
|
.loop:
|
|
|
|
ld a, (de)
|
|
|
|
or a
|
|
|
|
jr z, .notSpecial
|
|
|
|
cp (hl)
|
|
|
|
jr z, .found
|
|
|
|
inc de \ inc de \ inc de
|
|
|
|
jr .loop
|
|
|
|
.notSpecial:
|
|
|
|
; not found, find cmd. needle in (HL)
|
|
|
|
ex de, hl ; now in (DE)
|
|
|
|
ld hl, basCmds1
|
|
|
|
call basFindCmd
|
|
|
|
jr z, .foundCmd
|
|
|
|
; no core command? let's try the find hook.
|
|
|
|
ld ix, (BAS_FINDHOOK)
|
|
|
|
call callIX
|
|
|
|
ret nz
|
|
|
|
.foundCmd:
|
|
|
|
; We have routine addr in IX
|
|
|
|
ld (VAR_TBL), ix
|
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
.found:
|
|
|
|
; found special thing. Put in "A".
|
|
|
|
inc de
|
|
|
|
call intoDE
|
|
|
|
ld (VAR_TBL), de
|
|
|
|
ret ; Z set from .found jump.
|
|
|
|
|
|
|
|
.specialTbl:
|
|
|
|
.db '$'
|
|
|
|
.dw SCRATCHPAD
|
|
|
|
.db 0
|
|
|
|
|
2019-11-25 13:07:03 +11:00
|
|
|
basUSR:
|
|
|
|
call rdExpr
|
|
|
|
ret nz
|
|
|
|
push ix \ pop iy
|
|
|
|
; We have our address to call. Now, let's set up our registers.
|
|
|
|
; HL comes from variable H. H's index is 7*2.
|
|
|
|
ld hl, (VAR_TBL+14)
|
|
|
|
; DE comes from variable D. D's index is 3*2
|
|
|
|
ld de, (VAR_TBL+6)
|
|
|
|
; BC comes from variable B. B's index is 1*2
|
|
|
|
ld bc, (VAR_TBL+2)
|
|
|
|
; IX comes from variable X. X's index is 23*2
|
|
|
|
ld ix, (VAR_TBL+46)
|
|
|
|
; and finally, A
|
|
|
|
ld a, (VAR_TBL)
|
|
|
|
call callIY
|
2019-11-26 15:16:15 +11:00
|
|
|
basR2Var: ; Just send reg to vars. Used in basPgmHook
|
2019-11-25 13:07:03 +11:00
|
|
|
; Same dance, opposite way
|
|
|
|
ld (VAR_TBL), a
|
|
|
|
ld (VAR_TBL+46), ix
|
|
|
|
ld (VAR_TBL+2), bc
|
|
|
|
ld (VAR_TBL+6), de
|
|
|
|
ld (VAR_TBL+14), hl
|
|
|
|
cp a ; USR never errors out
|
|
|
|
ret
|
|
|
|
|
2019-12-01 13:36:34 +11:00
|
|
|
; Command table format: Null-terminated string followed by a 2-byte routine
|
|
|
|
; pointer.
|
|
|
|
|
2019-11-14 07:28:16 +11:00
|
|
|
; direct only
|
|
|
|
basCmds1:
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "list", 0
|
2019-11-20 07:14:04 +11:00
|
|
|
.dw basLIST
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "run", 0
|
2019-11-21 02:49:23 +11:00
|
|
|
.dw basRUN
|
2019-11-25 06:26:32 +11:00
|
|
|
.db "clear", 0
|
2019-12-01 13:36:34 +11:00
|
|
|
.dw bufInit
|
2019-11-14 07:28:16 +11:00
|
|
|
; statements
|
|
|
|
basCmds2:
|
2019-11-19 05:40:23 +11:00
|
|
|
.db "print", 0
|
2019-12-01 13:36:34 +11:00
|
|
|
.dw basPRINT
|
|
|
|
.db "goto", 0
|
2019-11-21 07:44:13 +11:00
|
|
|
.dw basGOTO
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "if", 0
|
2019-11-22 08:06:14 +11:00
|
|
|
.dw basIF
|
2019-12-13 03:17:10 +11:00
|
|
|
.db "while", 0
|
|
|
|
.dw basWHILE
|
2019-11-22 12:17:55 +11:00
|
|
|
.db "input", 0
|
2019-12-01 13:36:34 +11:00
|
|
|
.dw basINPUT
|
|
|
|
.db "peek", 0
|
2019-11-24 08:07:10 +11:00
|
|
|
.dw basPEEK
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "poke", 0
|
2019-11-24 08:07:10 +11:00
|
|
|
.dw basPOKE
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "deek", 0
|
2019-11-24 08:07:10 +11:00
|
|
|
.dw basDEEK
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "doke", 0
|
2019-11-24 08:07:10 +11:00
|
|
|
.dw basDOKE
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "out", 0
|
2019-11-24 12:35:21 +11:00
|
|
|
.dw basOUT
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "in", 0
|
2019-11-24 12:35:21 +11:00
|
|
|
.dw basIN
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "getc", 0
|
2019-12-01 13:13:44 +11:00
|
|
|
.dw basGETC
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "putc", 0
|
2019-12-01 13:13:44 +11:00
|
|
|
.dw basPUTC
|
2019-12-10 06:15:43 +11:00
|
|
|
.db "puth", 0
|
|
|
|
.dw basPUTH
|
2019-11-24 09:07:14 +11:00
|
|
|
.db "sleep", 0
|
2019-12-01 13:36:34 +11:00
|
|
|
.dw basSLEEP
|
|
|
|
.db "addr", 0
|
2019-11-25 07:39:36 +11:00
|
|
|
.dw basADDR
|
2019-12-01 13:36:34 +11:00
|
|
|
.db "usr", 0
|
2019-11-25 13:07:03 +11:00
|
|
|
.dw basUSR
|
2019-12-01 13:36:34 +11:00
|
|
|
.db 0xff ; end of table
|