Added system device to uxncli

This commit is contained in:
neauoire 2021-07-28 15:41:07 -07:00
parent 7b7f4fd0f7
commit b46d317b4f
2 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,6 @@
( dev/console ) ( dev/console )
|0e @System/debug
|18 @Console/write |18 @Console/write
( init ) ( init )
@ -7,12 +8,12 @@
|0100 ( -> ) |0100 ( -> )
;hello-word ;hello-word
&loop &loop
( send ) LDAk .Console/write DEO ( send ) LDAk .Console/write DEO
( incr ) #0001 ADD2 ( incr ) #0001 ADD2
( loop ) LDAk ,&loop JCN ( loop ) LDAk ,&loop JCN
POP2 POP2
#01 .System/debug DEO
BRK BRK

View File

@ -42,6 +42,18 @@ printstack(Stack *s)
#pragma mark - Devices #pragma mark - Devices
static void
system_talk(Device *d, Uint8 b0, Uint8 w)
{
if(!w) {
d->dat[0x2] = d->u->wst.ptr;
d->dat[0x3] = d->u->rst.ptr;
} else if(b0 == 0xe)
printstack(&d->u->wst);
else if(b0 == 0xf)
d->u->ram.ptr = 0x0000;
}
static void static void
console_talk(Device *d, Uint8 b0, Uint8 w) console_talk(Device *d, Uint8 b0, Uint8 w)
{ {
@ -121,7 +133,7 @@ main(int argc, char **argv)
if(!loaduxn(&u, argv[1])) if(!loaduxn(&u, argv[1]))
return error("Load", "Failed"); return error("Load", "Failed");
portuxn(&u, 0x0, "empty", nil_talk); portuxn(&u, 0x0, "system", system_talk);
devconsole = portuxn(&u, 0x1, "console", console_talk); devconsole = portuxn(&u, 0x1, "console", console_talk);
portuxn(&u, 0x2, "empty", nil_talk); portuxn(&u, 0x2, "empty", nil_talk);
portuxn(&u, 0x3, "empty", nil_talk); portuxn(&u, 0x3, "empty", nil_talk);
@ -140,7 +152,5 @@ main(int argc, char **argv)
run(&u); run(&u);
if(argc > 2)
printstack(&u.wst);
return 0; return 0;
} }