Here’s a really weird #uxn “Hello World” program:
( hello.tal )
( devices )
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
( macros )
( print a character to standard output )
%EMIT { .Console/write DEO } ( character -- )
%EMITK { .Console/write DEOk } ( character -- character Consolewrite )
( print a newline )
%NL { #0a EMIT } ( -- )
( main program )
|0100 #0a6f
#6c
#6568
EMITK NIP DEOk NIP DEOk DEOk NIP DEOk NIP DEO
,wo LDRk ( wo w -- )
STH #0d SUB STHr
@looper #00 POP ( wo w -- )
EMIT ( wo -- )
INC ( wo+1 -- )
LDRk ( wo+1 o -- )
DUP #00 NEQ ,looper ( wo+1 o 1 looper -- )
JCN ( wo+1 o -- )
BRK
@wo
'w 'o 'r 'l 'd 21> so the |00 and |20 are not part of the memory address space.
They are, |0000 and |0020 are just address in the first page(0000-0100 range), which is part of the memory address space.
A better way to think about labels, is that it's just giving a name to a number.
#0a18 DEO, is the same as #0a .Console/write DEO
There's no difference between |2, |02, |002 and |0002
Got something working for background processing in #uxn with YIELD/RESUME/STOP actions, so the code doesn't have to be written in a contorted way (just put YIELD in strategic places and hope you leave enough stack for the rest of the code, which should also leave the stack as it found it).
I'm planning on using this for the computer player of the tokamak game to amortize the cost of the AI over several frames (and maybe also visualize its algorithms).
```
( bg.tal )
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
%STOP { ;stopped ;pc STA2 BRK }
%YIELD { ;yield JSR2 }
%RESUME { .pc LDZ2 JMP2 }
|0000
@pc $2
@frame $2
|0100
;on-frame .Screen/vector DEO2
,background JMP
@on-frame
.frame LDZ2 #0001 ADD2 .frame STZ2
RESUME
@yield
STH2r .pc STZ2
BRK
@stopped
YIELD
,stopped JMP
@background
#0a #00
&for-line ( end current )
EQUk ,&break-line JCN
LIT 'z LIT 'a
&for-letters ( end current )
DUP .Console/write DEO
YIELD
EQUk ,&break-letters JCN
INC
,&for-letters JMP
&break-letters
POP2
#0a .Console/write DEO
INC
,&for-line JMP
&break-line
POP2
STOP
```