duskos

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

commit 1e9c7d82e4d7c18fb8dbcb9ec5495cd8357a9114
parent cbcc7d055727546bbc4362b16fd8ce00d576dfec
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed,  1 Jun 2022 13:51:40 -0400

Make RS-related word into compiling words

Having them as regular word messed up things too much because this forth is
STC. The words would always have to work with 2nd item of RS all the time. Messy
and ugly.

Instead, what we'll do is that every RS-related word is compiled as inline
native code wherever it's used.

Diffstat:
Masm.py | 15++++++++++++++-
Mxcomp.txt | 4++++
2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/asm.py b/asm.py @@ -20,7 +20,6 @@ aliases = [ ('r2p', 'r>'), ('rget', 'r@'), ('rdrop', 'r~'), - ('ret', ';'), ] for a, b in aliases: opcode = ops[a.encode()] @@ -137,6 +136,9 @@ def _next_(): opwr('_next_') intwr(ps.pop()) +def retwr(): + opwr('ret') + def strwr(): s = bytearray() c = fp.read(1) @@ -172,6 +174,15 @@ def _alias_(): off = words[nextt()] intwr(off) +def _opwriter_(): + name = nextt() + newword(name) + outbuf[-1] |= 0x80 # immediate + opcode = ops[name] + litwr(opcode) + callwr(words[b'c,']) + retwr() + def _compile_(): litwr(ops[b'_call_']) callwr(words[b'c,']) @@ -190,6 +201,7 @@ special = { b':': newword, b'(': _comment_, b'\\': _lcomment_, + b';': retwr, b',"': strwr, b'S"': slitwr, b'if': _if_, @@ -202,6 +214,7 @@ special = { b'create': _create_, b'value': _value_, b'alias': _alias_, + b'opwriter': _opwriter_, b'compile': _compile_, b'callop': _callop_, b'pspushop': _pspushop_, diff --git a/xcomp.txt b/xcomp.txt @@ -159,6 +159,10 @@ alias in< boot< word parse not if curword find not if (wnf) then execute stack? then ; : interpret begin run1 again ; +opwriter r> +opwriter >r +opwriter r@ +opwriter r~ : prompt lblcurrent: S" Dusk OS" stype ; lblmain: 0 'curword 5 + c! interpret bye lblhere: