duskos

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

commit 551763b62b8e4d3be74120c38c1afe135cedaf56
parent a7e419851d24804f6ea0c62ade16c289aa56956b
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun, 20 Nov 2022 15:14:27 -0500

app/uxn: Hello World!

Diffstat:
Mfs/app/uxn/vm.c | 5+++--
Mfs/tests/app/uxn/dummy.bin | 0
Mfs/tests/app/uxn/dummy.tal | 17++++++++++++-----
Mfs/tests/app/uxn/vm.fs | 3+--
4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/fs/app/uxn/vm.c b/fs/app/uxn/vm.c @@ -95,7 +95,7 @@ static void nulldeo(Device *d, unsigned char port) { emit('N'); } /* Operations */ static void _err() { error(42); } -static void LIT() { push(peek(pc++)); } +static void LIT() { push(peek(pc++)); pc += bs; } static void INC() { push(pop()+1); } static void POP() { pop(); } static void NIP() { unsigned short x = pop(); pop(); push(x); } @@ -119,6 +119,7 @@ static void GTH() { push8(pop() < pop()); } static void LTH() { push8(pop() > pop()); } static void JMP() { warp(pop()); } static void JCN() { unsigned short a = pop(); if (pop8()) { warp(a); } } +static void LDA() { push(peek(pop16())); } static void DEO() { unsigned char port = pop8(); unsigned short val = pop(); @@ -136,7 +137,7 @@ static void ADD() { push(pop() + pop()); } static VMOP ops[$20] = { LIT, INC, POP, NIP, SWP, ROT, DUP, OVR, EQU, NEQ, GTH, LTH, JMP, JCN, _err, _err, - _err, _err, _err, _err, _err, _err, _err, DEO, + _err, _err, _err, _err, LDA, _err, _err, DEO, ADD, _err, _err, _err, _err, _err, _err, _err}; void uxn_exec() { diff --git a/fs/tests/app/uxn/dummy.bin b/fs/tests/app/uxn/dummy.bin Binary files differ. diff --git a/fs/tests/app/uxn/dummy.tal b/fs/tests/app/uxn/dummy.tal @@ -1,6 +1,13 @@ -|0100 -#2a INCk ( 2a 2b ) -DUP2 ADD2 ( 54 56 ) -#18 DEO ( 54 ) -#18 DEO +%EMIT { #18 DEO } + +|0100 + ;hello-word + + @while + ( send ) LDAk EMIT + ( loop ) INC2 LDAk ,while JCN + POP2 + BRK + +@hello-word "Hello 20 "World! 00 diff --git a/fs/tests/app/uxn/vm.fs b/fs/tests/app/uxn/vm.fs @@ -6,7 +6,6 @@ testbegin uxn_ram $100 + S" /tests/app/uxn/dummy.bin" curpath :find# Path :open tuck File :readall File :close uxn_init -create expected 3 nc, 2 $56 $54 capture uxn_exec -expected #s= +S" Hello World!" #s= testend