const std = @import("std"); const sys = @import("system.zig"); test "load value into accumulator" { var system: sys.System = .{}; const program = [_]u8{ 0x01, 0x52, // ldai 0x52 }; system.loadProgramRaw(&program); try system.step(); try std.testing.expectEqual(0x52, system.a); } test "load values and check registers afterwards" { var system: sys.System = .{}; const program = [_]u8{ 0x01, 0x01, // ladi 0x01 0x0c, 0x00, 0x02, // mov a, c 0x06, 0x02, // addr c }; system.loadProgramRaw(&program); while (system.read(system.pc) != 0x00) { try system.step(); } try std.testing.expectEqual(2, system.a); try std.testing.expectEqual(1, system.c); } test "load values, add values, jump" { var system: sys.System = .{}; const program = [_]u8{ 0x01, 0x03, // ladi 0x03 0x0c, 0x00, 0x02, // mov a, c 0x0b, 0x02, // cmp c 0x09, 0x11, 0xa9, // jz 0xa911 0x08, 0x15, 0xa9, // jmp 0xa915 }; system.loadProgramRaw(&program); while (system.read(system.pc) != 0x00) { try system.step(); } try std.testing.expectEqual(0x03, system.a); try std.testing.expectEqual(0x03, system.c); try std.testing.expectEqual(0xa911, system.pc); }