mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:08:07 +11:00
basic: add expression support to print
Again, same thing as in zasm.
This commit is contained in:
parent
0bd58fd178
commit
f5b04fc02f
@ -14,6 +14,8 @@
|
||||
.inc "lib/ari.asm"
|
||||
.inc "lib/parse.asm"
|
||||
.inc "lib/fmt.asm"
|
||||
.equ EXPR_PARSE parseLiteral
|
||||
.inc "lib/expr.asm"
|
||||
.inc "basic/tok.asm"
|
||||
.equ BAS_RAMSTART USER_RAMSTART
|
||||
.inc "basic/main.asm"
|
||||
|
@ -105,7 +105,7 @@ basBYE:
|
||||
.db "Goodbye!", 0
|
||||
|
||||
basPRINT:
|
||||
call parseLiteral
|
||||
call parseExpr
|
||||
jp nz, basERR
|
||||
push ix \ pop de
|
||||
ld hl, BAS_SCRATCHPAD
|
||||
|
@ -1,3 +1,15 @@
|
||||
; *** Requirements ***
|
||||
; findchar
|
||||
; multDEBC
|
||||
;
|
||||
; *** Defines ***
|
||||
;
|
||||
; EXPR_PARSE: routine to call to parse literals or symbols that are part of
|
||||
; the expression. Routine's signature:
|
||||
; String in (HL), returns its parsed value to IX. Z for success.
|
||||
;
|
||||
; *** Code ***
|
||||
;
|
||||
; Parse expression in string at (HL) and returns the result in IX.
|
||||
; We expect (HL) to be disposable: we mutate it to avoid having to make a copy.
|
||||
; Sets Z on success, unset on error.
|
||||
@ -19,7 +31,7 @@ _parseExpr:
|
||||
ld a, '*'
|
||||
call _findAndSplit
|
||||
jp z, _applyMult
|
||||
jp parseNumberOrSymbol
|
||||
jp EXPR_PARSE
|
||||
|
||||
; Given a string in (HL) and a separator char in A, return a splitted string,
|
||||
; that is, the same (HL) string but with the found A char replaced by a null
|
@ -74,3 +74,19 @@ strlen:
|
||||
pop bc
|
||||
ret
|
||||
|
||||
; DE * BC -> DE (high) and HL (low)
|
||||
multDEBC:
|
||||
ld hl, 0
|
||||
ld a, 0x10
|
||||
.loop:
|
||||
add hl, hl
|
||||
rl e
|
||||
rl d
|
||||
jr nc, .noinc
|
||||
add hl, bc
|
||||
jr nc, .noinc
|
||||
inc de
|
||||
.noinc:
|
||||
dec a
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
@ -31,8 +31,6 @@
|
||||
; _blkSeek
|
||||
; _blkTell
|
||||
; printstr
|
||||
; FS_HANDLE_SIZE
|
||||
; BLOCKDEV_SIZE
|
||||
|
||||
.inc "user.h"
|
||||
|
||||
@ -80,7 +78,8 @@ jp zasmMain
|
||||
.equ DIREC_RAMSTART INS_RAMEND
|
||||
.inc "zasm/directive.asm"
|
||||
.inc "zasm/parse.asm"
|
||||
.inc "zasm/expr.asm"
|
||||
.equ EXPR_PARSE parseNumberOrSymbol
|
||||
.inc "lib/expr.asm"
|
||||
.equ SYM_RAMSTART DIREC_RAMEND
|
||||
.inc "zasm/symbol.asm"
|
||||
.equ ZASM_RAMSTART SYM_RAMEND
|
||||
|
@ -171,19 +171,3 @@ findStringInList:
|
||||
ret
|
||||
|
||||
|
||||
; DE * BC -> DE (high) and HL (low)
|
||||
multDEBC:
|
||||
ld hl, 0
|
||||
ld a, 0x10
|
||||
.loop:
|
||||
add hl, hl
|
||||
rl e
|
||||
rl d
|
||||
jr nc, .noinc
|
||||
add hl, bc
|
||||
jr nc, .noinc
|
||||
inc de
|
||||
.noinc:
|
||||
dec a
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
@ -18,7 +18,8 @@ jp test
|
||||
.inc "zasm/parse.asm"
|
||||
.equ SYM_RAMSTART DIREC_LASTVAL+2
|
||||
.inc "zasm/symbol.asm"
|
||||
.inc "zasm/expr.asm"
|
||||
.equ EXPR_PARSE parseNumberOrSymbol
|
||||
.inc "lib/expr.asm"
|
||||
|
||||
; Pretend that we aren't in first pass
|
||||
zasmIsFirstPass:
|
||||
|
@ -7,8 +7,8 @@ jp runTests
|
||||
.inc "lib/util.asm"
|
||||
.inc "zasm/util.asm"
|
||||
.inc "lib/parse.asm"
|
||||
.inc "zasm/parse.asm"
|
||||
.inc "zasm/expr.asm"
|
||||
.equ EXPR_PARSE parseLiteral
|
||||
.inc "lib/expr.asm"
|
||||
.equ INS_RAMSTART RAMSTART
|
||||
.inc "zasm/instr.asm"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user