Changes to v12.js (JavaScript TI-68k emulator, GPL-2.0-or-later) Modified 2026-11-08 for the TI-89 Titanium Online website. Why: the unmodified core computed wrong results inside PedroM. Examples before the fix: 123456789*987654321 = 121862266663424901 (correct: 121932631112635269) 65535*65535 = 8589803521 (correct: 4294836225) 25!, 2^100, 100! wrong digits PedroM shell: 5^3 = 107.82..., ln(2) = 0.2796... Every one of these was a 68000 condition-code or arithmetic emulation error. After the changes the results above are correct. What was changed (all in TI68kEmulatorCoreModule): ADDX, SUBX Z flag: cleared when the result is nonzero, unchanged otherwise (SUBX used the wrong mask 0xFFBF and never cleared Z; ADDX cleared it for every result). SUB, SUBI, CMP, CMPI, CMPA, CMPM V (overflow) flag wrong when the source was 0x80 / 0x8000 / 0x80000000. NEG N flag for longs tested mask 0x7FFFFFFF instead of 0x80000000; V never set. NEGX X and C never set; Z handling as ADDX/SUBX. CLR N, V, C were not cleared. EXT.W, EXT.L, SWAP N and Z were not set, V and C not cleared. DIVS quotient rounded toward minus infinity instead of toward zero; N not set for a negative quotient. ABCD, SBCD Dy,Dx "d += op(d,s) - d & 0xFF" (JavaScript precedence) corrupted the upper 24 bits of Dx. NBCD X and C not set for 0 - 99 - X. ROXR C was set whenever the result was negative; it must be a copy of X. Shifts/rotates by a register count count taken modulo 32 instead of 64; a zero count must clear C (ROXL/ROXR: C = X), leave X unchanged and clear V. How it was checked: tests/engine/ runs the core's own decoded instructions against the M68000PRM semantics (about 200 instruction groups, every size, register/immediate/memory forms, random and edge operands). Run from the project root: node tests/engine/run.cjs tests/engine/patch-v12.cjs re-applies these changes to an unmodified upstream v12.js. Not fixed (PedroM itself, not the emulator): decimal results of the zs maths engine (evalf, approx) are wrong or crash it, and the plain shell's sqrt is inaccurate (sqrt(16) = 3.9966).