first step towards string expression evaluation
This commit is contained in:
1 parent
801755c9a8
commit
48eec7d56e
5 files changed
+89
-13
No files matched your search
@@ -20,7 +20,7 @@
|
|||||||
.label VERCKB = $0A // flag used by BASIC, 0 - LOAD, 1 - VERIFY
|
.label VERCKB = $0A // flag used by BASIC, 0 - LOAD, 1 - VERIFY
|
||||||
.label COUNT = $0B // [!] our implementation might be different XXX give more details
|
.label COUNT = $0B // [!] our implementation might be different XXX give more details
|
||||||
.label DIMFLG = $0C // [!] our implementation might be different XXX give more details
|
.label DIMFLG = $0C // [!] our implementation might be different XXX give more details
|
||||||
.label VALTYP = $0D // -- NOT IMPLEMENTED --
|
.label VALTYP = $0D // expression eveluation result; $00 - float, $FF - string
|
||||||
.label INTFLG = $0E // -- NOT IMPLEMENTED --
|
.label INTFLG = $0E // -- NOT IMPLEMENTED --
|
||||||
.label GARBFL = $0F // [!] our implementation might be different XXX give more details
|
.label GARBFL = $0F // [!] our implementation might be different XXX give more details
|
||||||
.label SUBFLG = $10 // -- NOT IMPLEMENTED --
|
.label SUBFLG = $10 // -- NOT IMPLEMENTED --
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
// #LAYOUT# STD * #TAKE
|
|
||||||
// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
|
||||||
// #LAYOUT# * BASIC_0 #TAKE
|
|
||||||
// #LAYOUT# * * #IGNORE
|
|
||||||
|
|
||||||
|
|
||||||
// XXX provide documentation and implementation
|
|
||||||
|
|
||||||
FRMEVL:
|
|
||||||
STUB_IMPLEMENTATION()
|
|
||||||
@@ -6,8 +6,50 @@
|
|||||||
|
|
||||||
cmd_print:
|
cmd_print:
|
||||||
|
|
||||||
// XXX print an argument here
|
// First check if we have anything to print
|
||||||
|
|
||||||
|
jsr end_of_statement_check
|
||||||
|
bcs cmd_print_new_line
|
||||||
|
|
||||||
|
cmp #$3B // semicolon
|
||||||
|
beq cmd_print_done
|
||||||
|
|
||||||
|
jsr unconsume_character
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_print_loop:
|
||||||
|
|
||||||
|
// Now evaluate the expression
|
||||||
|
|
||||||
|
jsr FRMEVL
|
||||||
|
lda VALTYP
|
||||||
|
bpl cmd_print_float
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_print_string:
|
||||||
|
|
||||||
|
// Print a string value
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
!:
|
||||||
|
cpy __FAC1 + 0
|
||||||
|
beq cmd_print_next_arg
|
||||||
|
|
||||||
|
lda (__FAC1 + 1), y // XXX read from under ROM
|
||||||
|
jsr JCHROUT
|
||||||
|
iny
|
||||||
|
jmp !-
|
||||||
|
|
||||||
|
cmd_print_float:
|
||||||
|
|
||||||
|
// XXX probably we should also check INTFLG here
|
||||||
|
// XXX
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_print_next_arg:
|
||||||
|
|
||||||
// Look for the next argument
|
// Look for the next argument
|
||||||
|
|
||||||
@@ -16,10 +58,14 @@ cmd_print:
|
|||||||
|
|
||||||
jsr fetch_character
|
jsr fetch_character
|
||||||
cmp #$2C // comma
|
cmp #$2C // comma
|
||||||
beq cmd_print
|
beq cmd_print_loop
|
||||||
cmp #$3B // semicolon
|
cmp #$3B // semicolon
|
||||||
beq cmd_print_done
|
beq cmd_print_done
|
||||||
|
|
||||||
|
// Something unexpected
|
||||||
|
|
||||||
|
jmp do_SYNTAX_error
|
||||||
|
|
||||||
cmd_print_new_line:
|
cmd_print_new_line:
|
||||||
|
|
||||||
jsr print_return
|
jsr print_return
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
// Well-known BASIC routine, described in:
|
||||||
|
//
|
||||||
|
// - [CM64] Computes Mapping the Commodore 64 - page 102
|
||||||
|
// - https://sta.c64.org/cbm64basconv.html
|
||||||
|
//
|
||||||
|
// Output:
|
||||||
|
// - VALTYP - $00 = floating number, $FF = string
|
||||||
|
// - INTFLG (XXX float/integer, probably)
|
||||||
|
// - for float: FAC1
|
||||||
|
// - for string: __FAC1 + 0 = length, __FAC1 + 1 = pointer to string
|
||||||
|
|
||||||
|
// XXX provide documentation and implementation
|
||||||
|
|
||||||
|
FRMEVL:
|
||||||
|
|
||||||
|
// XXX for now we just report dummy string
|
||||||
|
|
||||||
|
lda #$FF
|
||||||
|
sta VALTYP
|
||||||
|
|
||||||
|
lda #$0B
|
||||||
|
sta __FAC1 + 0
|
||||||
|
|
||||||
|
lda #<dummy_text
|
||||||
|
sta __FAC1 + 1
|
||||||
|
|
||||||
|
lda #>dummy_text
|
||||||
|
sta __FAC1 + 2
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
dummy_text:
|
||||||
|
|
||||||
|
.text "LOREM IPSUM"
|
||||||
File renamed without changes.
Reference in new issue
Block a user