duskos

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

commit 5e87344df8229230aa833a4e7e7727387480733f
parent 1f831dd2f075de86b240870db86e5eac1531d091
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 17 Mar 2023 09:06:04 -0400

hal i386: local variables work

EAX=12345678 at bye

Diffstat:
Mfs/xcomp/bootlo2.fs | 30+++++++++++++++++++++++++++++-
Mfs/xcomp/i386/kernel.fs | 4++--
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/fs/xcomp/bootlo2.fs b/fs/xcomp/bootlo2.fs @@ -123,4 +123,32 @@ code ^ -1 xorn, exit, code scnt dup, PSP) lea, ] PSTOP -^ >> >> 1- ; code rcnt dup, RSP) lea, ] RSTOP -^ >> >> ; -: foo rcnt bye ; foo +: while [compile] if swap ; immediate +: repeat [compile] again [compile] then ; immediate + +: case ( -- then-stopgap ) 0 [compile] >r ; immediate +: of ( -- jump-addr ) [compile] r@ word compword [compile] if ; immediate +: endof [compile] else ; immediate +: endcase ( then-stopgap jump1? jump2? ... jumpn? -- ) + ?dup if begin [compile] then ?dup not until then [compile] rdrop ; immediate + +\ Local variables + beginning of compiling words +code (cell) r> exit, +: create code compile (cell) ; +: const code litn exit, ; +4 const CELLSZ + +\ execword param: addr +\ compileword param: HAL operand +create toptr 0 , \ pointer to 8b struct [execword, compileword] +: _@, ( operand -- ) dup, @, ; :16b dup, 16b) @, ; :8b dup, 8b) @, ; +create toptrdef ' @ , ' _@, , +: toptr@ ( -- w ) + 0 toptr @! ?dup not if toptrdef then + compiling if CELLSZ + then @ findmod ; +: var, ( off -- ) RSP) swap [rcnt] @ neg CELLSZ - -^ +) toptr@ execute ; +: V1 0 var, ; immediate : V2 4 var, ; immediate +: V3 8 var, ; immediate : V4 12 var, ; immediate + +create hello $12345678 , +: foo hello @ >r V1 bye ; foo diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs @@ -80,7 +80,7 @@ lblnextmeta xconst nextmeta pc to lblcompiling 0 , xcode compiling - dup, ax lblcompiling m) mov, ret, + xdup, ax lblcompiling m) mov, ret, xcode bye \ temporary word dx 42 i) mov, @@ -244,7 +244,7 @@ pc to L2 \ 16b or 8b ax $b600 i) or, L1 absjmp, xcode @, ( operand -- ) \ ax operand mov, ax $20000 i) test, L2 abs>rel jnz, - ax $fffffeff i) test, L2 abs>rel jz, + ax $100 i) test, L2 abs>rel jz, ax $8a00 i) or, L1 absjmp, xcode @!, ( operand -- ) \ operand ax xchg,