From dc57fad04573575cccb9f911316b663ad5944695 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 13 Jul 2023 11:40:44 -0700 Subject: [PATCH] Better device handlers --- cli/uxnvm/uxnvm.tal | 20 +++++++++----------- cli/uxnvm/vm.tal | 8 ++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/cli/uxnvm/uxnvm.tal b/cli/uxnvm/uxnvm.tal index 1ecdaf3..d799c05 100644 --- a/cli/uxnvm/uxnvm.tal +++ b/cli/uxnvm/uxnvm.tal @@ -41,34 +41,32 @@ .uxn/err LDZ ?&err ?run - &end ( -- ) - ;/count LDA2 - ;dict/cycles - JMP2r + ;/count LDA2 + ;dict/cycles + JMP2r &err ( opcode -- ) POP ! @halt ( opcode -- opcode ) JMP2r -@send ( v* p* -- ) - NIP +@emu-deo ( v p -- ) ( | handlers ) DUP #0e NEQ ?&>no-debug - ( TODO ) &>no-debug + POP2 JMP2r &>no-debug DUP #0f NEQ ?&>no-halt - ( TODO ) &>no-halt + POP2 JMP2r &>no-halt DUP #18 NEQ ?&>no-out - POP NIP #18 DEO + DEO JMP2r &>no-out DUP #19 NEQ ?&>no-err - POP NIP #19 DEO + DEO JMP2r &>no-err ( | error ) ;dict/err-device /b #0a18 DEO - POP2 JMP2r + POP JMP2r ( @|stdlib ) diff --git a/cli/uxnvm/vm.tal b/cli/uxnvm/vm.tal index 1c70cad..74a4a20 100644 --- a/cli/uxnvm/vm.tal +++ b/cli/uxnvm/vm.tal @@ -71,13 +71,9 @@ DUP #7f GTH #ff MUL SWP .uxn/pc LDZ2 ADD2 JMP2r @devw ( v* p* -- ) - DUP #10 AND ?&console .uxn/2 LDZ ?&16 - &8 NIP DEO - POP JMP2r - &16 NIP DEO2 - JMP2r - &console !send + &8 NIP ROT POP !emu-deo + &16 NIP STHk emu-deo STHr INC !emu-deo @devr ( p* -- ) .uxn/2 LDZ ?devr/16