Condensed vm.tal
This commit is contained in:
parent
40adea4936
commit
e65a4ecf69
178
cli/uxnvm/vm.tal
178
cli/uxnvm/vm.tal
|
@ -3,9 +3,9 @@
|
||||||
@<reset> ( -- )
|
@<reset> ( -- )
|
||||||
[ LIT2 00 -uxn/err ] STZ
|
[ LIT2 00 -uxn/err ] STZ
|
||||||
#0100 .uxn/pc STZ2
|
#0100 .uxn/pc STZ2
|
||||||
#0000 ;wst/ptr STA2
|
#0000 DUP2 ;wst/ptr STA2
|
||||||
#0000 ;rst/ptr STA2
|
DUP2 ;rst/ptr STA2
|
||||||
#0000 ;<step>/count STA2
|
;<step>/count STA2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@<step> ( -- ok )
|
@<step> ( -- ok )
|
||||||
|
@ -52,26 +52,19 @@
|
||||||
|
|
||||||
@poke ( v* a* -- )
|
@poke ( v* a* -- )
|
||||||
.uxn/2 LDZ ?&16
|
.uxn/2 LDZ ?&16
|
||||||
&8 ( -- )
|
&8 ;rom ADD2 STA
|
||||||
;rom ADD2 STA
|
|
||||||
POP JMP2r
|
POP JMP2r
|
||||||
&16 ( -- )
|
&16 ;rom ADD2 STA2
|
||||||
;rom ADD2 STA2
|
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@peek ( a* -- v* )
|
@peek ( a* -- v* )
|
||||||
.uxn/2 LDZ ?&16
|
.uxn/2 LDZ ?&16
|
||||||
&8 ( -- )
|
&8 ;rom ADD2 LDA #00 SWP JMP2r
|
||||||
;rom ADD2 LDA #00 SWP JMP2r
|
&16 ;rom ADD2 LDA2 JMP2r
|
||||||
&16 ( -- )
|
|
||||||
;rom ADD2 LDA2 JMP2r
|
|
||||||
|
|
||||||
@warp ( a* -- )
|
@warp ( a* -- )
|
||||||
.uxn/2 LDZ ?&16
|
.uxn/2 LDZ ?&16
|
||||||
&8 ( -- )
|
&8 NIP rel &16 .uxn/pc STZ2
|
||||||
NIP rel
|
|
||||||
&16 ( -- )
|
|
||||||
.uxn/pc STZ2
|
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@rel ( a* -- )
|
@rel ( a* -- )
|
||||||
|
@ -80,21 +73,16 @@
|
||||||
@devw ( v* p* -- )
|
@devw ( v* p* -- )
|
||||||
DUP #10 AND ?&console
|
DUP #10 AND ?&console
|
||||||
.uxn/2 LDZ ?&16
|
.uxn/2 LDZ ?&16
|
||||||
&8 ( -- )
|
&8 NIP DEO
|
||||||
NIP DEO
|
|
||||||
POP JMP2r
|
POP JMP2r
|
||||||
&16 ( -- )
|
&16 NIP DEO2
|
||||||
NIP DEO2
|
|
||||||
JMP2r
|
JMP2r
|
||||||
&console ( -- )
|
&console !send
|
||||||
!send
|
|
||||||
|
|
||||||
@devr ( p* -- )
|
@devr ( p* -- )
|
||||||
.uxn/2 LDZ ?devr/16
|
.uxn/2 LDZ ?devr/16
|
||||||
&8 ( -- )
|
&8 NIP DEI #00 SWP !push
|
||||||
NIP DEI #00 SWP !push
|
&16 NIP DEI2 !push
|
||||||
&16 ( -- )
|
|
||||||
NIP DEI2 !push
|
|
||||||
|
|
||||||
(
|
(
|
||||||
@|library )
|
@|library )
|
||||||
|
@ -116,112 +104,52 @@
|
||||||
&op-jmi ( -- )
|
&op-jmi ( -- )
|
||||||
.uxn/pc LDZ2 DUP2 peek/16 ADD2 INC2 INC2 !warp/16
|
.uxn/pc LDZ2 DUP2 peek/16 ADD2 INC2 INC2 !warp/16
|
||||||
|
|
||||||
@op-inc
|
@lib ( non immediate opcodes )
|
||||||
pop INC2 !push
|
&inc pop INC2 !push
|
||||||
|
&pop pop POP2 JMP2r
|
||||||
@op-pop
|
&nip pop pop POP2 !push
|
||||||
pop POP2 JMP2r
|
&swp pop pop SWP2 push !push
|
||||||
|
&rot pop pop pop ROT2 ROT2 push push !push
|
||||||
@op-nip
|
&dup pop DUP2 push !push
|
||||||
pop pop POP2 !push
|
&ovr pop pop SWP2 OVR2 push push !push
|
||||||
|
&equ pop pop EQU2 !push/byte
|
||||||
@op-swp
|
&neq pop pop NEQ2 !push/byte
|
||||||
pop pop SWP2 push !push
|
>h pop pop SWP2 GTH2 !push/byte
|
||||||
|
<h pop pop SWP2 LTH2 !push/byte
|
||||||
@op-rot
|
&jmp pop !warp
|
||||||
pop pop pop ROT2 ROT2 push push !push
|
&jcn pop pop/8 NIP ?warp
|
||||||
|
|
||||||
@op-dup
|
|
||||||
pop DUP2 push !push
|
|
||||||
|
|
||||||
@op-ovr
|
|
||||||
pop pop SWP2 OVR2 push push !push
|
|
||||||
|
|
||||||
@op-equ
|
|
||||||
pop pop EQU2 !push/byte
|
|
||||||
|
|
||||||
@op-neq
|
|
||||||
pop pop NEQ2 !push/byte
|
|
||||||
|
|
||||||
@op-gth
|
|
||||||
pop pop SWP2 GTH2 !push/byte
|
|
||||||
|
|
||||||
@op-lth
|
|
||||||
pop pop SWP2 LTH2 !push/byte
|
|
||||||
|
|
||||||
@op-jmp
|
|
||||||
pop !warp
|
|
||||||
|
|
||||||
@op-jcn
|
|
||||||
pop pop/8 NIP ?warp
|
|
||||||
POP2 JMP2r
|
POP2 JMP2r
|
||||||
|
&jsr pop .uxn/pc LDZ2 .uxn/dst LDZ2 .uxn/src STZ2
|
||||||
@op-jsr
|
|
||||||
pop .uxn/pc LDZ2 .uxn/dst LDZ2 .uxn/src STZ2
|
|
||||||
push/16 !warp
|
push/16 !warp
|
||||||
|
&sth pop .uxn/dst LDZ2 .uxn/src STZ2
|
||||||
@op-sth
|
|
||||||
pop .uxn/dst LDZ2 .uxn/src STZ2
|
|
||||||
!push
|
!push
|
||||||
|
&ldz pop/8 peek !push
|
||||||
@op-ldz
|
&stz pop/8 pop SWP2 !poke
|
||||||
pop/8 peek !push
|
&ldr pop/8 NIP rel peek !push
|
||||||
|
&str pop/8 pop SWP2 NIP rel !poke
|
||||||
@op-stz
|
&lda pop/16 peek !push
|
||||||
pop/8 pop SWP2 !poke
|
&sta pop/16 pop SWP2 !poke
|
||||||
|
&dei pop/8 !devr
|
||||||
@op-ldr
|
&deo pop/8 pop SWP2 !devw
|
||||||
pop/8 NIP rel peek !push
|
&add pop pop ADD2 !push
|
||||||
|
&sub pop pop SWP2 SUB2 !push
|
||||||
@op-str
|
&mul pop pop MUL2 !push
|
||||||
pop/8 pop SWP2 NIP rel !poke
|
&div pop pop SWP2 DIV2 !push
|
||||||
|
&and pop pop AND2 !push
|
||||||
@op-lda
|
&ora pop pop ORA2 !push
|
||||||
pop/16 peek !push
|
&eor pop pop EOR2 !push
|
||||||
|
&sft pop/8 pop SWP2 NIP SFT2 !push
|
||||||
@op-sta
|
|
||||||
pop/16 pop SWP2 !poke
|
|
||||||
|
|
||||||
@op-dei
|
|
||||||
pop/8 !devr
|
|
||||||
|
|
||||||
@op-deo
|
|
||||||
pop/8 pop SWP2 !devw
|
|
||||||
|
|
||||||
@op-add
|
|
||||||
pop pop ADD2 !push
|
|
||||||
|
|
||||||
@op-sub
|
|
||||||
pop pop SWP2 SUB2 !push
|
|
||||||
|
|
||||||
@op-mul
|
|
||||||
pop pop MUL2 !push
|
|
||||||
|
|
||||||
@op-div
|
|
||||||
pop pop SWP2 DIV2 !push
|
|
||||||
|
|
||||||
@op-and
|
|
||||||
pop pop AND2 !push
|
|
||||||
|
|
||||||
@op-ora
|
|
||||||
pop pop ORA2 !push
|
|
||||||
|
|
||||||
@op-eor
|
|
||||||
pop pop EOR2 !push
|
|
||||||
|
|
||||||
@op-sft
|
|
||||||
pop/8 pop SWP2 NIP SFT2 !push
|
|
||||||
|
|
||||||
@optbl
|
@optbl
|
||||||
[
|
[
|
||||||
=op-lit =op-inc =op-pop =op-nip
|
=op-lit =lib/inc =lib/pop =lib/nip
|
||||||
=op-swp =op-rot =op-dup =op-ovr
|
=lib/swp =lib/rot =lib/dup =lib/ovr
|
||||||
=op-equ =op-neq =op-gth =op-lth
|
=lib/equ =lib/neq =lib/gth =lib/lth
|
||||||
=op-jmp =op-jcn =op-jsr =op-sth
|
=lib/jmp =lib/jcn =lib/jsr =lib/sth
|
||||||
=op-ldz =op-stz =op-ldr =op-str
|
=lib/ldz =lib/stz =lib/ldr =lib/str
|
||||||
=op-lda =op-sta =op-dei =op-deo
|
=lib/lda =lib/sta =lib/dei =lib/deo
|
||||||
=op-add =op-sub =op-mul =op-div
|
=lib/add =lib/sub =lib/mul =lib/div
|
||||||
=op-and =op-ora =op-eor =op-sft ]
|
=lib/and =lib/ora =lib/eor =lib/sft ]
|
||||||
|
|
||||||
(
|
(
|
||||||
@|uxn )
|
@|uxn )
|
||||||
|
|
Loading…
Reference in New Issue