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, evaluationg ends when a BRK opcode is encountered. Stack pointers and stack content are preserved between running vectors. Uxn is non-interruptible and evaluation of vectors is sequential, not concurrent.
All programs begin by executing at 0x100, also called the reset vector. Devices that may respond to events have vector ports, that can be written to. 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 ( -> ) ( A mouse button is pressed ) BRK
Reading or writing to device ports is always done by the high byte first, then the lower byte. Some devices may only trigger on the lower-byte. If a port is not managed by a device, the port acts like a normal memory cell.
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