1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 08:20:57 +11:00

Compare commits

..

No commits in common. "0b8c8c9ca04172e7ea7284a52b1b3bec45b83d1a" and "b8ea5156123138db029f659868b908f17a777552" have entirely different histories.

20 changed files with 69 additions and 96 deletions

View File

@ -7,10 +7,10 @@ context, branching doesn't work.
f IF A ELSE B THEN: if f is true, execute A, if false, execute
B. ELSE is optional.
[IF] .. [THEN]: Meta-IF. Works outside definitions. No [ELSE].
BEGIN .. f UNTIL: if f is false, branch to BEGIN.
BEGIN .. AGAIN: Always branch to BEGIN.
x y DO .. LOOP: LOOP increments y. if y != x, branch to DO.
(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. (cont.)

11
blk/043
View File

@ -1,8 +1,4 @@
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.
(cont.)
(br) -- Branches by the number specified in the 2
following bytes. Can be negative.
(?br) f -- Branch if f is false.
@ -13,3 +9,8 @@ have to consume it to avoid PSP leak.
ABORT -- Resets PS and RS and returns to interpreter.
ABORT" x" -- *I* Compiles a ." followed by a ABORT.
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.

View File

@ -1,5 +0,0 @@
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.

View File

@ -1,8 +0,0 @@
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
View File

@ -1,13 +0,0 @@
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

View File

@ -3,7 +3,7 @@ OUT [nA, (C)r] IN [An, r(C)]
SET [br] RES [br] BIT [br]
RL [r] RLC [r] SLA [r] RLA RLCA
RR [r] RRC [r] SRL [r] RRA RRCA
CALL [nn] RST [n] DJNZ
CALL [nn] DJNZ
JP [nn, (HL), (IX), (IY)]
JR [, Z, NZ, C, NC]

View File

@ -1,14 +1,16 @@
: LDdd(nn), ( dd nn -- )
( dd nn -- )
: LDdd(nn),
0xed A,
SWAP <<4 0x4b OR A,
A,,
;
: LD(nn)dd, ( nn dd -- )
( nn dd -- )
: LD(nn)dd,
0xed A,
<<4 0x43 OR A,
A,,
;
: RSTn, 0xc7 OR A, ;
: JP(IX), IX DROP JP(HL), ;
: JP(IY), IY DROP JP(HL), ;

View File

@ -6,4 +6,3 @@
: PUSHZ, BC 0 LDddnn, IFZ, BC INCss, THEN, BC PUSHqq, ;
: HLZ, A H LDrr, L ORr, ;
: DEZ, A D LDrr, E ORr, ;
: LDDE(HL), E (HL) LDrr, HL INCss, D (HL) LDrr, ;

10
blk/260
View File

@ -2,10 +2,7 @@ Cross compilation program
This programs allows cross compilation of boot binary and
icore. Run "262 LOAD" right before your cross compilation and
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.
then set XCURRENT to CURRENT and XCOFF to H@.
This redefines defining words to achieve cross compilation.
The goal is two-fold:
@ -13,4 +10,7 @@ The goal is two-fold:
1. Add an offset to all word references in definitions.
2. Don't shadow important words we need right now.
(cont.)
Words overrides like ":", "IMMEDIATE" and "CODE" are not
automatically shadowed to allow the harmless inclusion of
this unit. This shadowing has to take place in your xcomp
configuration. (cont.)

View File

@ -1,9 +1,6 @@
Words overrides like ":", "IMMEDIATE" and "CODE" are not
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
(cont.)
See example in /emul/forth/xcomp.fs
Why limit ourselves to icore? Oh, I've tried cross-compiling
the whole shebang. I tried. And failed. Too dynamic.

View File

@ -1,4 +1,5 @@
VARIABLE XCURRENT
VARIABLE XOFF
: XCON XCURRENT CURRENT* ! ;
: XCOFF 0x02 RAM+ CURRENT* ! ;

View File

@ -4,7 +4,7 @@
XCURRENT @ SWAP ( xcur w ) _find ( a f )
IF ( a )
DUP IMMED? IF ABORT THEN
DUP ORG @ > IF ORG @ - BIN( @ + THEN ,
DUP XOFF @ > IF XOFF @ - THEN ,
ELSE ( w )
0x02 RAM+ @ SWAP ( cur w ) _find ( a f )
IF DUP IMMED? NOT IF ABORT THEN EXECUTE

11
blk/301
View File

@ -1,10 +1,7 @@
L3 BSET PC ORG @ 0x34 + ! ( execute )
EXDEHL, ( HL now points to wordref )
( We don't apply BIN( reliably on stable ABI stuff, we
might need to adjust addr. Ugly, but well... )
BIN( @ [IF]
A XORr, H ORr, IFZ, H BIN( @ 256 / LDrn,
[THEN]
L3 BSET
PC ORG @ 0x34 + ! ( execute )
( DE points to wordref )
EXDEHL,
E (HL) LDrr,
D BIN( @ 256 / LDrn,
EXDEHL,

10
blk/302
View File

@ -1,12 +1,16 @@
L1 BSET PC ORG @ 0x0f + ! ( compiledWord )
L1 BSET
PC ORG @ 0x0f + ! ( compiledWord )
( 1. Push current IP to RS
2. Set new IP to the second atom of the list
3. Execute the first atom of the list. )
IY PUSHqq, HL POPqq, ( <-- IP )
0x11 BCALL, ( 11 == pushRS )
EXDEHL, ( HL points to PFA )
( While we inc, dereference into DE for execute call later. )
LDDE(HL),
( While we increase, dereference into DE for execute call
later. )
E (HL) LDrr,
HL INCss,
D (HL) LDrr,
HL INCss,
HL PUSHqq, IY POPqq, ( --> IP )
JR, L3 BWR ( execute-B301 )

View File

@ -6,7 +6,3 @@
H@ 2- ( push a. -2 for allot offset )
; IMMEDIATE
: [IF]
IF EXIT THEN
LIT< [THEN] BEGIN DUP WORD S= UNTIL DROP ;
: [THEN] ;

Binary file not shown.

View File

@ -10,11 +10,12 @@
CURRENT @ XCURRENT !
H@ 256 /MOD 2 PC! 2 PC!
H@ XOFF !
282 LOAD ( boot.z80 )
393 LOAD ( icore )
(entry) _
( Update LATEST )
PC ORG @ 8 + !
H@ XOFF @ - XOFF @ 8 + !
," CURRENT @ HERE ! "
," : EMIT 0 PC! ; "
," : KEY 0 PC@ ; "

View File

@ -16,13 +16,14 @@ RAMSTART 0x70 + CONSTANT ACIA_MEM
CURRENT @ XCURRENT !
H@ 256 /MOD 2 PC! 2 PC!
H@ XOFF !
282 LOAD ( boot.z80 )
352 LOAD ( acia.z80 )
372 LOAD ( sdc.z80 )
393 LOAD ( icore )
(entry) _
( Update LATEST )
PC ORG @ 8 + !
H@ XOFF @ - XOFF @ 8 + !
422 441 XPACKR ( core cmp )
446 452 XPACKR ( parse )
358 360 XPACKR ( acia.fs )

View File

@ -1,8 +1,30 @@
TARGET = stage1.bin
EDIR = ../../emul
STAGE2 = $(EDIR)/stage2
SHELLAPPS = zasm ed
APPTARGETS = ${SHELLAPPS:%=cfsin/%}
CFSTARGETS = $(APPTARGETS) cfsin/user.h
TARGET = os.bin
BASEDIR = ../..
ZASM = $(BASEDIR)/emul/zasm/zasm
KERNEL = $(BASEDIR)/kernel
APPS = $(BASEDIR)/apps
CFSPACK = $(BASEDIR)/tools/cfspack/cfspack
.PHONY: all
all: $(TARGET)
$(TARGET): xcomp.fs $(STAGE2)
cat xcomp.fs | $(STAGE2) > $@
all: $(TARGET) floppy.cfs
$(TARGET): glue.asm
$(ZASM) $(KERNEL) $(APPS) < glue.asm > $@
$(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)

View File

@ -1,22 +0,0 @@
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!