diff --git a/cli/uxncore/src/uxncore.tal b/cli/uxncore/src/uxncore.tal index f119901..f4acad9 100644 --- a/cli/uxncore/src/uxncore.tal +++ b/cli/uxncore/src/uxncore.tal @@ -2,16 +2,65 @@ @on-reset ( -> ) ( | generate ) - ;dict/int - ;dict/fn-name - [ LIT2 "{ 18 ] DEO - #0a18 DEO - #0918 DEO - ;dict/ram-var - [ LIT2 "} 18 ] DEO - #0a18 DEO + ;dict/start + + ;dict/end BRK +@ ( -- ) + #00 + &>l ( -- ) + DUP + INC DUP ?&>l + POP JMP2r + +@ ( byte -- ) + ;dict/case + DUP + [ LIT2 ": 18 ] DEO + #2018 DEO + ( | name ) + [ LIT2 "/ 18 ] DEO + [ LIT2 "* 18 ] DEO + #2018 DEO + DUP + #2018 DEO + [ LIT2 "* 18 ] DEO + [ LIT2 "/ 18 ] DEO + ( | body ) + ;dict/break + #0a18 DEO + POP JMP2r + +@ ( byte -- ) + ( | main ) + DUP #1f AND #00 SWP #0004 MUL2 ;opcodes ADD2 + ( | modes ) + DUP #20 AND #00 EQU ?{ + [ LIT2 "2 18 ] DEO } + DUP #40 AND #00 EQU ?{ + [ LIT2 "r 18 ] DEO } + DUP #80 AND #00 EQU ?{ + [ LIT2 "k 18 ] DEO } + POP JMP2r + +@ ( byte -- ) + [ LIT2 "0 18 ] DEO + [ LIT2 "x 18 ] DEO + !/b + +@ ( short* -: ) + SWP /b + &b ( byte -: ) + DUP #04 SFT /c + &c ( byte -: ) + #0f AND DUP #09 GTH #27 MUL ADD + ( >> ) + +@ ( num -- ) + [ LIT "0 ] ADD #18 DEO + JMP2r + ( @|utils ) @@ -28,7 +77,21 @@ ( @|assets ) -@dict &int "int $1 - &fn-name "uxn_eval(Uxn 20 "*u, 20 "Uint16 20 "pc) $1 - &ram-var "Uint8 20 "*ram 20 "= 20 "u->ram; $1 +@opcodes [ + "LIT 00 "INC 00 "POP 00 "NIP 00 + "SWP 00 "ROT 00 "DUP 00 "OVR 00 + "EQU 00 "NEQ 00 "GTH 00 "LTH 00 + "JMP 00 "JCN 00 "JSR 00 "STH 00 + "LDZ 00 "STZ 00 "LDR 00 "STR 00 + "LDA 00 "STA 00 "DEI 00 "DEO 00 + "ADD 00 "SUB 00 "MUL 00 "DIV 00 + "AND 00 "ORA 00 "EOR 00 "SFT 00 + &brk "BRK 00 &jci "JCI 00 &jmi "JMI + 00 &jsi "JSI 00 ] + +@dict ( strings ) + &start "int 0a "uxn_eval(Uxn 20 "*u, 20 "Uint16 20 "pc) 20 "{ 0a 09 "Uint8 20 "*ram 20 "= 20 "u->ram; 0a 09 "switch(ram[pc]) 20 "{ $1 + &end 09 "} 0a "} 0a $1 + &case 09 "case 20 $1 + &break "break; $1