duskos

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

commit 9321c6237597b156433238fc40917a83e1fdc729
parent 5158f54c2c29e4a95d0b3f0ec438494dcd098d84
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Thu,  9 Mar 2023 21:21:52 -0500

hal: add "cmp," and "[]="

Diffstat:
Mfs/xcomp/bootlo.fs | 11+++++++++--
Mposix/vm.c | 12+++++++++---
2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -261,13 +261,20 @@ code (s) r@ W>A, W) 8b @, 1 W+n, RSP) +, rdrop W<>A, branchA, : abort" [compile] ." compile abort ; immediate : word" [compile] S" NEXTWORD litn compile ! ; immediate -: prompt ." hello HAL!\n" ; prompt bye code []= ( a1 a2 u -- f ) PSP) @!, W>A, begin \ P+4=a1 P+0=u A=a2 - PSP + PSP) 4 +) 8b [@], A) 8b cmp, 0 Z) branchC, + 8 ps+, 0 LIT>W, exit, then + 1 A+n, 1 PSP) 4 +) [+n], -1 PSP) [+n], + PSP) @, =0>Z, NZ) branchC, drop + 8 ps+, 1 LIT>W, exit, : s= ( s1 s2 -- f ) over c@ 1+ []= ; : [if] not if S" [then]" begin word over s= until drop then ; alias noop [then] +S" foo" S" bar" s= dbg +S" foo" S" foo" s= dbg +: chk S" foo" S" foo" s= dbg ; chk +: prompt ." hello HAL!\n" ; prompt bye $01 const EMETA_DOCLINE \ a doc strings that ends with LF \ a \\ comment goes before the creation of the word it comments diff --git a/posix/vm.c b/posix/vm.c @@ -203,6 +203,7 @@ static void WFETCH() { vm.W = gd(readop()); } // 0x10 static void WSTORE() { sd(readop(), vm.W); } static void WSWAP() { dword a, n; a = readop(); n = gd(a); sd(a, vm.W); vm.W = n; } static void MADDN() { dword a = readop(); dword n=gpc(); sd(a, gd(a)+n); } +static void WCMP() { vm.Z = gd(readop()) == vm.W; } static void WIFETCH() { vm.W = gd(gd(readop())); } static void WISTORE() { sd(gd(readop()), vm.W); } static void WADD() { vm.W += gd(readop()); } @@ -211,6 +212,7 @@ static void WFETCH16() { vm.W = gw(readop()); } // 0x18 static void WSTORE16() { sw(readop(), vm.W); } static void WSWAP16() { dword a, n; a = readop(); n = gw(a); sw(a, vm.W); vm.W = n; } static void MADDN16() { dword a = readop(); dword n=gpc(); sw(a, gw(a)+(word)n); } +static void WCMP16() { vm.Z = gw(readop()) == (vm.W & 0xffff); } static void WIFETCH16() { vm.W = gw(gd(readop())); } static void WISTORE16() { sw(gd(readop()), vm.W); } static void WADD16() { vm.W += gw(readop()); } @@ -219,6 +221,7 @@ static void WFETCH8() { vm.W = gb(readop()); } // 0x20 static void WSTORE8() { sb(readop(), vm.W); } static void WSWAP8() { dword a, n; a = readop(); n = gb(a); sb(a, vm.W); vm.W = n; } static void MADDN8() { dword a = readop(); dword n=gpc(); sb(a, gb(a)+(byte)n); } +static void WCMP8() { vm.Z = gb(readop()) == (vm.W & 0xff); } static void WIFETCH8() { vm.W = gb(gd(readop())); } static void WISTORE8() { sb(gd(readop()), vm.W); } static void WADD8() { vm.W += gb(readop()); } @@ -442,9 +445,9 @@ static void STOREZ() { vm.W = vm.Z; } static void (*ops[OPCNT])() = { BR, CALL, RET, BRWR, BRA, BRC, BRCDROP, YIELD, PSADD, RSADD, WLIT, ALIT, WADDN, AADDN, W2A, WSWAPA, - WFETCH, WSTORE, WSWAP, MADDN, NULL, WIFETCH, WISTORE, WADD, - WFETCH16, WSTORE16, WSWAP16, MADDN16, NULL, WIFETCH16, WISTORE16, WADD16, - WFETCH8, WSTORE8, WSWAP8, MADDN8, NULL, WIFETCH8, WISTORE8, WADD8, + WFETCH, WSTORE, WSWAP, MADDN, WCMP, WIFETCH, WISTORE, WADD, + WFETCH16, WSTORE16, WSWAP16, MADDN16, WCMP16, WIFETCH16, WISTORE16, WADD16, + WFETCH8, WSTORE8, WSWAP8, MADDN8, WCMP8, WIFETCH8, WISTORE8, WADD8, WLEA, BOOTRD, STDOUT, MAYBEKEY, NULL, NULL, NULL, NULL, MAYBEWORD, WORD, PARSE, FIND, WNF, FINDMOD, NULL, NULL, STACKCHK, COMPWORD, RUNWORD, COMPILING, STARTCOMP, STOPCOMP, RSADDWR, NULL, @@ -536,6 +539,9 @@ static void buildsysdict() { entry("[+n],"); compopwr(0x13); writewr(); retwr(); CODE16(); compopwr(0x1b); writewr(); retwr(); CODE8(); compopwr(0x23); writewr(); retwr(); + entry("cmp,"); compopwr(0x14); retwr(); + CODE16(); compopwr(0x1c); retwr(); + CODE8(); compopwr(0x24); retwr(); entry("[@],"); compopwr(0x15); retwr(); CODE16(); compopwr(0x1d); retwr(); CODE8(); compopwr(0x25); retwr();