Uxntal Devices
Uxn can communicate with a maximum of 256 ports(16 devices, each device has 16 ports), each port can handle a specific I/O message. Ports are mapped to the devices memory page, which is located outside of the main addressable memory.
Vectors are locations in programs that are evaluated when certain events occur, evaluation ends when a BRK opcode is encountered. Stack pointers and stack content are preserved between running vectors. Uxn is uninterruptible and evaluation of vectors is sequential, not concurrent.
Every program begins by evaluating at 0x0100, also called the reset vector. During the reset vector, addresses in memory may be bound and unbound to device vector ports. A vector address of 0x0000, is not evaluated. For example, the address stored in the Mouse/vector ports points to a part of the
program to be evaluated when the cursor is moved, or a button state has
changed.
@on-reset ( -> ) ( set vector ) ;on-mouse .Mouse/vector DEO2 BRK @on-mouse ( -> ) ( read state ) .Mouse/state DEI ?&on-touch BRK &on-touch ( -> ) ( The vector is unbound ) #0000 .Mouse/vector DEO2 BRK
Reading a short from a device is always done with the high-byte first and only the-high byte may trigger a device call. Writing a short to a device is also always done with the high-byte first, but only the low-byte may trigger a device call. If a port is not managed by a device, the port acts like a normal memory cell. The low-byte of a short located at 0xff wraps to 0x00.
Writing to a port does not insure that reading that port back will return the same value. For example, writing to Screen/height when the screen is not resizable, and then reading from that same port will get the actual size regardless of what was written to it.
incoming: uxntal notation uxntal reference uxntal memory varvara