commit a3e95d2d208c8ed76c9774dcfbeb2a5d4e4fa168
parent 3c9ee4c634e74e1871c7bb0f745aedc9282ad5fb
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 1 Jun 2022 13:51:41 -0400
Aaaaaalmost there!
Diffstat:
5 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
@@ -6,7 +6,7 @@ xcomp.asm: dusk.asm xcomp2.txt f2asm.py aliases.txt
cat dusk.asm >> $@
./f2asm.py xcomp2.txt >> $@
-dusk: xcomp.asm
+dusk: xcomp.asm boot2.fs
nasm -f elf32 xcomp.asm -o dusk.o
ld -m elf_i386 dusk.o -o $@
diff --git a/boot2.fs b/boot2.fs
@@ -0,0 +1 @@
+'X' emit bye
diff --git a/dusk.asm b/dusk.asm
@@ -97,12 +97,14 @@ rs_top:
ps_top:
herestart: resb MEMSIZE
+SECTION .data
+bootsrc: incbin "boot2.fs"
SECTION .text
GLOBAL _start
_start:
mov dword [here], herestart
- mov dword [current], bootsrc
+ mov dword [current], word_lastxcomp
mov dword [inptr], bootsrc
jmp word_abort
@@ -177,6 +179,7 @@ defword 'dup', 3, word_dup, word_drop
defword '?dup', 4, word_conddup, word_drop
test dword [ebp], -1
jnz word_dup
+ ret
defword 'swap', 4, word_swap, word_conddup
mov eax, [ebp]
@@ -216,7 +219,7 @@ defword '>r', 2, word_ps2rs, word_rs2ps
defword 'r@', 2, word_rsget, word_ps2rs
mov eax, [esp+4]
- mov [areg], eax
+ pspush eax
ret
defword 'r~', 2, word_rsdrop, word_rsget
@@ -250,15 +253,16 @@ defword 'A>', 2, word_Aget, word_Aset
ret
defword 'Ac@', 3, word_Acfetch, word_Aget
- mov eax, [areg]
- mov eax, [eax]
+ mov eax, 0
+ mov esi, [areg]
+ mov al, [esi]
pspush eax
ret
defword 'Ac!', 3, word_Acstore, word_Acfetch
pspop eax
- mov eax, [areg]
- mov [eax], eax
+ mov esi, [areg]
+ mov [esi], al
ret
defword 'A+', 2, word_Ainc, word_Acstore
diff --git a/f2asm.py b/f2asm.py
@@ -177,4 +177,4 @@ while t:
fp.close()
newword('_')
-out("bootsrc:\n")
+out("word_lastxcomp:\n")
diff --git a/xcomp2.txt b/xcomp2.txt
@@ -62,12 +62,15 @@ create tbl-0-f ," 0123456789abcdef"
?dup not if 2drop 1 exit then A>r >r >A ( a1 )
begin Ac@+ over c@ = not if r~ r>A drop 0 exit then 1+ next
drop r>A 1 ;
+: wordlen ( w -- len ) 1- c@ $7f and ;
+: wordname ( w -- sa sl ) dup wordlen swap 5 - over - swap ;
+: prevword ( w -- w ) dup if 5 - @ then ;
: find ( sa sl -- w? f ) \ Guards A
A>r >r >A current begin ( w R:sl )
- dup 1- c@ $7f and ( wlen ) r@ = if ( w )
- dup r@ - 5 - A> r@ ( w a1 a2 u )
+ dup wordlen r@ = if ( w )
+ A> over wordname ( w a1 a2 u )
[]= if ( w ) r~ 1 r>A exit then then
- 5 - ( prev field ) @ ?dup not until r~ 0 r>A ( not found ) ;
+ prevword ?dup not until r~ 0 r>A ( not found ) ;
: (wnf) curword stype S" word not found" stype abort ;
: ' word find not if (wnf) then ;
: entry word tuck move, ( len )
@@ -84,4 +87,4 @@ create tbl-0-f ," 0123456789abcdef"
: run1 ( -- ) \ interpret next word
word parse not if
curword find not if (wnf) then execute stack? then ;
-: mainloop 'X' emit 0 'curword 5 + c! bye begin run1 again ;
+: mainloop 0 'curword 5 + c! begin run1 again ;