Repository navigation
NanoCore v0.3.0
Correctness pass over the emulator, assembler, and docs.
Fixed
- Emulator panic on out-of-range register operands. An operand byte ≥ 16 indexed past the 16-register file and crashed the process (
index out of bounds: the len is 16 but the index is 255). Register operands are now masked to R0–R15, matching how packed two-register operands already worked. Reachable from any hand-written.ncb, a jump into.DBdata, or a misaligned PC. - Hex literals were parsed by a byte-decoder.
0xFwas rejected outright (even digit counts only) and0x1234silently truncated to0x12. Short forms now assemble correctly and out-of-range values are a proper error. Same fix applies to address entry in the TUI, where0xFsilently became0x00. - Undefined labels reported the wrong error.
JMP nowheresaidInvalid value 'nowhere'; it now saysUndefined label 'nowhere'. Malformed numeric literals (JMP 0xZZ) keep their own message. - Runaway programs exited 0. A program that never halted printed a force-halt notice and reported success. It now raises
MaxCyclesExceededand exits 1. STOREoperand order was documented backwards in the README and on the website —STORE addr Rddoes not assemble; the correct form isSTORE Rd addr. The website also describedSTRwith its operands reversed.programs/screen.ncbwas missing — the only example program without a compiled binary.
Added
--max-cycles <N>to raise or lower the 1024-cycle budget.screen.ncaalready uses 689 of the default.EmulatorError::MaxCyclesExceeded { cycles }.
Changed
- Dropped the
hexdependency in favour ofu8::from_str_radix. Op::instruction_lenno longer has a catch-all arm. Adding an opcode without giving it a length is now a compile error rather than a silent 1-byte default that desynchronises the PC.
Breaking
EmulatorErrorgained a variant — exhaustivematches need a new arm.NanoCoregained a publicmax_cyclesfield — struct-literal construction breaks; useNanoCore::new().NanoCore::run()now returnsErr(MaxCyclesExceeded)where it previously returnedOk(()). Programs that relied on silently hitting the cap will start failing; pass--max-cyclesto raise it.