duskos

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

commit 767c730b556348c1b4982a8d8347911c797a8bb9
parent c1d807791d62e60fb37ac44355ba30431146d5c0
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 24 Mar 2023 17:43:40 -0400

halcc: helloworld()

Diffstat:
Mfs/comp/c/type.fs | 3++-
Mfs/tests/comp/c/cc.fs | 2+-
Mfs/tests/comp/c/test2.c | 6++++++
Mposix/dis.c | 6+++---
Mposix/vm.c | 3++-
5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/comp/c/type.fs b/fs/comp/c/type.fs @@ -99,7 +99,8 @@ struct[ CDecl swap llnext repeat ( res ) ; \ When the CDecl is an array, return the size of a single element. - : :elemsize ( self -- size ) dup nbelem _assert type _typesize ; + : :elemsize ( self -- size ) + dup nbelem _assert dup lvl if drop 4 else type _typesize then ; : :argssize ( self -- size ) dup :funcsig? _assert llcnt 1- CELLSZ * ; : :offset! ( off self -- off+size ) 2dup to offset :size + ; diff --git a/fs/tests/comp/c/cc.fs b/fs/tests/comp/c/cc.fs @@ -40,8 +40,8 @@ globalinc 1236 #eq globalinc 1238 #eq 1 globalshort 2 #eq 42 142 funcsig 184 #eq -testend \s capture helloworld S" Hello World!" #s= +testend \s create expected ," Null terminated\0" nullstr expected 16 []= # 5 forsum 10 #eq diff --git a/fs/tests/comp/c/test2.c b/fs/tests/comp/c/test2.c @@ -163,3 +163,9 @@ int funcsig(int a, int b) { int foo = fn(a, b); return fn(a, b); } + +void stype(char *str); +static char *msgs[1] = {"Hello World!"}; +void helloworld() { + stype(msgs[0]); +} diff --git a/posix/dis.c b/posix/dis.c @@ -147,7 +147,7 @@ static struct op ops[OPCNT] = { {"WMOD", ARGOPN}, {"WSHL", ARGOP}, {"WSHR", ARGOP}, - {NULL, ARGERR}, + {"WLEA", ARGOP}, {NULL, ARGERR}, {"WSUB16", ARGOP}, @@ -156,7 +156,7 @@ static struct op ops[OPCNT] = { {"WMOD16", ARGOPN}, {"WSHL16", ARGOP}, {"WSHR16", ARGOP}, - {NULL, ARGERR}, + {"WLEA", ARGOP}, {NULL, ARGERR}, {"WSUB8", ARGOP}, @@ -165,7 +165,7 @@ static struct op ops[OPCNT] = { {"WMOD8", ARGOPN}, {"WSHL8", ARGOP}, {"WSHR8", ARGOP}, - {NULL, ARGERR}, + {"WLEA", ARGOP}, {NULL, ARGERR}, {"WAND", ARGOP}, diff --git a/posix/vm.c b/posix/vm.c @@ -310,7 +310,8 @@ static void MAYBEKEY() { // n -- operand static void MAKEMEM() { vm.W = hbankset(OPHASDISP|OPMEM, vm.W); } // operand n -- operand -static void ADDDISP() { dword by = ppop(); vm.W = hbankset(vm.W, by)|OPHASDISP; } +static void ADDDISP() { + dword by = ppop(); if (by) vm.W = hbankset(vm.W, by)|OPHASDISP; } static void MAYBEWORD() { // 0x30 dword c, a;