mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 10:20:55 +11:00
Compare commits
5 Commits
b8ea515612
...
0b8c8c9ca0
Author | SHA1 | Date | |
---|---|---|---|
|
0b8c8c9ca0 | ||
|
61b2e02351 | ||
|
838548843e | ||
|
4501313410 | ||
|
f97df4614e |
8
blk/042
8
blk/042
@ -7,10 +7,10 @@ context, branching doesn't work.
|
|||||||
|
|
||||||
f IF A ELSE B THEN: if f is true, execute A, if false, execute
|
f IF A ELSE B THEN: if f is true, execute A, if false, execute
|
||||||
B. ELSE is optional.
|
B. ELSE is optional.
|
||||||
|
[IF] .. [THEN]: Meta-IF. Works outside definitions. No [ELSE].
|
||||||
BEGIN .. f UNTIL: if f is false, branch to BEGIN.
|
BEGIN .. f UNTIL: if f is false, branch to BEGIN.
|
||||||
BEGIN .. AGAIN: Always branch to BEGIN.
|
BEGIN .. AGAIN: Always branch to BEGIN.
|
||||||
x y DO .. LOOP: LOOP increments y. if y != x, branch to DO.
|
x y DO .. LOOP: LOOP increments y. if y != x, branch to DO.
|
||||||
x CASE y OF A ENDOF z OF B ENDOF C ENDCASE: If x == y, execute
|
|
||||||
A, if x == z, execute B. Otherwise, execute C. x is dropped
|
|
||||||
in case of an OF match, *but it is kept if it reaches C*. You
|
(cont.)
|
||||||
have to consume it to avoid PSP leak. (cont.)
|
|
||||||
|
11
blk/043
11
blk/043
@ -1,4 +1,8 @@
|
|||||||
(cont.)
|
x CASE y OF A ENDOF z OF B ENDOF C ENDCASE: If x == y, execute
|
||||||
|
A, if x == z, execute B. Otherwise, execute C. x is dropped
|
||||||
|
in case of an OF match, *but it is kept if it reaches C*. You
|
||||||
|
have to consume it to avoid PSP leak.
|
||||||
|
|
||||||
(br) -- Branches by the number specified in the 2
|
(br) -- Branches by the number specified in the 2
|
||||||
following bytes. Can be negative.
|
following bytes. Can be negative.
|
||||||
(?br) f -- Branch if f is false.
|
(?br) f -- Branch if f is false.
|
||||||
@ -9,8 +13,3 @@
|
|||||||
ABORT -- Resets PS and RS and returns to interpreter.
|
ABORT -- Resets PS and RS and returns to interpreter.
|
||||||
ABORT" x" -- *I* Compiles a ." followed by a ABORT.
|
ABORT" x" -- *I* Compiles a ." followed by a ABORT.
|
||||||
EXECUTE a -- Execute wordref at addr a
|
EXECUTE a -- Execute wordref at addr a
|
||||||
INTERPRET -- Get a line from stdin, compile it in tmp memory,
|
|
||||||
then execute the compiled contents.
|
|
||||||
LEAVE -- In a DO..LOOP, exit at the next LOOP call.
|
|
||||||
QUIT -- Return to interpreter prompt immediately
|
|
||||||
EXIT! -- Exit current INTERPRET loop.
|
|
||||||
|
5
blk/044
Normal file
5
blk/044
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
INTERPRET -- Get a line from stdin, compile it in tmp memory,
|
||||||
|
then execute the compiled contents.
|
||||||
|
LEAVE -- In a DO..LOOP, exit at the next LOOP call.
|
||||||
|
QUIT -- Return to interpreter prompt immediately
|
||||||
|
EXIT! -- Exit current INTERPRET loop.
|
8
blk/160
Normal file
8
blk/160
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
TRS-80 Drivers
|
||||||
|
|
||||||
|
Drivers for the TRS-80 keyboard, video and floppy. At the
|
||||||
|
moment, they are thin layer over the drivers provided by
|
||||||
|
TRSDOS' SVC.
|
||||||
|
|
||||||
|
Load the Z80 words with "162 LOAD" and the high level part
|
||||||
|
with "164 LOAD".
|
13
blk/162
Normal file
13
blk/162
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
CODE KEY
|
||||||
|
A 0x01 LDrn, ( @KEY )
|
||||||
|
0x28 RSTn,
|
||||||
|
L A LDrr, H 0 LDrn,
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
||||||
|
CODE EMIT
|
||||||
|
BC POPqq, ( c == @DSP arg )
|
||||||
|
chkPS,
|
||||||
|
A 0x02 LDrn, ( @DSP )
|
||||||
|
0x28 RSTn,
|
||||||
|
;CODE
|
2
blk/209
2
blk/209
@ -3,7 +3,7 @@ OUT [nA, (C)r] IN [An, r(C)]
|
|||||||
SET [br] RES [br] BIT [br]
|
SET [br] RES [br] BIT [br]
|
||||||
RL [r] RLC [r] SLA [r] RLA RLCA
|
RL [r] RLC [r] SLA [r] RLA RLCA
|
||||||
RR [r] RRC [r] SRL [r] RRA RRCA
|
RR [r] RRC [r] SRL [r] RRA RRCA
|
||||||
CALL [nn] DJNZ
|
CALL [nn] RST [n] DJNZ
|
||||||
JP [nn, (HL), (IX), (IY)]
|
JP [nn, (HL), (IX), (IY)]
|
||||||
JR [, Z, NZ, C, NC]
|
JR [, Z, NZ, C, NC]
|
||||||
|
|
||||||
|
8
blk/242
8
blk/242
@ -1,16 +1,14 @@
|
|||||||
( dd nn -- )
|
: LDdd(nn), ( dd nn -- )
|
||||||
: LDdd(nn),
|
|
||||||
0xed A,
|
0xed A,
|
||||||
SWAP <<4 0x4b OR A,
|
SWAP <<4 0x4b OR A,
|
||||||
A,,
|
A,,
|
||||||
;
|
;
|
||||||
|
: LD(nn)dd, ( nn dd -- )
|
||||||
( nn dd -- )
|
|
||||||
: LD(nn)dd,
|
|
||||||
0xed A,
|
0xed A,
|
||||||
<<4 0x43 OR A,
|
<<4 0x43 OR A,
|
||||||
A,,
|
A,,
|
||||||
;
|
;
|
||||||
|
: RSTn, 0xc7 OR A, ;
|
||||||
|
|
||||||
: JP(IX), IX DROP JP(HL), ;
|
: JP(IX), IX DROP JP(HL), ;
|
||||||
: JP(IY), IY DROP JP(HL), ;
|
: JP(IY), IY DROP JP(HL), ;
|
||||||
|
1
blk/249
1
blk/249
@ -6,3 +6,4 @@
|
|||||||
: PUSHZ, BC 0 LDddnn, IFZ, BC INCss, THEN, BC PUSHqq, ;
|
: PUSHZ, BC 0 LDddnn, IFZ, BC INCss, THEN, BC PUSHqq, ;
|
||||||
: HLZ, A H LDrr, L ORr, ;
|
: HLZ, A H LDrr, L ORr, ;
|
||||||
: DEZ, A D LDrr, E ORr, ;
|
: DEZ, A D LDrr, E ORr, ;
|
||||||
|
: LDDE(HL), E (HL) LDrr, HL INCss, D (HL) LDrr, ;
|
||||||
|
10
blk/260
10
blk/260
@ -2,7 +2,10 @@ Cross compilation program
|
|||||||
|
|
||||||
This programs allows cross compilation of boot binary and
|
This programs allows cross compilation of boot binary and
|
||||||
icore. Run "262 LOAD" right before your cross compilation and
|
icore. Run "262 LOAD" right before your cross compilation and
|
||||||
then set XCURRENT to CURRENT and XCOFF to H@.
|
then set XCURRENT to CURRENT.
|
||||||
|
|
||||||
|
This unit depends on a properly initialized z80a with ORG and
|
||||||
|
BIN( set. That is how we determine compilation offsets.
|
||||||
|
|
||||||
This redefines defining words to achieve cross compilation.
|
This redefines defining words to achieve cross compilation.
|
||||||
The goal is two-fold:
|
The goal is two-fold:
|
||||||
@ -10,7 +13,4 @@ The goal is two-fold:
|
|||||||
1. Add an offset to all word references in definitions.
|
1. Add an offset to all word references in definitions.
|
||||||
2. Don't shadow important words we need right now.
|
2. Don't shadow important words we need right now.
|
||||||
|
|
||||||
Words overrides like ":", "IMMEDIATE" and "CODE" are not
|
(cont.)
|
||||||
automatically shadowed to allow the harmless inclusion of
|
|
||||||
this unit. This shadowing has to take place in your xcomp
|
|
||||||
configuration. (cont.)
|
|
||||||
|
9
blk/261
9
blk/261
@ -1,6 +1,9 @@
|
|||||||
(cont.)
|
Words overrides like ":", "IMMEDIATE" and "CODE" are not
|
||||||
See example in /emul/forth/xcomp.fs
|
automatically shadowed to allow the harmless inclusion of
|
||||||
|
this unit. This shadowing has to take place in your xcomp
|
||||||
|
configuration.
|
||||||
|
|
||||||
|
See example in /emul/xcomp.fs
|
||||||
|
|
||||||
Why limit ourselves to icore? Oh, I've tried cross-compiling
|
Why limit ourselves to icore? Oh, I've tried cross-compiling
|
||||||
the whole shebang. I tried. And failed. Too dynamic.
|
the whole shebang. I tried. And failed. Too dynamic.
|
||||||
|
|
||||||
|
1
blk/263
1
blk/263
@ -1,5 +1,4 @@
|
|||||||
VARIABLE XCURRENT
|
VARIABLE XCURRENT
|
||||||
VARIABLE XOFF
|
|
||||||
|
|
||||||
: XCON XCURRENT CURRENT* ! ;
|
: XCON XCURRENT CURRENT* ! ;
|
||||||
: XCOFF 0x02 RAM+ CURRENT* ! ;
|
: XCOFF 0x02 RAM+ CURRENT* ! ;
|
||||||
|
2
blk/265
2
blk/265
@ -4,7 +4,7 @@
|
|||||||
XCURRENT @ SWAP ( xcur w ) _find ( a f )
|
XCURRENT @ SWAP ( xcur w ) _find ( a f )
|
||||||
IF ( a )
|
IF ( a )
|
||||||
DUP IMMED? IF ABORT THEN
|
DUP IMMED? IF ABORT THEN
|
||||||
DUP XOFF @ > IF XOFF @ - THEN ,
|
DUP ORG @ > IF ORG @ - BIN( @ + THEN ,
|
||||||
ELSE ( w )
|
ELSE ( w )
|
||||||
0x02 RAM+ @ SWAP ( cur w ) _find ( a f )
|
0x02 RAM+ @ SWAP ( cur w ) _find ( a f )
|
||||||
IF DUP IMMED? NOT IF ABORT THEN EXECUTE
|
IF DUP IMMED? NOT IF ABORT THEN EXECUTE
|
||||||
|
11
blk/301
11
blk/301
@ -1,7 +1,10 @@
|
|||||||
L3 BSET
|
L3 BSET PC ORG @ 0x34 + ! ( execute )
|
||||||
PC ORG @ 0x34 + ! ( execute )
|
EXDEHL, ( HL now points to wordref )
|
||||||
( DE points to wordref )
|
( We don't apply BIN( reliably on stable ABI stuff, we
|
||||||
EXDEHL,
|
might need to adjust addr. Ugly, but well... )
|
||||||
|
BIN( @ [IF]
|
||||||
|
A XORr, H ORr, IFZ, H BIN( @ 256 / LDrn,
|
||||||
|
[THEN]
|
||||||
E (HL) LDrr,
|
E (HL) LDrr,
|
||||||
D BIN( @ 256 / LDrn,
|
D BIN( @ 256 / LDrn,
|
||||||
EXDEHL,
|
EXDEHL,
|
||||||
|
10
blk/302
10
blk/302
@ -1,16 +1,12 @@
|
|||||||
L1 BSET
|
L1 BSET PC ORG @ 0x0f + ! ( compiledWord )
|
||||||
PC ORG @ 0x0f + ! ( compiledWord )
|
|
||||||
( 1. Push current IP to RS
|
( 1. Push current IP to RS
|
||||||
2. Set new IP to the second atom of the list
|
2. Set new IP to the second atom of the list
|
||||||
3. Execute the first atom of the list. )
|
3. Execute the first atom of the list. )
|
||||||
IY PUSHqq, HL POPqq, ( <-- IP )
|
IY PUSHqq, HL POPqq, ( <-- IP )
|
||||||
0x11 BCALL, ( 11 == pushRS )
|
0x11 BCALL, ( 11 == pushRS )
|
||||||
EXDEHL, ( HL points to PFA )
|
EXDEHL, ( HL points to PFA )
|
||||||
( While we increase, dereference into DE for execute call
|
( While we inc, dereference into DE for execute call later. )
|
||||||
later. )
|
LDDE(HL),
|
||||||
E (HL) LDrr,
|
|
||||||
HL INCss,
|
|
||||||
D (HL) LDrr,
|
|
||||||
HL INCss,
|
HL INCss,
|
||||||
HL PUSHqq, IY POPqq, ( --> IP )
|
HL PUSHqq, IY POPqq, ( --> IP )
|
||||||
JR, L3 BWR ( execute-B301 )
|
JR, L3 BWR ( execute-B301 )
|
||||||
|
4
blk/426
4
blk/426
@ -6,3 +6,7 @@
|
|||||||
H@ 2- ( push a. -2 for allot offset )
|
H@ 2- ( push a. -2 for allot offset )
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
|
||||||
|
: [IF]
|
||||||
|
IF EXIT THEN
|
||||||
|
LIT< [THEN] BEGIN DUP WORD S= UNTIL DROP ;
|
||||||
|
: [THEN] ;
|
||||||
|
BIN
emul/stage0.bin
BIN
emul/stage0.bin
Binary file not shown.
@ -10,12 +10,11 @@
|
|||||||
CURRENT @ XCURRENT !
|
CURRENT @ XCURRENT !
|
||||||
|
|
||||||
H@ 256 /MOD 2 PC! 2 PC!
|
H@ 256 /MOD 2 PC! 2 PC!
|
||||||
H@ XOFF !
|
|
||||||
282 LOAD ( boot.z80 )
|
282 LOAD ( boot.z80 )
|
||||||
393 LOAD ( icore )
|
393 LOAD ( icore )
|
||||||
(entry) _
|
(entry) _
|
||||||
( Update LATEST )
|
( Update LATEST )
|
||||||
H@ XOFF @ - XOFF @ 8 + !
|
PC ORG @ 8 + !
|
||||||
," CURRENT @ HERE ! "
|
," CURRENT @ HERE ! "
|
||||||
," : EMIT 0 PC! ; "
|
," : EMIT 0 PC! ; "
|
||||||
," : KEY 0 PC@ ; "
|
," : KEY 0 PC@ ; "
|
||||||
|
@ -16,14 +16,13 @@ RAMSTART 0x70 + CONSTANT ACIA_MEM
|
|||||||
CURRENT @ XCURRENT !
|
CURRENT @ XCURRENT !
|
||||||
|
|
||||||
H@ 256 /MOD 2 PC! 2 PC!
|
H@ 256 /MOD 2 PC! 2 PC!
|
||||||
H@ XOFF !
|
|
||||||
282 LOAD ( boot.z80 )
|
282 LOAD ( boot.z80 )
|
||||||
352 LOAD ( acia.z80 )
|
352 LOAD ( acia.z80 )
|
||||||
372 LOAD ( sdc.z80 )
|
372 LOAD ( sdc.z80 )
|
||||||
393 LOAD ( icore )
|
393 LOAD ( icore )
|
||||||
(entry) _
|
(entry) _
|
||||||
( Update LATEST )
|
( Update LATEST )
|
||||||
H@ XOFF @ - XOFF @ 8 + !
|
PC ORG @ 8 + !
|
||||||
422 441 XPACKR ( core cmp )
|
422 441 XPACKR ( core cmp )
|
||||||
446 452 XPACKR ( parse )
|
446 452 XPACKR ( parse )
|
||||||
358 360 XPACKR ( acia.fs )
|
358 360 XPACKR ( acia.fs )
|
||||||
|
@ -1,30 +1,8 @@
|
|||||||
SHELLAPPS = zasm ed
|
TARGET = stage1.bin
|
||||||
APPTARGETS = ${SHELLAPPS:%=cfsin/%}
|
EDIR = ../../emul
|
||||||
CFSTARGETS = $(APPTARGETS) cfsin/user.h
|
STAGE2 = $(EDIR)/stage2
|
||||||
TARGET = os.bin
|
|
||||||
BASEDIR = ../..
|
|
||||||
ZASM = $(BASEDIR)/emul/zasm/zasm
|
|
||||||
KERNEL = $(BASEDIR)/kernel
|
|
||||||
APPS = $(BASEDIR)/apps
|
|
||||||
CFSPACK = $(BASEDIR)/tools/cfspack/cfspack
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(TARGET) floppy.cfs
|
all: $(TARGET)
|
||||||
$(TARGET): glue.asm
|
$(TARGET): xcomp.fs $(STAGE2)
|
||||||
$(ZASM) $(KERNEL) $(APPS) < glue.asm > $@
|
cat xcomp.fs | $(STAGE2) > $@
|
||||||
|
|
||||||
$(CFSPACK):
|
|
||||||
make -C $(BASEDIR)/tools/cfspack
|
|
||||||
|
|
||||||
floppy.cfs: $(CFSTARGETS) $(CFSPACK)
|
|
||||||
$(CFSPACK) cfsin > $@
|
|
||||||
|
|
||||||
$(APPTARGETS):
|
|
||||||
$(ZASM) $(KERNEL) $(APPS) user.h < $(APPS)/${@:cfsin/%=%}/glue.asm > $@
|
|
||||||
|
|
||||||
cfsin/user.h: user.h
|
|
||||||
cp user.h $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f $(CFSTARGETS) floppy.cfs $(TARGET)
|
|
||||||
|
22
recipes/trs80/xcomp.fs
Normal file
22
recipes/trs80/xcomp.fs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
0x6000 CONSTANT RAMSTART
|
||||||
|
0xf000 CONSTANT RS_ADDR
|
||||||
|
212 LOAD ( z80 assembler )
|
||||||
|
262 LOAD ( xcomp )
|
||||||
|
: CODE XCODE ;
|
||||||
|
: IMMEDIATE XIMM ;
|
||||||
|
: (entry) (xentry) ;
|
||||||
|
: : [ ' X: , ] ;
|
||||||
|
|
||||||
|
CURRENT @ XCURRENT !
|
||||||
|
|
||||||
|
H@ 256 /MOD 2 PC! 2 PC!
|
||||||
|
0x3000 BIN( !
|
||||||
|
282 LOAD ( boot.z80 )
|
||||||
|
162 LOAD ( trs80.z80 )
|
||||||
|
393 LOAD ( icore )
|
||||||
|
(entry) _
|
||||||
|
( Update LATEST )
|
||||||
|
PC ORG @ 8 + !
|
||||||
|
422 463 XPACKR ( core cmp print parse readln fmt )
|
||||||
|
," : _ RDLN$ (ok) ; _ "
|
||||||
|
H@ 256 /MOD 2 PC! 2 PC!
|
Loading…
Reference in New Issue
Block a user