Welcome to this year's December Adventure. I did one of these last year too.
Days
Day 7
Ok, ready to start decadv2025 in earnest
First, a utility:
# ~/.aliases
function uxnrun() {
local tal="$1"
local rom="${tal%.tal}.rom"
exists-f "$tal" || return 1;
uxnasm "$tal" "$rom" && uxnemu "$rom"
}
function uxndbg() {
local tal="$1"
local rom="${tal%.tal}.rom"
exists-f "$tal" || return 1;
uxnasm "$tal" "$rom" && uxnemu -2x ~/roms/beetbug.rom "$rom"
}
I was looking at an example of printing date-times and noticed there was
some kind of implicit syntax with subroutine labels, so I read man 7 uxntal:
JCI, JMI, and JSI
The "immediate jump" instructions are produced by the assembler. They interpret the
next 2 bytes of the ROM as a relative address (addr) and have the following effects:
JMI ( -- ) jump to addr unconditionally
JCI ( bool^ -- ) jump to addr if bool is non-zero
JSI ( -- [pc*] ) jump to addr saving the current address (pc) on rst
(The instruction pointer will be moved forward 2 bytes, past the relative address.)
These instructions are created by the assembler from special syntax:
!dest produces JMI wx yz
?dest produces JCI wx yz
dest produces JSI wx yz (assuming dest is not a macro or reserved)
so, that makes sense of this kind of tal incantation:
|0100 #09 <emit-decimal> #05 <emit-decimal> BRK @<emit-decimal> ( byte -- ) LIT "0 ADD #18 DEO JMP2r
::14:48::
It's a little primitive, but I've made an isodate emitter in uxn:
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 |c0 @Datetime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 |0100 @on-reset .Datetime/year DEI2 \print-4digit LIT "- .Console/write DEO .Datetime/month DEI \print-2digit LIT "- .Console/write DEO .Datetime/day DEI \print-2digit LIT "/ .Console/write DEO .Datetime/hour DEI \print-2digit LIT ": .Console/write DEO .Datetime/minute DEI \print-2digit LIT ": .Console/write DEO .Datetime/second DEI \print-2digit BRK @\emit-decimal ( byte -- ) LIT "0 ADD #18 DEO JMP2r @\print-2digit ( 2-digit -- ) #0a DIVk \emit-decimal DIVk MUL SUB \emit-decimal JMP2r @\print-4digit ( 4-digit* -- ) #03e8 DIVk2 \emit-decimal POP ( 1000s ) DIVk2 MUL2 SUB2 #0064 DIVk2 \emit-decimal POP ( 100s ) DIVk2 MUL2 SUB2 #0a DIVk \emit-decimal ( 10s ) DIVk MUL SUB \emit-decimal ( 1s ) JMP2r ( uxncli datetime.rom -- 2025-11-07/15:13:48 )
At this point I could either extend it logically by having it emit something like "Sunday, December 7th", or I could extend it by making it a graphical application -- a little desktop clock.
I'm partial to figuring out fonts and animation.