duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 6823fbde4e51f30d570479fb9b80e95a4f375691
parent 7258462c43dfb4c5845070c88039473e735d8f39
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 18 Mar 2023 11:20:41 -0400

hal: begin creating the "high level layer"

I won't try fixing i386 DuskCC, it's needless work. I'll go straight to a
"pure HAL" CC. To that end, I begin re-writing DuskCC VM tests in HAL. We can
already see that the HAL is a more straightforward API than DuskCC VM.

Diffstat:
MMakefile | 8++++----
Afs/asm/hal.fs | 2++
Afs/tests/asm/hal.fs | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposix/hal.fs | 9+++++++++
4 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ TARGETS = dusk dis -BOOTFS_SRC = fs/xcomp/bootlo.fs posix/glue.fs fs/xcomp/boothi.fs +BOOTFS_SRC = fs/xcomp/bootlo.fs posix/hal.fs posix/glue.fs fs/xcomp/boothi.fs ALLSRCS = $(shell find fs) QEMU_FLAGS = -accel kvm -accel tcg -rtc base=utc QEMU_DRVOPTS = format=raw,index=0,if=ide @@ -61,9 +61,9 @@ testlib: dusk testcc: dusk echo "' byefail ' abort realias f<< tests/comp/c/all.fs bye" | ./dusk || (echo; exit 1) -.PHONY: testemul -testemul: dusk - echo "' byefail ' abort realias f<< tests/emul/all.fs bye" | ./dusk || (echo; exit 1) +.PHONY: testhal +testhal: dusk + echo "' byefail ' abort realias f<< tests/asm/hal.fs bye" | ./dusk || (echo; exit 1) .PHONY: testtext testtext: dusk diff --git a/fs/asm/hal.fs b/fs/asm/hal.fs @@ -0,0 +1,2 @@ +\ The HAL is provided by assemblers +ARCH S" i386" s= [if] f<< /asm/i386.fs [then] diff --git a/fs/tests/asm/hal.fs b/fs/tests/asm/hal.fs @@ -0,0 +1,53 @@ +?f<< /tests/harness.fs +?f<< /asm/hal.fs +testbegin +code test1 ( a b -- a-b ) + PSP) @!, + PSP) -, + nip, exit, +54 12 test1 42 #eq + +\ use RSP as local variables +code test2 ( -- n ) + dup, -8 rs+, + 42 LIT>W, RSP) !, + 5 LIT>W, RSP) 4 +) !, + RSP) @, + RSP) 4 +) +, + 8 rs+, exit, +test2 47 #eq + +\ simple expression +code test3 ( -- n ) + dup, -4 rs+, + 2 LIT>W, RSP) !, + 3 LIT>W, RSP) *, + 1 W+n, + 4 rs+, exit, +test3 7 #eq + +\ expression involving push/popping intermediate results +code test4 ( -- n ) \ 2 * 3 + 2 + dup, + 3 LIT>W, + -1 W+n, + dup, + 2 LIT>W, + dup, + 3 LIT>W, + PSP) *, nip, + PSP) +, nip, + exit, +test4 8 #eq + +\ variable reference and dereference +code test5 ( -- n ) + dup, -8 rs+, + 42 LIT>W, RSP) !, + RSP) lea, + RSP) 4 +) !, \ reference to RS+0 in RS+4 + \ Now, let's dereference + RSP) 4 +) [@], + 8 rs+, exit, +test5 42 #eq +testend diff --git a/posix/hal.fs b/posix/hal.fs @@ -0,0 +1,9 @@ +\ POSIX HAL +\ The POSIX VM doesn't have an assembler, but it still needs a HAL. This is +\ what provides it (in an inefficient manner). It is included after bootlo. + +create _tmp 0 , +: >tmp _tmp m) !, ; +: tmp> _tmp m) @, ; +: -, ( operand -- ) >tmp @, dup, tmp> compile -^ ; +: *, ( operand -- ) >tmp @, dup, tmp> compile * ;