duskos

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

commit 293ee41767d34809be8d7090185040abf12b8a54
parent a718f130d3891730da55f55306550609bb43170a
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun,  3 Jul 2022 10:14:53 -0400

Change "find" signature from ( str -- w? f ) to ( str -- word-or-0 )

This allows find() to be called from C code, which in turn allows C to call
Forth words with name that don't fit the rules for C identifiers.

Diffstat:
Mdusk.asm | 12++++--------
Mfs/cc/gen.fs | 2+-
Mfs/xcomp/bootlo.fs | 5++---
3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/dusk.asm b/dusk.asm @@ -789,7 +789,7 @@ defword '[]=', 3, word_rangeeq pspush eax ret -; ( str -- w? f ) +; ( str -- word-or-0 ) defword 'find', 4, word_find mov esi, [ebp] xor ecx, ecx @@ -811,7 +811,6 @@ _find_loop: jnz _find_skip2 ; same contents mov [ebp], edx - pspush 1 ret _find_skip2: mov cl, al @@ -828,8 +827,7 @@ _find_skip1: defword "'", 1, word_apos call word_word call word_find - pspop eax - test eax, eax + test dword [ebp], -1 jz word_wnf ret @@ -870,8 +868,7 @@ _xtcomp_loop: _xtcomp_notlit: pspush curword call word_find - pspop eax - test eax, eax + test dword [ebp], -1 jz word_wnf ; word found mov eax, [ebp] ; w @@ -905,8 +902,7 @@ defword 'runword', 7, word_runword ; not a literal pspush curword call word_find - pspop eax - test eax, eax + test dword [ebp], -1 jz word_wnf call word_execute jmp word_stackcond diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs @@ -223,7 +223,7 @@ ASTIDCNT wordtbl gentbl ( node -- ) ( node ) ast.funcall.funcname ( name ) dup ast.unit.find ?dup if ( name fnode ) nip dup nodeid AST_FUNCTION = _assert ast.func.address else ( name ) - find _assert then ( address ) + find ?dup _assert then ( address ) vmcall>op1, ; : _ ( node -- ) gentbl over nodeid wexec ; diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -1,6 +1,3 @@ -: = - not ; -: 0< <<c nip ; - : immediate current 1- dup c@ $80 or swap c! ; : ['] ' litn ; immediate : to ['] ! [to] ; @@ -17,6 +14,7 @@ : code word entry ; : create code compile (cell) ; : value code compile (val) , ; +: = - not ; : \ begin in< $0a = until ; immediate \ hello, this is a comment! : ( begin @@ -46,6 +44,7 @@ \ Arithmetic : > swap < ; +: 0< <<c nip ; : 0>= 0< not ; : >= < not ; : <= > not ;