mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 22:10:56 +11:00
Compare commits
No commits in common. "585e9f3b6e0fadd70063127a19bdf33b458206b5" and "43b450ca306a3725f80c42d9b1b939de3db4e8a1" have entirely different histories.
585e9f3b6e
...
43b450ca30
@ -104,8 +104,3 @@ Symbols have a different meaning depending on the application. In zasm, it's
|
|||||||
labels and constants. In basic, it's variables.
|
labels and constants. In basic, it's variables.
|
||||||
|
|
||||||
Expressions can't contain spaces.
|
Expressions can't contain spaces.
|
||||||
|
|
||||||
Expressions can have an empty left operand. It will then be considered as 0.
|
|
||||||
This allows signed integers, for example, `-42` to be expressed as expected.
|
|
||||||
That form doesn't work well everywhere and is mostly supported for BASIC. In
|
|
||||||
zasm, you're safer with `0-42`.
|
|
||||||
|
@ -47,12 +47,10 @@ by typing a whitespace.
|
|||||||
|
|
||||||
### Numbers, expressions and variables
|
### Numbers, expressions and variables
|
||||||
|
|
||||||
Numbers are stored in memory as 16-bit integers (little endian) and numbers
|
Only 16-bit integers (unsigned for now) are supported in this BASIC. When
|
||||||
being represented by BASIC are expressed as signed integers, in decimal form.
|
printed, they're printed in decimal form. When expressing number literals, you
|
||||||
Line numbers, however, are expressed and treated as unsigned integers: You can,
|
can do so either in multiple forms. . See "Number literals" in `apps/README.md`
|
||||||
if you want, put something on line "-1", but it will be the equivalent of line
|
for details.
|
||||||
65535. When expressing number literals, you can do so either in multiple forms.
|
|
||||||
See "Number literals" in `apps/README.md` for details.
|
|
||||||
|
|
||||||
Expressions are accepted wherever a number is expected. For example,
|
Expressions are accepted wherever a number is expected. For example,
|
||||||
`print 2+3` will print `5`. See "Expressions" in `apps/README.md`.
|
`print 2+3` will print `5`. See "Expressions" in `apps/README.md`.
|
||||||
|
@ -192,7 +192,7 @@ basPRINT:
|
|||||||
jr nz, .parseError
|
jr nz, .parseError
|
||||||
push ix \ pop de
|
push ix \ pop de
|
||||||
ld hl, SCRATCHPAD
|
ld hl, SCRATCHPAD
|
||||||
call fmtDecimalS
|
call fmtDecimal
|
||||||
call printstr
|
call printstr
|
||||||
pop hl ; <-- lvl 1
|
pop hl ; <-- lvl 1
|
||||||
.chkAnother:
|
.chkAnother:
|
||||||
|
@ -97,16 +97,8 @@ _findAndSplit:
|
|||||||
; parse expression on the left (HL) and the right (DE) and put the results in
|
; parse expression on the left (HL) and the right (DE) and put the results in
|
||||||
; HL (left) and DE (right)
|
; HL (left) and DE (right)
|
||||||
_resolveLeftAndRight:
|
_resolveLeftAndRight:
|
||||||
; special case: is (HL) zero? If yes, it means that our left operand
|
|
||||||
; is empty. consider it as 0
|
|
||||||
ld ix, 0 ; pre-set to 0
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
jr z, .skip
|
|
||||||
; Parse left operand in (HL)
|
|
||||||
call parseExpr
|
call parseExpr
|
||||||
ret nz ; return immediately if error
|
ret nz ; return immediately if error
|
||||||
.skip:
|
|
||||||
; Now we have parsed everything to the left and we have its result in
|
; Now we have parsed everything to the left and we have its result in
|
||||||
; IX. What we need to do now is the same thing on (DE) and then apply
|
; IX. What we need to do now is the same thing on (DE) and then apply
|
||||||
; the + operator. Let's save IX somewhere and parse this.
|
; the + operator. Let's save IX somewhere and parse this.
|
||||||
|
@ -1,25 +1,4 @@
|
|||||||
|
|
||||||
; Same as fmtDecimal, but DE is considered a signed number
|
|
||||||
fmtDecimalS:
|
|
||||||
bit 7, d
|
|
||||||
jr z, fmtDecimal ; unset, not negative
|
|
||||||
; Invert DE. spit '-', unset bit, then call fmtDecimal
|
|
||||||
push de
|
|
||||||
ld a, '-'
|
|
||||||
ld (hl), a
|
|
||||||
inc hl
|
|
||||||
ld a, d
|
|
||||||
cpl
|
|
||||||
ld d, a
|
|
||||||
ld a, e
|
|
||||||
cpl
|
|
||||||
ld e, a
|
|
||||||
inc de
|
|
||||||
call fmtDecimal
|
|
||||||
dec hl
|
|
||||||
pop de
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Format the number in DE into the string at (HL) in a decimal form.
|
; Format the number in DE into the string at (HL) in a decimal form.
|
||||||
; Null-terminated. DE is considered an unsigned number.
|
; Null-terminated. DE is considered an unsigned number.
|
||||||
fmtDecimal:
|
fmtDecimal:
|
||||||
|
@ -57,18 +57,3 @@ memory starting at address 0 and then run the code until it halts. The exit
|
|||||||
code of the program is the value of `A` when the program halts.
|
code of the program is the value of `A` when the program halts.
|
||||||
|
|
||||||
This is used for unit tests.
|
This is used for unit tests.
|
||||||
|
|
||||||
## Problems?
|
|
||||||
|
|
||||||
If the libz80-wrapped zasm executable works badly (hangs, spew garbage, etc.),
|
|
||||||
it's probably because you've broken your bootstrap binaries. They're easy to
|
|
||||||
mistakenly break. To verify if you've done that, look at your git status. If
|
|
||||||
`kernel.bin` or `zasm.bin` are modified, try resetting them and then run
|
|
||||||
`make clean all`. Things should go better afterwards.
|
|
||||||
|
|
||||||
If that doesn't work, there's also the nuclear option of `git reset --hard`
|
|
||||||
and `git clean -fxd`.
|
|
||||||
|
|
||||||
If that still doesn't work, it might be because the current commit you're on
|
|
||||||
is broken, but that is rather rare: the repo on Github is plugged on Travis
|
|
||||||
and it checks that everything is smooth.
|
|
||||||
|
@ -149,8 +149,6 @@ testParseExpr:
|
|||||||
call .testEQ
|
call .testEQ
|
||||||
ld iy, .t7
|
ld iy, .t7
|
||||||
call .testEQ
|
call .testEQ
|
||||||
ld iy, .t8
|
|
||||||
call .testEQ
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.testEQ:
|
.testEQ:
|
||||||
@ -188,9 +186,6 @@ testParseExpr:
|
|||||||
.t7:
|
.t7:
|
||||||
.dw 0xcfb8
|
.dw 0xcfb8
|
||||||
.db "0x99f7{3", 0
|
.db "0x99f7{3", 0
|
||||||
.t8:
|
|
||||||
.dw 0xffff
|
|
||||||
.db "-1", 0
|
|
||||||
|
|
||||||
nexttest:
|
nexttest:
|
||||||
ld a, (testNum)
|
ld a, (testNum)
|
||||||
|
@ -11,7 +11,6 @@ test:
|
|||||||
ld sp, 0xffff
|
ld sp, 0xffff
|
||||||
|
|
||||||
call testFmtDecimal
|
call testFmtDecimal
|
||||||
call testFmtDecimalS
|
|
||||||
|
|
||||||
; success
|
; success
|
||||||
xor a
|
xor a
|
||||||
@ -56,30 +55,6 @@ testFmtDecimal:
|
|||||||
.dw 0xffff
|
.dw 0xffff
|
||||||
.db "65535", 0
|
.db "65535", 0
|
||||||
|
|
||||||
testFmtDecimalS:
|
|
||||||
ld ix, .t1
|
|
||||||
call .test
|
|
||||||
ld ix, .t2
|
|
||||||
call .test
|
|
||||||
ret
|
|
||||||
.test:
|
|
||||||
ld e, (ix)
|
|
||||||
ld d, (ix+1)
|
|
||||||
ld hl, sandbox
|
|
||||||
call fmtDecimalS
|
|
||||||
ld hl, sandbox
|
|
||||||
push ix \ pop de
|
|
||||||
inc de \ inc de
|
|
||||||
call strcmp
|
|
||||||
jp nz, fail
|
|
||||||
jp nexttest
|
|
||||||
.t1:
|
|
||||||
.dw 1234
|
|
||||||
.db "1234", 0
|
|
||||||
.t2:
|
|
||||||
.dw 0-1234
|
|
||||||
.db "-1234", 0
|
|
||||||
|
|
||||||
nexttest:
|
nexttest:
|
||||||
ld a, (testNum)
|
ld a, (testNum)
|
||||||
inc a
|
inc a
|
||||||
|
Loading…
Reference in New Issue
Block a user