uxn - a new rabbit hole
uxn / varvara
shit - sorry for the wording - I found a new rabbit hole, it caught my attention because of some mastodon posts. I think in uxn you can dive in for aeons. Have a look at uxn or rather varvara, as the whole stack is called. It is a virtual 64kb computer, running on any device where a corresponding emulator exists. The architecture is quite simple:
- 32 opcodes in 3 modes (shorts (2), keep stack (k), and access return stack (r))
- No registers, just two stacks: working stack, return stack
- zero page (first 1kb)
- devices: screen, keyboard, console, controller, audio, and others (as far as I understood, you can build also your own devices, at least there are two reserved for that)
- easy graphics and sprites (bitmap sprites in 1 or 2 colors, drawing pixels)
uxntal
The uxn-virtual machine can be programed in uxntal, a forth-oriented assembler. If you ever did some assembler in the 8-bit era, f.e. 6502 on the C64, you'll be into it in some hours. You'll find also a nice tutorial at compudanzas site.
Ahhh, so much fun to write in assembler again, haven't done this for about 30 years. In the distant past I got some experience in 6502 on the Commodore 64 ($a9 LDA, $8d STA, will never forget these opcodes) and also the 68000, which I programmed at the Amiga. Never will forget AMIGA Maschinensprache (German), my first intro into Assembler with Amiga.
Uxnasm, the assembler offers a lot of functionality: macros and an extensive way to handle labels. There exists uxnasm in C for your host system, but also a bare-metal versions asma.tal and drifblim, these run on uxn itself. And - of course - there are various emacs-modes with syntax highlight for uxntal and other functionalities. I chose uxntal-mode, as I like simply hitting C-x C-e to compile and start a rom.
What I would love to have, is also org-babel support for uxncli.
See below, my first uxntal progam, printing hexvalues from the stack.
( print-bytes.tal )
( devices )
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
( macros )
%EMIT { .Console/write DEO } ( char -- )
%NL { #0a EMIT } ( -- )
%BLANK { #20 EMIT } ( -- )
%QUIT { #010f DEO } ( -- )
|0100
#9f
;print-byte JSR2 BLANK
#aa
;print-byte JSR2 NL
#1234
;print-short JSR2 NL
QUIT
BRK
( prints a short on stack )
@print-short ( short -- )
SWP
,print-byte JSR
,print-byte JSR
JMP2r
( prints a byte on stack )
@print-byte ( byte -- )
DUP
#04 SFT
,&print-nibble JSR
#0f AND
,&print-nibble JSR
JMP2r
&print-nibble
#30 ADD
DUP
#3a LTH
,&output JCN
#07 ADD
&output
EMIT
JMP2r
Ideas
Just some ideas, what I would like to do with that stuff, if there weren't that many time constrains …
- uxn-emulator in Common Lisp
- an simple emacs clone for uxn
- your own operating system in uxn
- a befunge machine in uxn
- nice games
- gemini client / server
Guys behind it
Not only uxn is interesting, the creators behind uxn, who started the project AFAIU, are very intersting people. Since 2016 they live on a sail boat. Have a look at their site and wiki. Everything they publish is real artists work. I enjoy just having a look at their websites and projectsdescriptions.