implement reporting BASIC errors, continuing work on tokeniser
This commit is contained in:
1 parent
428bd8e497
commit
1bb72973fa
2 files changed
+65
-13
No files matched your search
@@ -0,0 +1,31 @@
|
|||||||
|
;; Error # in X
|
||||||
|
|
||||||
|
do_basic_error:
|
||||||
|
;; "?"
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
lda #$3f
|
||||||
|
jsr $ffd2
|
||||||
|
pla
|
||||||
|
tax
|
||||||
|
|
||||||
|
;; Error message text
|
||||||
|
jsr print_packed_message
|
||||||
|
|
||||||
|
lda #$20
|
||||||
|
jsr $ffd2
|
||||||
|
|
||||||
|
;; "ERROR"
|
||||||
|
ldx #33
|
||||||
|
jsr print_packed_message
|
||||||
|
|
||||||
|
;; New lines
|
||||||
|
lda #$0d
|
||||||
|
jsr $ffd2
|
||||||
|
lda #$00
|
||||||
|
jsr $ffd2
|
||||||
|
|
||||||
|
;; XXX - Restore stack depth first?
|
||||||
|
|
||||||
|
jmp basic_main_loop
|
||||||
|
|
||||||
+34
-13
@@ -29,8 +29,9 @@ tokenise_char:
|
|||||||
cmp $0113
|
cmp $0113
|
||||||
bne +
|
bne +
|
||||||
|
|
||||||
inc $0428
|
ldx #0
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Finished tokenising line
|
;; Finished tokenising line
|
||||||
;; Update tokenise_work1 and terminate with null
|
;; Update tokenise_work1 and terminate with null
|
||||||
ldx $0112
|
ldx $0112
|
||||||
@@ -40,8 +41,8 @@ tokenise_char:
|
|||||||
rts
|
rts
|
||||||
*
|
*
|
||||||
;; More to do
|
;; More to do
|
||||||
inc $0429
|
ldx #1
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Maximum keyword length
|
;; Maximum keyword length
|
||||||
lda #7
|
lda #7
|
||||||
@@ -52,35 +53,54 @@ tokenise_char_loop:
|
|||||||
;; Returns packed length in tokenise_work2 and writes the packed
|
;; Returns packed length in tokenise_work2 and writes the packed
|
||||||
;; word at $0100+
|
;; word at $0100+
|
||||||
|
|
||||||
inc $042a
|
ldx #2
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Pack string
|
;; Pack string
|
||||||
ldx $0110
|
ldx $0110
|
||||||
|
stx $044e
|
||||||
lda $0111
|
lda $0111
|
||||||
sta tokenise_work1
|
sta tokenise_work1
|
||||||
|
bpl +
|
||||||
|
foo: inc $d020
|
||||||
|
jmp foo
|
||||||
|
|
||||||
|
*
|
||||||
sta $044f
|
sta $044f
|
||||||
jsr pack_word
|
jsr pack_word
|
||||||
|
lda tokenise_work2
|
||||||
|
cmp #$10
|
||||||
|
bcc +
|
||||||
|
;; Packed string too long
|
||||||
|
ldx #16
|
||||||
|
jmp do_basic_error
|
||||||
|
*
|
||||||
|
|
||||||
inc $042b
|
ldx #3
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Search for it in keywords
|
;; Search for it in keywords
|
||||||
jsr keyword_search
|
jsr keyword_search
|
||||||
|
|
||||||
php
|
ldx #4
|
||||||
inc $042c
|
stx $0450
|
||||||
plp
|
|
||||||
|
|
||||||
;; Did we find a keyword?
|
;; Did we find a keyword?
|
||||||
bcc found_token_in_line
|
bcc found_token_in_line
|
||||||
|
|
||||||
inc $042d
|
ldx #5
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Nope, so try shorter
|
;; Nope, so try shorter
|
||||||
|
ldx $0111
|
||||||
|
stx $044d
|
||||||
|
inc $0608,x
|
||||||
dec $0111
|
dec $0111
|
||||||
bne tokenise_char_loop
|
bne tokenise_char_loop
|
||||||
|
|
||||||
inc $042e
|
ldx #6
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Is not a token, so copy to output verbatim
|
;; Is not a token, so copy to output verbatim
|
||||||
ldx $0110
|
ldx $0110
|
||||||
ldy $0112
|
ldy $0112
|
||||||
@@ -94,7 +114,8 @@ tokenise_char_loop:
|
|||||||
|
|
||||||
found_token_in_line:
|
found_token_in_line:
|
||||||
|
|
||||||
inc $042f
|
ldx #7
|
||||||
|
stx $0450
|
||||||
|
|
||||||
;; Got a token, so write it out
|
;; Got a token, so write it out
|
||||||
ldx $0112
|
ldx $0112
|
||||||
|
|||||||
Reference in new issue
Block a user