The 6502 standard library
On the native targets (arm64, x86_64, win64, arm9) the standard library uses a host operating system for everyday services: a clock, a process heap, a way to exit with a status. The xt6502 target has none of these. It is a bare banked 6502 with the platform ROM, so the library provides those services itself, in hand-written 6502.
The classes below exist on every target where the service makes sense. On the native backends they are thin wrappers over the host OS. On the 6502 they are the full implementation: reading hardware registers, walking a free list, chaining an interrupt vector.
System utilities
Section titled “System utilities”- Time: the
RTCLOKjiffy clock, with elapsed time in jiffies and seconds, plus busy-wait delays. On native targets it reads a monotonic host clock instead. - Heap: introspection on the coalescing free-list allocator (free bytes, largest extent, capacity). The 6502 walks the free list; native targets report host-heap figures.
- Vbi: install and remove vertical-blank interrupt
handlers through the OS-safe
SETVBVpath. 6502-only; no native target has these vectors. - System: process control, to exit the program back
to DOS from anywhere. 6502-only; on native targets you return from
main. - Memory: bulk fill / clear / copy / move with self-modifying page-aligned inner loops. Its bodies are inline 6502 assembly, so it is effectively 6502-only.
The rest of the surface on 6502
Section titled “The rest of the surface on 6502”The 6502 also has more than these utilities:
- Strings and collections use narrower types. The 6502
Stringis byte-oriented withu16indexes and has no UTF-8 character layer, because a decoder is too costly on a 6502.Array/Numberstore narrower primitives unless-DENABLE_64BIT=1widens them. See Foundation for how the containers differ, and String (xt6502) for the byte-oriented string API. - Graphics and files exist on 6502 too. The
Gfx*classes drive the ANTIC display modes, andFILEprovides buffered file I/O over DOS.
If a class from the native library is missing here, it usually wraps an OS facility the bare 6502 does not have. Where the service is useful, the library provides a 6502 implementation rather than a stub.