Something went wrong. Try again.
A cycle-accurate Apple II and Apple IIgs emulator written in Zig, usable as both a program and a library.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546// SPDX-FileCopyrightText: 2026 Jeffrey C. Ollie <jeff@ocjtech.us>//// SPDX-License-Identifier: MIT
/// Describes one instruction: its mnemonic, and every opcode that selects it/// together with that opcode's addressing mode and cycle count. Opcodes/// collects these at comptime to build the dispatch table.pub fn data(comptime CPU: type) type { return struct { pub const mnemonic = "NOP"; pub const opcodes = [_]CPU.Opcodes.Init{ .{ .opcode = 0xea, .addressing_mode = .Implied, .cycles = 2, }, };
/// The implementation for a single addressing mode. Resolved at /// comptime so the dispatch table holds a plain function pointer with /// no mode left to branch on at runtime. pub fn func( comptime addressing_mode: CPU.AddressingModes, comptime widths: ?CPU.Widths, ) *const fn (*CPU) CPU.Opcodes.Error!void { if (addressing_mode != .Implied) @compileError("illegal addressing mode"); _ = widths; const f = struct { /// Does nothing, in two cycles. /// /// Unlike the NMOS 6502, where a great many undefined /// encodings did nothing by accident, this is the only one /// here that does nothing on purpose. The 65816 decodes all /// 256, and the ones its designers had no use for became /// WDM — reserved, and specified to do nothing but take its /// bytes — rather than being left to do whatever the silicon /// happened to do. pub fn NOP(cpu: *CPU) !void { cpu.program_counter.internal(); } }; return f.NOP; } };}