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,19 +1,20 @@
( dev/console )
|0e @System/debug
|18 @Console/write
( init )
|0100 ( -> )
;hello-word
;hello-word
&loop
( send ) LDAk .Console/write DEO
( incr ) #0001 ADD2
( loop ) LDAk ,&loop JCN
POP2
#01 .System/debug DEO
BRK
@hello-word "Hello 20 "World!

View File

@ -42,6 +42,18 @@ printstack(Stack *s)
#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
console_talk(Device *d, Uint8 b0, Uint8 w)
{
@ -121,7 +133,7 @@ main(int argc, char **argv)
if(!loaduxn(&u, argv[1]))
return error("Load", "Failed");
portuxn(&u, 0x0, "empty", nil_talk);
portuxn(&u, 0x0, "system", system_talk);
devconsole = portuxn(&u, 0x1, "console", console_talk);
portuxn(&u, 0x2, "empty", nil_talk);
portuxn(&u, 0x3, "empty", nil_talk);
@ -140,7 +152,5 @@ main(int argc, char **argv)
run(&u);
if(argc > 2)
printstack(&u.wst);
return 0;
}