implement beginnings of BASIC main loop execution

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-28 22:10:32 +09:30
1 parent 06a227696e
commit 6a0b2d8e7f
4 files changed
+310 -58

No files matched your search

+160
View File
@@ -16,6 +16,19 @@ basic_execute_line:
;; The checks should be done in order of frequency, so that we are as
;; fast as possible.
cmp #$7f
bcc not_a_token
;; It's a token: So get the jump table entry for it, push it on the stack
;; and then RTS to start it.
asl
tax
lda basic_command_jump_table+1,x
pha
lda basic_command_jump_table+0,x
pha
rts
not_a_token:
;; Space, which we can also just ignore
cmp #$20
beq basic_skip_char
@@ -45,3 +58,150 @@ basic_end_of_line:
;; one.
jmp basic_main_loop
basic_command_jump_table:
;; $80 - $8F
.word cmd_end-1
.word cmd_for-1
.word cmd_next-1
.word cmd_data-1
.word cmd_inputhash-1
.word cmd_input-1
.word cmd_dim-1
.word cmd_read-1
.word cmd_let-1
.word cmd_goto-1
.word cmd_run-1
.word cmd_if-1
.word cmd_restore-1
.word cmd_gosub-1
.word cmd_return -1
.word cmd_rem-1
;; $90-$9F
.word cmd_stop-1
.word cmd_on-1
.word cmd_wait-1
.word cmd_load-1
.word cmd_save-1
.word cmd_verify-1
.word cmd_def-1
.word cmd_poke-1
.word cmd_printhash-1
.word cmd_print-1
.word cmd_cont-1
.word cmd_list-1
.word cmd_clr-1
.word cmd_cmd-1
.word cmd_sys-1
.word cmd_open-1
;; $A0-$AF
.word cmd_close-1
.word cmd_get-1
.word cmd_new-1
.word cmd_tab-1
.word cmd_to-1
.word cmd_fn-1
.word cmd_spc-1
.word cmd_then-1
.word cmd_not-1
.word cmd_step-1
.word cmd_plus-1
.word cmd_minus-1
.word cmd_mult-1
.word cmd_div-1
.word cmd_exponent-1
.word cmd_and-1
;; $B0-$BF
.word cmd_or-1
.word cmd_greater-1
.word cmd_equal-1
.word cmd_less-1
.word cmd_sgn-1
.word cmd_int-1
.word cmd_abs-1
.word cmd_usr-1
.word cmd_fre-1
.word cmd_pos-1
.word cmd_sqr-1
.word cmd_rnd-1
.word cmd_log-1
.word cmd_exp-1
.word cmd_cos-1
.word cmd_sin-1
;; $C0-$CF
.word cmd_tan-1
.word cmd_atn-1
.word cmd_peek-1
.word cmd_len-1
.word cmd_str-1
.word cmd_val-1
.word cmd_asc-1
.word cmd_chr-1
.word cmd_left-1
.word cmd_right-1
.word cmd_mid-1
.word cmd_go-1
;; Undefined tokens
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
;; $D0-$DF
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
;; $E0-$EF
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
;; $F0-$FF
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
.word cmd_unimplemented-1
+89
View File
@@ -0,0 +1,89 @@
;; Default handler for all not-yet-implemented commands
cmd_end:
cmd_for:
cmd_next:
cmd_data:
cmd_inputhash:
cmd_input:
cmd_dim:
cmd_read:
cmd_let:
cmd_goto:
cmd_run:
cmd_if:
cmd_restore:
cmd_gosub:
cmd_return:
cmd_rem:
;; $90-$9F
cmd_stop:
cmd_on:
cmd_wait:
cmd_load:
cmd_save:
cmd_verify:
cmd_def:
cmd_poke:
cmd_printhash:
cmd_print:
cmd_cont:
cmd_list:
cmd_cmd:
cmd_sys:
cmd_open:
;; $A0-$AF
cmd_close:
cmd_get:
cmd_tab:
cmd_to:
cmd_fn:
cmd_spc:
cmd_then:
cmd_not:
cmd_step:
cmd_plus:
cmd_minus:
cmd_mult:
cmd_div:
cmd_exponent:
cmd_and:
;; $B0-$BF
cmd_or:
cmd_greater:
cmd_equal:
cmd_less:
cmd_sgn:
cmd_int:
cmd_abs:
cmd_usr:
cmd_fre:
cmd_pos:
cmd_sqr:
cmd_rnd:
cmd_log:
cmd_exp:
cmd_cos:
cmd_sin:
;; $C0-$CF
cmd_tan:
cmd_atn:
cmd_peek:
cmd_len:
cmd_str:
cmd_val:
cmd_asc:
cmd_chr:
cmd_left:
cmd_right:
cmd_mid:
cmd_go:
;; Undefined tokens
cmd_unimplemented:
ldx #36
jmp do_basic_error
+60 -58
View File
@@ -6,10 +6,10 @@ packed_message_chars:
.byte $49 ; 'I' = $5 (nybl)
.byte $52 ; 'R' = $6 (nybl)
.byte $41 ; 'A' = $7 (nybl)
.byte $53 ; 'S' = $8 (nybl)
.byte $4C ; 'L' = $9 (nybl)
.byte $46 ; 'F' = $a (nybl)
.byte $44 ; 'D' = $b (nybl)
.byte $4C ; 'L' = $8 (nybl)
.byte $53 ; 'S' = $9 (nybl)
.byte $44 ; 'D' = $a (nybl)
.byte $46 ; 'F' = $b (nybl)
.byte $55 ; 'U' = $c (nybl)
.byte $50 ; 'P' = $d (nybl)
.byte $4D ; 'M' = $e (nybl)
@@ -54,69 +54,71 @@ packed_message_tokens:
.byte $ff,$30,$ff,$31,$ff,$32,$ff,$33
.byte $ff,$34,$ff,$35,$36,$ff,$1a,$37
.byte $ff
.byte $05
.byte $38
.byte $ff
packed_message_words:
.byte $23,$30,$e7,$4f,$59,$00,$a5,$91
.byte $80,$a5,$91,$00,$3d,$14,$00,$43
.byte $20,$a3,$c4,$b0,$b1,$f4,$5f,$43
.byte $10,$d6,$18,$14,$20,$54,$dc,$20
.byte $3c,$2d,$c2,$00,$e5,$88,$54,$f2
.byte $00,$a5,$91,$47,$e1,$00,$59,$91
.byte $f2,$79,$00,$4c,$ef,$42,$16,$00
.byte $23,$30,$e7,$4f,$59,$00,$b5,$81
.byte $90,$b5,$81,$00,$3d,$14,$00,$43
.byte $20,$b3,$c4,$a0,$a1,$f4,$5f,$43
.byte $10,$d6,$19,$14,$20,$54,$dc,$20
.byte $3c,$2d,$c2,$00,$e5,$99,$54,$f2
.byte $00,$b5,$81,$47,$e1,$00,$58,$81
.byte $f2,$78,$00,$4c,$ef,$42,$16,$00
.byte $41,$f7,$20,$f8,$52,$f6,$3c,$20
.byte $a3,$60,$8f,$59,$42,$7f,$58,$00
.byte $61,$2c,$64,$00,$f2,$38,$cf,$42
.byte $00,$3c,$20,$3a,$00,$b7,$27,$00
.byte $b3,$60,$9f,$59,$42,$7f,$58,$00
.byte $61,$2c,$64,$00,$f2,$39,$cf,$42
.byte $00,$3c,$20,$3b,$00,$a7,$27,$00
.byte $fc,$c7,$42,$52,$f3,$00,$3f,$56
.byte $16,$a9,$3f,$57,$00,$e1,$e3,$6f
.byte $59,$00,$c4,$b1,$af,$27,$b0,$82
.byte $72,$1e,$14,$20,$f5,$7b,$00,$8c
.byte $f5,$8f,$43,$65,$d2,$00,$61,$b5
.byte $ef,$27,$b0,$76,$67,$f3,$00,$b5
.byte $f4,$58,$53,$40,$f5,$f3,$00,$ff
.byte $5a,$16,$30,$b5,$61,$f1,$20,$2f
.byte $59,$d1,$00,$e5,$8e,$72,$f1,$f6
.byte $00,$82,$65,$4f,$47,$00,$93,$4f
.byte $47,$00,$a3,$6e,$c9,$70,$f1,$3e
.byte $d9,$1f,$58,$00,$f1,$74,$fa,$20
.byte $f1,$34,$25,$4c,$10,$ac,$4f,$43
.byte $25,$34,$00,$f4,$16,$5a,$f3,$00
.byte $93,$7b,$00,$61,$7b,$f3,$fd,$fb
.byte $00,$93,$7b,$54,$f2,$00,$f4,$16
.byte $5a,$f3,$54,$f2,$00,$87,$f4,$54
.byte $16,$b8,$3f,$57,$00,$e1,$e3,$6f
.byte $59,$00,$c4,$a1,$bf,$27,$a0,$92
.byte $72,$1e,$14,$20,$f5,$7a,$00,$9c
.byte $f5,$9f,$43,$65,$d2,$00,$61,$a5
.byte $ef,$27,$a0,$76,$67,$f3,$00,$a5
.byte $f4,$59,$53,$40,$f5,$f3,$00,$ff
.byte $5a,$16,$30,$a5,$61,$f1,$20,$2f
.byte $59,$d1,$00,$e5,$9e,$72,$f1,$f6
.byte $00,$92,$65,$4f,$47,$00,$83,$4f
.byte $47,$00,$b3,$6e,$c8,$70,$f1,$3e
.byte $d8,$1f,$58,$00,$f1,$74,$fa,$20
.byte $f1,$34,$25,$4c,$10,$bc,$4f,$43
.byte $25,$34,$00,$f4,$16,$5b,$f3,$00
.byte $83,$7a,$00,$61,$7a,$f3,$fd,$fb
.byte $00,$83,$7a,$54,$f2,$00,$f4,$16
.byte $5b,$f3,$54,$f2,$00,$97,$f4,$54
.byte $f2,$00,$16,$63,$60,$f5,$f3,$21
.byte $80,$a6,$11,$fd,$fb,$fb,$00,$f1
.byte $36
.byte $6c
.byte $d2
.byte $00
.byte $90,$b6,$11,$fd,$fb,$fb,$00,$f1
.byte $36,$6c,$d2,$00,$5e,$d8,$1e,$14
.byte $21
.byte $a0
packed_keywords:
.byte $14,$b0,$a3,$60,$41,$f7,$20,$b7
.byte $14,$a0,$b3,$60,$41,$f7,$20,$a7
.byte $27,$00,$54,$dc,$2f,$23,$00,$54
.byte $dc,$20,$b5,$e0,$61,$7b,$00,$91
.byte $20,$f2,$32,$30,$6c,$40,$5a,$00
.byte $61,$82,$36,$10,$f2,$38,$cf,$42
.byte $00,$61,$2c,$64,$00,$61,$e0,$82
.byte $3d,$00,$34,$00,$f8,$75,$20,$93
.byte $7b,$00,$87,$f4,$10,$f4,$16,$5a
.byte $f3,$00,$b1,$a0,$d3,$ff,$4b,$10
.byte $dc,$20,$a5,$e0,$61,$7a,$00,$81
.byte $20,$f2,$32,$30,$6c,$40,$5b,$00
.byte $61,$92,$36,$10,$f2,$39,$cf,$42
.byte $00,$61,$2c,$64,$00,$61,$e0,$92
.byte $3d,$00,$34,$00,$f8,$75,$20,$83
.byte $7a,$00,$97,$f4,$10,$f4,$16,$5b
.byte $f3,$00,$a1,$b0,$d3,$ff,$4b,$10
.byte $d6,$54,$2f,$23,$00,$d6,$54,$20
.byte $f1,$34,$20,$95,$82,$00,$f1,$96
.byte $00,$f1,$eb,$00,$8f,$59,$80,$3d
.byte $14,$00,$f1,$93,$81,$00,$f2,$12
.byte $f1,$34,$20,$85,$92,$00,$f1,$86
.byte $00,$f1,$ea,$00,$9f,$59,$90,$3d
.byte $14,$00,$f1,$83,$91,$00,$f2,$12
.byte $00,$41,$f8,$00,$27,$f5,$fe,$28
.byte $23,$00,$a4,$00,$8d,$f1,$fe,$28
.byte $2f,$48,$14,$00,$43,$20,$82,$1d
.byte $23,$00,$b4,$00,$9d,$f1,$fe,$28
.byte $2f,$48,$14,$00,$43,$20,$92,$1d
.byte $00,$fe,$2b,$fe,$2d,$fe,$2a,$fe
.byte $2f,$fe,$5e,$74,$b0,$36,$00,$fe
.byte $3e,$fe,$3d,$fe,$3c,$8f,$47,$40
.byte $54,$20,$7f,$42,$80,$c8,$60,$a6
.byte $10,$d3,$80,$8f,$51,$60,$64,$b0
.byte $93,$f2,$00,$1f,$58,$d0,$f1,$38
.byte $00,$85,$40,$27,$40,$72,$40,$d1
.byte $1f,$4b,$00,$91,$40,$82,$6f,$24
.byte $00,$f4,$79,$00,$78,$f1,$00,$f1
.byte $f6,$6f,$24,$00,$91,$a2,$f9,$00
.byte $65,$f2,$f6,$2f,$24,$00,$e5,$bf
.byte $2f,$fe,$5e,$74,$a0,$36,$00,$fe
.byte $3e,$fe,$3d,$fe,$3c,$9f,$47,$40
.byte $54,$20,$7f,$42,$90,$c9,$60,$b6
.byte $10,$d3,$90,$9f,$51,$60,$64,$a0
.byte $83,$f2,$00,$1f,$58,$d0,$f1,$39
.byte $00,$95,$40,$27,$40,$72,$40,$d1
.byte $1f,$4b,$00,$81,$40,$92,$6f,$24
.byte $00,$f4,$78,$00,$79,$f1,$00,$f1
.byte $f6,$6f,$24,$00,$81,$b2,$f9,$00
.byte $65,$f2,$f6,$2f,$24,$00,$e5,$af
.byte $24
.byte $00
.byte $f2
+1
View File
@@ -165,6 +165,7 @@ char *error_list[]={
"ERROR", // #33 // Simply the word error that is attached to the other parts of messages https://fjkraan.home.xs4all.nl/comp/apple2faq/app2asoftfaq.html
"BYTES FREE.\r\r", // #34 // https://github.com/stefanhaustein/expressionparser
"MEMORY CORRUPT", // #35
"NOT IMPLEMENTED", // #36
NULL};
// Token $FF is end of message, so we can have only 255 unique words