Skip to content

Commit

Permalink
Merge pull request #41 from kerrishotts/develop-2.0
Browse files Browse the repository at this point in the history
Develop 2.0
  • Loading branch information
kerrishotts authored Jul 8, 2020
2 parents 521a18f + 30b124a commit 807fef1
Show file tree
Hide file tree
Showing 27 changed files with 5,177 additions and 1,898 deletions.
46 changes: 39 additions & 7 deletions asm/kernel/basic/basic.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
# 31:30 = type (0=FOR, 1=GOSUB, 2=CALL)
# 29:16 = variable (for FOR)
# 15:0 = line number to return to
expr-area: .byte[256] # (0x100) Area for evaluating expressions

# 0x300 bytes remaining for non-array data
forsub-stack-ptr: .byte 0 # pointer into forsub stack
Expand All @@ -62,14 +61,21 @@
param-types: .byte[10] # tracks the types of each parameter on the queue
params: .byte[80] # Up to 10 parameters (8 bytes)

accumulator-token: .byte 0 # current accumulator type
accumulator: .word 0, 0, 0, 0 # current accumulator value (or ptr, if string)

operand-token: .byte 0 # second operand type
operand: .word 0, 0, 0, 0 # value of second operand

itoa-buffer: .byte[32] # buffer for int-to-string ops

list-options:
highlight: .byte 1 # if !0, use syntax highlighting
indent: .byte 1 # if !0, enable block indentation
list-colors:
linenum-color: .byte constants.LINENUM_COLOR
function-color: .byte constants.FUNCTION_COLOR
operator-color: .byte constants.OPERATOR_COLOR
grouping-color: .byte constants.GROUPING_COLOR
command-color: .byte constants.COMMAND_COLOR
number-color: .byte constants.NUMBER_COLOR
string-color: .byte constants.STRING_COLOR
variable-color: .byte constants.VARIABLE_COLOR


# some self-modifying code lives here too :-/
_self-mod:
Expand Down Expand Up @@ -111,6 +117,9 @@
.import "./handlers/fn.asm"
.import "./handlers/stmt.asm"

.import "./expr-tokens.asm"
.import "./stmt-tokens.asm"

.import "./eval.asm"
.import "./exec.asm"

Expand Down Expand Up @@ -146,6 +155,29 @@
x := brodata.welcome & 7
call [vectors.PRINT]
call new
call init-list-options
ret
}

init-list-options: {
dl := 1
[bdata.indent] := dl
dl := constants.LINENUM_COLOR
[bdata.linenum-color] := dl
dl := constants.FUNCTION_COLOR
[bdata.function-color] := dl
dl := constants.OPERATOR_COLOR
[bdata.operator-color] := dl
dl := constants.GROUPING_COLOR
[bdata.grouping-color] := dl
dl := constants.NUMBER_COLOR
[bdata.number-color] := dl
dl := constants.STRING_COLOR
[bdata.string-color] := dl
dl := constants.VARIABLE_COLOR
[bdata.variable-color] := dl
dl := constants.COMMAND_COLOR
[bdata.command-color] := dl
ret
}

Expand Down
11 changes: 11 additions & 0 deletions asm/kernel/basic/constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.const CLS 12
.const SPACE 0x20
.const QUOTE 0x22
.const CURSOR_LEFT 17

.const MODE_DIRECT 0x00
.const MODE_RUN 0x01
Expand All @@ -15,4 +16,14 @@

.const EXIT_EARLY 0xFF
.const NO_STMT_TERM_NEEDED 0xFE

.const COMMAND_COLOR 22 # Yellow
.const FUNCTION_COLOR 22 # Yellow
.const OPERATOR_COLOR 22 # Yellow
.const GROUPING_COLOR 23 # White
.const LINENUM_COLOR 23 # White
.const NUMBER_COLOR 19 # Cyan
.const STRING_COLOR 21 # Purple
.const VARIABLE_COLOR 23 # White

}
130 changes: 0 additions & 130 deletions asm/kernel/basic/eval.asm
Original file line number Diff line number Diff line change
Expand Up @@ -200,136 +200,6 @@
ret
}


expression-handlers: # vector, param#s, assoc (0=left,0F=right), precedence
.word token-not-impl ,0x1014 # 128, ABS
.word token-not-impl ,0x2006 # 129, AND
.word token-not-impl ,0x1014 # 130, ASC
.word token-not-impl ,0x1014 # 131, ATN
.word handler-syntax-error ,0x0000 # 132, AT
.word handler-syntax-error ,0x0000 # 133, CALL
.word handler-syntax-error ,0x0000 # 134, CATALOG
.word token-not-impl ,0x1014 # 135, CHR
.word handler-syntax-error ,0x0000 # 136, CLS
.word handler-syntax-error ,0x0000 # 137, CLOSE
.word handler-syntax-error ,0x0000 # 138, CONTINUE
.word token-not-impl ,0x1014 # 139, COS
.word handler-syntax-error ,0x0000 # 140, DATA
.word handler-syntax-error ,0x0000 # 141, DEFFN
.word handler-syntax-error ,0x0000 # 142, DEFSUB
.word handler-syntax-error ,0x0000 # 143, DIM
.word handler-syntax-error ,0x0000 # 144, DO
.word handler-syntax-error ,0x0000 # 145, ELSEIF
.word handler-syntax-error ,0x0000 # 146, ELSE
.word handler-syntax-error ,0x0000 # 147, ENDSUB
.word handler-syntax-error ,0x0000 # 148, ENDFN
.word handler-syntax-error ,0x0000 # 149, ENDIF
.word handler-syntax-error ,0x0000 # 150, END
.word token-not-impl ,0x1014 # 151, EXP
.word handler-syntax-error ,0x0000 # 152, FOR
.word token-not-impl ,0x0014 # 153, GETKEY
.word handler-syntax-error ,0x0000 # 154, GOSUB
.word handler-syntax-error ,0x0000 # 155, GOTO
.word token-not-impl ,0x1014 # 156, HEX
.word handler-syntax-error ,0x0000 # 157, HOME
.word handler-syntax-error ,0x0000 # 158, IF
.word handler-syntax-error ,0x0000 # 159, INPUT
.word token-not-impl ,0x1014 # 160, INT
.word handler-in-expr ,0x1014 # 161, IN
.word token-not-impl ,0x3014 # 162, LEFT
.word token-not-impl ,0x1014 # 163, LEN
.word handler-syntax-error ,0x0000 # 164, LIST
.word handler-syntax-error ,0x0000 # 165, LOAD
.word token-not-impl ,0x1014 # 166, LOG
.word handler-syntax-error ,0x0000 # 167, LOOP
.word token-not-impl ,0x3014 # 168, MID
.word handler-syntax-error ,0x0000 # 169, NEW
.word handler-syntax-error ,0x0000 # 170, NEXT
.word token-not-impl ,0x1F11 # 171, NOT (right assoc)
.word handler-syntax-error ,0x0000 # 172, ON
.word handler-syntax-error ,0x0000 # 173, OPEN
.word token-not-impl ,0x2005 # 174, OR
.word handler-syntax-error ,0x0000 # 175, OUT
.word handler-peek-expr ,0x2014 # 176, PEEK
.word handler-syntax-error ,0x0000 # 177, POKE
.word handler-syntax-error ,0x0000 # 178, PRINT
.word handler-syntax-error ,0x0000 # 179, READ
.word token-not-impl ,0x0000 # 180, REM
.word handler-syntax-error ,0x0000 # 181, RETURN
.word token-not-impl ,0x3014 # 182, RIGHT
.word handler-rnd-expr ,0x1014 # 183, RND
.word handler-syntax-error ,0x0000 # 184, RENAME
.word handler-syntax-error ,0x0000 # 185, REMOVE
.word handler-syntax-error ,0x0000 # 186, RESTORE
.word handler-syntax-error ,0x0000 # 187, RUN
.word handler-syntax-error ,0x0000 # 188, SAVE
.word token-not-impl ,0x1014 # 189, SGN
.word token-not-impl ,0x1014 # 190, SIN
.word token-not-impl ,0x1014 # 191, SPC
.word token-not-impl ,0x1014 # 192, SQR
.word handler-syntax-error ,0x0000 # 193, STEP
.word handler-syntax-error ,0x0000 # 194, STOP
.word token-not-impl ,0x1014 # 195, STR
.word token-not-impl ,0x1014 # 196, TAB
.word token-not-impl ,0x1014 # 197, TAN
.word handler-syntax-error ,0x0000 # 198, THEN
.word handler-syntax-error ,0x0000 # 199, TO
.word handler-syntax-error ,0x0000 # 200, UNTIL
.word token-not-impl ,0x1014 # 201, USR
.word token-not-impl ,0x1014 # 202, VAL
.word handler-syntax-error ,0x0000 # 203, WHILE
.word handler-add-expr ,0x200E # 204, +
.word handler-sub-expr ,0x200E # 205, -
.word handler-mul-expr ,0x200F # 206, *
.word handler-div-expr ,0x200F # 207, /
.word handler-mod-expr ,0x200F # 208, %
.word token-not-impl ,0x2F10 # 209, ^ right associative
.word handler-neq-expr ,0x200B # 210, <>, !=
.word handler-lte-expr ,0x200C # 211, <=
.word handler-gte-expr ,0x200C # 212, >=
.word handler-lt-expr ,0x200C # 213, <
.word handler-gt-expr ,0x200C # 214, >
.word handler-equ-expr ,0x200B # 215, =
.word 0xFFFE ,0x0015 # 216, (
.word 0xFFFF ,0x0015 # 217, )
.word token-not-impl ,0x0014 # 218, [
.word token-not-impl ,0x0014 # 219, ]
.word token-not-impl ,0x00FF # 220, :
.word token-not-impl ,0x1014 # 221, LOWER
.word token-not-impl ,0x1014 # 222, UPPER
.word handler-syntax-error ,0x0000 # 223, LET
.word token-not-impl ,0x0001 # 224, COMMA
.word token-not-impl ,0x0001 # 225, SEMICOLON
.word token-not-impl ,0x2014 # 226, CHRS$
.word handler-neg-expr ,0x1011 # 227, Unary -
.word token-not-impl ,0x0000 # 228
.word token-not-impl ,0x0000 # 229
.word token-not-impl ,0x0000 # 230
.word token-not-impl ,0x0000 # 231
.word token-not-impl ,0x0000 # 232
.word token-not-impl ,0x0000 # 233
.word token-not-impl ,0x0000 # 234
.word token-not-impl ,0x0000 # 235
.word token-not-impl ,0x0000 # 236
.word token-not-impl ,0x0000 # 237
.word token-not-impl ,0x0000 # 238
.word token-not-impl ,0x0000 # 239
.word token-not-impl ,0x0000 # 240
.word token-not-impl ,0x0000 # 241
.word token-not-impl ,0x0000 # 242
.word token-not-impl ,0x0000 # 243
.word token-not-impl ,0x0000 # 244
.word token-not-impl ,0x0000 # 245
.word token-not-impl ,0x0000 # 246
.word token-not-impl ,0x0000 # 247
.word token-not-impl ,0x0000 # 248
.word token-not-impl ,0x00FF # 249, TOK_REAL
.word token-not-impl ,0x00FF # 250, TOK_VARIABLE
.word token-not-impl ,0x00FF # 251, TOK_CODE_STRING
.word token-not-impl ,0x00FF # 252, TOK_STRING
.word token-not-impl ,0x00FF # 253, TOK_DWORD
.word token-not-impl ,0x00FF # 254, TOK_WORD
.word token-not-impl ,0x00FF # 255, TOK_BYTE
#
# EVAL is responsible for evaluating the current expression
#
Expand Down
131 changes: 0 additions & 131 deletions asm/kernel/basic/exec.asm
Original file line number Diff line number Diff line change
@@ -1,135 +1,4 @@
.segment __current__ kmemmap.basic.code-start .append {
statement-handlers:
.word handler-syntax-error # 128, ABS
.word handler-syntax-error # 129, AND
.word handler-syntax-error # 130, ASC
.word handler-syntax-error # 131, ATN
.word handler-syntax-error # 132, AT
.word token-not-impl # 133, CALL
.word token-not-impl # 134, CATALOG
.word handler-syntax-error # 135, CHR
.word handler-clear-screen # 136, CLS
.word token-not-impl # 137, CLOSE
.word token-not-impl # 138, CONTINUE
.word handler-syntax-error # 139, COS
.word token-not-impl # 140, DATA
.word token-not-impl # 141, DEFFN
.word token-not-impl # 142, DEFSUB
.word token-not-impl # 143, DIM
.word token-not-impl # 144, DO
.word token-not-impl # 145, ELSEIF
.word token-not-impl # 146, ELSE
.word token-not-impl # 147, ENDSUB
.word token-not-impl # 148, ENDFN
.word token-not-impl # 149, ENDIF
.word token-not-impl # 150, END
.word handler-syntax-error # 151, EXP
.word token-not-impl # 152, FOR
.word handler-syntax-error # 153, GETKEY
.word token-not-impl # 154, GOSUB
.word handler-goto # 155, GOTO
.word handler-syntax-error # 156, HEX
.word handler-home # 157, HOME
.word handler-if # 158, IF
.word token-not-impl # 159, INPUT
.word handler-syntax-error # 160, INT
.word handler-syntax-error # 161, IN
.word handler-syntax-error # 162, LEFT
.word handler-syntax-error # 163, LEN
.word handler-list # 164, LIST
.word token-not-impl # 165, LOAD
.word handler-syntax-error # 166, LOG
.word token-not-impl # 167, LOOP
.word handler-syntax-error # 168, MID
.word handler-new # 169, NEW
.word token-not-impl # 170, NEXT
.word handler-syntax-error # 171, NOT
.word token-not-impl # 172, ON
.word token-not-impl # 173, OPEN
.word handler-syntax-error # 174, OR
.word handler-out # 175, OUT
.word handler-syntax-error # 176, PEEK
.word handler-poke # 177, POKE
.word handler-print # 178, PRINT
.word token-not-impl # 179, READ
.word handler-rem # 180, REM
.word token-not-impl # 181, RETURN
.word handler-syntax-error # 182, RIGHT
.word handler-syntax-error # 183, RND
.word token-not-impl # 184, RENAME
.word token-not-impl # 185, REMOVE
.word token-not-impl # 186, RESTORE
.word handler-run # 187, RUN
.word token-not-impl # 188, SAVE
.word handler-syntax-error # 189, SGN
.word handler-syntax-error # 190, SIN
.word handler-syntax-error # 191, SPC
.word handler-syntax-error # 192, SQR
.word token-not-impl # 193, STEP
.word token-not-impl # 194, STOP
.word handler-syntax-error # 195, STR
.word handler-syntax-error # 196, TAB
.word handler-syntax-error # 197, TAN
.word token-not-impl # 198, THEN
.word token-not-impl # 199, TO
.word token-not-impl # 200, UNTIL
.word handler-syntax-error # 201, USR
.word handler-syntax-error # 202, VAL
.word token-not-impl # 203, WHILE
.word handler-syntax-error # 204, +
.word handler-syntax-error # 205, -
.word handler-syntax-error # 206, *
.word handler-syntax-error # 207, /
.word handler-syntax-error # 208, %
.word handler-syntax-error # 209, ^
.word handler-syntax-error # 210, <>, !=
.word handler-syntax-error # 211, <=
.word handler-syntax-error # 212, >=
.word handler-syntax-error # 213, <
.word handler-syntax-error # 214, >
.word handler-syntax-error # 215, =
.word handler-syntax-error # 216, (
.word handler-syntax-error # 217, )
.word handler-syntax-error # 218, [
.word handler-syntax-error # 219, ]
.word token-not-impl # 220, :
.word handler-syntax-error # 221, LOWER
.word handler-syntax-error # 222, UPPER
.word handler-let # 223, LET
.word token-not-impl # 224, COMMA
.word token-not-impl # 225, SEMICOLON
.word token-not-impl # 226, CHRS$
.word token-not-impl # 227
.word token-not-impl # 228
.word token-not-impl # 229
.word token-not-impl # 230
.word token-not-impl # 231
.word token-not-impl # 232
.word token-not-impl # 233
.word token-not-impl # 234
.word token-not-impl # 235
.word token-not-impl # 236
.word token-not-impl # 237
.word token-not-impl # 238
.word token-not-impl # 239
.word token-not-impl # 240
.word token-not-impl # 241
.word token-not-impl # 242
.word token-not-impl # 243
.word token-not-impl # 244
.word token-not-impl # 245
.word token-not-impl # 246
.word token-not-impl # 247
.word token-not-impl # 248
.word handler-syntax-error # 249, TOK_REAL
.word handler-assignment # 250, TOK_VARIABLE
.word handler-syntax-error # 251, TOK_CODE_STRING
.word handler-syntax-error # 252, TOK_STRING
.word handler-syntax-error # 253, TOK_DWORD
.word handler-syntax-error # 254, TOK_WORD
.word handler-syntax-error # 255, TOK_BYTE


#
# EXEC is responsible for evaluating the line at D,X
#
Expand Down
Loading

0 comments on commit 807fef1

Please sign in to comment.