duskos

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

commit 21cfece551c5285569588b624faba78018bd41dd
parent 634a95f34be1a8f164537b59fa889508b0e11792
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Thu, 15 Sep 2022 19:51:44 -0400

cc/vm/forth: fix PS corruption bug

The removal of the argframe introduced a bug not covered by tests.

Diffstat:
Mfs/cc/vm/forth.fs | 11+++++++----
Mfs/tests/cc/cc.fs | 2++
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/cc/vm/forth.fs b/fs/cc/vm/forth.fs @@ -87,16 +87,19 @@ struct+[ VMOp \ generate function prelude code by allocating "locsz" bytes on RS. : vmprelude, ( argsz locsz -- ) - to locsz to argsz + to locsz to argsz 0 to psoff locsz if locsz neg r+, then ; \ deallocate locsz and argsz. If result is set, keep a 4b in here and push the \ result there. : vmret, selop2 noop# \ returning with a second operand? something's wrong - selop1 vmop loc if opCompile* opdeinit then - argsz ?dup if 4 / >r begin compile nip next then - locsz if locsz r+, then + selop1 vmop loc if + opCompile* opdeinit argsz ?dup if + p', compile ! argsz CELLSZ - ?dup if p+, then then + else + argsz ?dup if p+, then then + locsz ?dup if r+, then exit, ; \ Write op to args diff --git a/fs/tests/cc/cc.fs b/fs/tests/cc/cc.fs @@ -37,8 +37,10 @@ capture helloworld S" Hello World!" #s= 42 5 forloop 47 #eq 1 multret 1 #eq 42 multret 32 #eq +1234 \ test that void funcs with args don't mess with the PS underneath it. 55 capture multretvoid S" Nope" #s= 42 capture multretvoid S" Answer to the universe" #s= +1234 #eq -1 0 lts # -1 0 ltu not # 0 boolnot 1 #eq