diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..db69ff2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,78 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1706063522, + "narHash": "sha256-o1m9en7ovSjyktXgX3n/6GJEwG06WYa/9Mfx5hTTf5g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "95c1439b205d507f3cb88aae76e02cd6a01ac504", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "zig2nix": "zig2nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "zig2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1713576181, + "narHash": "sha256-vYvot66I7+58YjWaQldcZfNh4H2Mj2eE+PpYTjncBac=", + "owner": "Cloudef", + "repo": "zig2nix", + "rev": "59edca8316d1c395ac05474489b8ea9f26ebd53c", + "type": "github" + }, + "original": { + "owner": "Cloudef", + "repo": "zig2nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/src/main.zig b/src/main.zig index f648ad6..6d06f57 100644 --- a/src/main.zig +++ b/src/main.zig @@ -7,32 +7,32 @@ pub fn main() !void { var uxn = Uxn{ .mem = try allocator.alloc(u8, 0xFFFF), - .ws = try allocator.alloc(u8, 0xFF), - .rs = try allocator.alloc(u8, 0xFF), - .wsp = 0, - .rsp = 0, + .ws = .{ + .s = try allocator.alloc(u8, 0xFF), + .sp = 0, + }, + .rs = .{ + .s = try allocator.alloc(u8, 0xFF), + .sp = 0, + }, .pc = 0x0100, }; defer allocator.free(uxn.mem); - defer allocator.free(uxn.ws); - defer allocator.free(uxn.rs); + defer allocator.free(uxn.ws.s); + defer allocator.free(uxn.rs.s); while (true) uxn.loop(); } pub const Uxn = struct { mem: [0xFFFF]u8, - // ws: [0xFF]u8, - // rs: [0xFF]u8, - // wsp: u8, - // rsp: u8, ws: Stack, rs: Stack, pc: u16, const Stack = struct { - s: *[0xFF]u8, - sp: *u8, + s: [0xFF]u8, + sp: u8, pub fn peek(self: *Stack, comptime T: type) T { return switch (T) { @@ -555,3 +555,124 @@ pub const Uxn = struct { stack.push(T, (a >> right) << left); } }; + +test "uxnasm" { + const rom = [_]u8{ + 0xa0, 0x01, 0x07, 0x80, 0x10, 0x37, 0x00, 0x80, 0x12, 0x16, 0x06, 0x20, 0x00, 0x05, 0x02, 0x60, + 0x00, 0x65, 0x00, 0x60, 0x00, 0x01, 0x00, 0x80, 0x20, 0x8a, 0x0c, 0x04, 0x02, 0x80, 0x20, 0x07, + 0x80, 0xfb, 0x13, 0x26, 0xa0, 0x20, 0x20, 0x28, 0x20, 0x00, 0x42, 0x80, 0x20, 0x09, 0x20, 0x00, + 0x1c, 0x06, 0x80, 0x5b, 0x08, 0x20, 0x00, 0x1a, 0x06, 0x80, 0x5d, 0x08, 0x20, 0x00, 0x13, 0x06, + 0x80, 0x28, 0x08, 0x20, 0x00, 0x29, 0x06, 0x80, 0x29, 0x08, 0x20, 0x00, 0x22, 0x80, 0x01, 0x20, + 0x00, 0x02, 0x02, 0x6c, 0x80, 0x20, 0x07, 0x80, 0xfb, 0x13, 0x26, 0xa0, 0x20, 0x20, 0x28, 0x20, + 0x00, 0x0b, 0x02, 0x80, 0x00, 0xa0, 0x08, 0x6b, 0xb5, 0x21, 0x80, 0xf9, 0x33, 0x22, 0x6c, 0x80, + 0x28, 0x19, 0xa0, 0x01, 0x4e, 0x15, 0x6c, 0xa0, 0x01, 0x66, 0x34, 0x21, 0x26, 0xa0, 0x04, 0x1a, + 0x35, 0xa0, 0x04, 0x51, 0x35, 0xa0, 0x08, 0x6b, 0x60, 0x04, 0x6d, 0x80, 0x01, 0x60, 0x00, 0x91, + 0x20, 0x00, 0x85, 0x80, 0x00, 0x60, 0x00, 0x89, 0x20, 0x00, 0x7d, 0xa0, 0x80, 0x00, 0x80, 0x62, + 0x30, 0x21, 0x38, 0xa0, 0x81, 0x00, 0x94, 0x80, 0x18, 0x17, 0x21, 0xa9, 0x20, 0xff, 0xf7, 0x22, + 0x22, 0xa0, 0x04, 0x1a, 0x34, 0xa0, 0x04, 0x51, 0x34, 0xa1, 0x21, 0x14, 0x20, 0x00, 0x26, 0xa0, + 0x00, 0x03, 0x38, 0x94, 0x80, 0x41, 0x19, 0x80, 0x1a, 0x0b, 0x20, 0x00, 0x18, 0x26, 0xa0, 0x06, + 0x5e, 0x60, 0x03, 0xd1, 0x20, 0x00, 0x0e, 0xa0, 0x06, 0x52, 0x60, 0x04, 0x3d, 0x26, 0x60, 0x04, + 0x3e, 0xa0, 0x0a, 0x19, 0x17, 0x60, 0x03, 0xb1, 0x21, 0xaa, 0x20, 0xff, 0xcc, 0x22, 0x22, 0xa0, + 0x06, 0x64, 0x60, 0x04, 0x25, 0x80, 0x62, 0x30, 0xa0, 0x00, 0xff, 0x39, 0x60, 0x04, 0x26, 0xa0, + 0x06, 0x74, 0x60, 0x04, 0x15, 0xa0, 0x04, 0x34, 0x34, 0x60, 0x04, 0x19, 0xa0, 0x06, 0x80, 0x60, + 0x04, 0x08, 0xa0, 0x06, 0x7c, 0x60, 0x04, 0x02, 0xa0, 0x80, 0x66, 0x10, 0x1d, 0x80, 0x0f, 0x17, + 0x6c, 0x80, 0x67, 0x11, 0xa0, 0x01, 0x00, 0x60, 0x01, 0x24, 0x80, 0x00, 0xa0, 0x05, 0x6a, 0x15, + 0xa0, 0x06, 0x5e, 0x60, 0x01, 0x94, 0xa0, 0x08, 0x6b, 0x26, 0x80, 0x64, 0x31, 0x26, 0x60, 0x00, + 0x13, 0x80, 0x66, 0x10, 0x20, 0x00, 0x08, 0x60, 0x03, 0x4f, 0x21, 0x94, 0x20, 0xff, 0xea, 0x22, + 0x80, 0x66, 0x10, 0x6c, 0x94, 0x80, 0x08, 0x13, 0xa0, 0x07, 0x6b, 0xa0, 0x07, 0x3b, 0x94, 0x80, + 0x00, 0x09, 0x20, 0x00, 0x04, 0x23, 0x21, 0x34, 0x2c, 0xa0, 0x00, 0x03, 0x38, 0xaa, 0x20, 0xff, + 0xed, 0x22, 0x22, 0x60, 0x02, 0x71, 0x20, 0x00, 0x8f, 0x60, 0x02, 0x81, 0x20, 0x00, 0x6e, 0x40, + 0x00, 0x4e, 0x21, 0x60, 0x01, 0xf3, 0x40, 0x00, 0xc5, 0x21, 0x60, 0x01, 0xec, 0x80, 0x60, 0x30, + 0x38, 0x40, 0x00, 0xba, 0x21, 0x40, 0x01, 0x32, 0x21, 0x60, 0x01, 0x0c, 0x40, 0x01, 0x5a, 0x80, + 0x80, 0x60, 0x00, 0x9b, 0x21, 0x60, 0x02, 0x1b, 0x40, 0x00, 0x94, 0x80, 0x80, 0x60, 0x00, 0x8f, + 0x21, 0x60, 0x01, 0xce, 0x03, 0x40, 0x00, 0x87, 0x80, 0xa0, 0x60, 0x00, 0x82, 0x21, 0x60, 0x01, + 0xc1, 0x40, 0x00, 0x77, 0x21, 0x80, 0x20, 0x40, 0x00, 0x65, 0x21, 0x80, 0x40, 0x40, 0x00, 0x5f, + 0x80, 0x60, 0x40, 0x00, 0x5a, 0x21, 0x40, 0x00, 0x1a, 0x21, 0x40, 0x00, 0x0a, 0x22, 0x40, 0x02, + 0xa1, 0x6c, 0x94, 0x60, 0x00, 0x59, 0x21, 0x94, 0x20, 0xff, 0xf7, 0x22, 0x6c, 0x60, 0x02, 0x1e, + 0x40, 0x00, 0x4c, 0x26, 0x60, 0x02, 0xa7, 0x03, 0x06, 0x80, 0x04, 0x08, 0x80, 0x50, 0x1f, 0x80, + 0x80, 0x1d, 0x60, 0x00, 0x3a, 0x40, 0x00, 0x05, 0x26, 0x60, 0x02, 0x92, 0x03, 0x06, 0x80, 0x02, + 0x09, 0x20, 0x00, 0x08, 0x02, 0x60, 0x02, 0xca, 0x03, 0x40, 0x00, 0x23, 0x80, 0x04, 0x09, 0x20, + 0x00, 0x06, 0x60, 0x02, 0xbd, 0x40, 0x00, 0x13, 0x22, 0xa0, 0x06, 0x9d, 0x40, 0x00, 0x23, 0x60, + 0x00, 0x0d, 0x60, 0x01, 0x4d, 0x80, 0x60, 0x30, 0x21, 0x21, 0x39, 0x04, 0x60, 0x00, 0x00, 0x06, + 0x80, 0x60, 0x30, 0xa1, 0x2f, 0xa0, 0x80, 0x00, 0x38, 0x15, 0x60, 0x00, 0x31, 0x6f, 0x80, 0x60, + 0x31, 0x6c, 0xa0, 0x06, 0x88, 0x60, 0x02, 0xc2, 0x60, 0x02, 0xbf, 0xa0, 0x20, 0x19, 0x17, 0x80, + 0x64, 0x30, 0x60, 0x02, 0xba, 0xa0, 0x06, 0x6f, 0x60, 0x02, 0xaf, 0x80, 0x00, 0x30, 0x60, 0x02, + 0xae, 0xa0, 0x2e, 0x19, 0x17, 0xa0, 0x0a, 0x19, 0x17, 0xa0, 0x01, 0x66, 0x11, 0x6c, 0x20, 0x00, + 0x01, 0x6c, 0x80, 0x67, 0x10, 0x20, 0x00, 0x01, 0x6c, 0x80, 0x60, 0x30, 0x26, 0x07, 0x20, 0x00, + 0x06, 0xa0, 0x06, 0xce, 0x60, 0xff, 0xbb, 0xa0, 0x80, 0x00, 0x2b, 0x20, 0x00, 0x06, 0xa0, 0x06, + 0xa4, 0x60, 0xff, 0xae, 0x80, 0x62, 0x31, 0x6c, 0x26, 0x60, 0x01, 0xf2, 0xa0, 0x00, 0x30, 0x60, + 0x01, 0xec, 0x38, 0xa0, 0x00, 0x30, 0x2b, 0x20, 0x00, 0x06, 0xa0, 0x06, 0xb5, 0x40, 0xff, 0x92, + 0xa0, 0x00, 0x00, 0x60, 0x02, 0x45, 0xa0, 0x00, 0x30, 0x6c, 0x26, 0xc0, 0x00, 0x94, 0x80, 0x2f, + 0x08, 0x20, 0x00, 0x09, 0x94, 0xcf, 0x11, 0x41, 0x21, 0x94, 0x20, 0xff, 0xf0, 0x22, 0x80, 0x00, + 0x4f, 0x11, 0xa0, 0x00, 0x00, 0xa0, 0x00, 0x30, 0x60, 0x02, 0x20, 0xa0, 0x2f, 0x00, 0xa0, 0x00, + 0x30, 0x60, 0x01, 0xa5, 0xa1, 0x80, 0xc9, 0x33, 0x35, 0x80, 0x67, 0x10, 0x20, 0x00, 0x02, 0x22, + 0x6c, 0x60, 0x00, 0xe3, 0x20, 0x00, 0x34, 0x60, 0x00, 0xf3, 0x20, 0x00, 0x2e, 0x26, 0x60, 0x00, + 0x38, 0x21, 0x1d, 0x20, 0x00, 0x2c, 0x80, 0x60, 0x30, 0xa0, 0x00, 0x00, 0xaf, 0x61, 0x61, 0x35, + 0x80, 0x00, 0xef, 0x61, 0x15, 0x26, 0xef, 0x60, 0x01, 0xe1, 0x60, 0x01, 0x71, 0x6f, 0x38, 0x21, + 0x80, 0xe7, 0x33, 0xa0, 0x00, 0x00, 0x21, 0x80, 0xfa, 0x33, 0x6c, 0x22, 0xa0, 0x06, 0xc7, 0x40, + 0xff, 0x10, 0x22, 0xa0, 0x06, 0x93, 0x40, 0xff, 0x09, 0x80, 0x11, 0x33, 0xa0, 0x04, 0x1a, 0x34, + 0xa0, 0x00, 0x00, 0xa8, 0x20, 0x00, 0x16, 0xa0, 0x00, 0x03, 0x38, 0x26, 0xa0, 0x00, 0x00, 0x60, + 0x01, 0x43, 0x20, 0x00, 0x0e, 0x60, 0x01, 0x31, 0x21, 0xaa, 0x20, 0xff, 0xe6, 0x22, 0x22, 0xa0, + 0xff, 0xff, 0x6c, 0xa0, 0x00, 0x03, 0x39, 0x23, 0x6c, 0x60, 0x00, 0x6b, 0x20, 0x01, 0x63, 0x40, + 0x00, 0x11, 0x94, 0x80, 0x7b, 0x09, 0x20, 0x00, 0x04, 0x22, 0x60, 0x00, 0xdc, 0x80, 0x67, 0x10, + 0x20, 0x00, 0x29, 0x94, 0x80, 0x26, 0x09, 0x20, 0x00, 0x04, 0x21, 0x60, 0xff, 0x0a, 0x94, 0x80, + 0x2f, 0x09, 0x20, 0x00, 0x04, 0x21, 0x60, 0xfe, 0xff, 0x60, 0xff, 0x9d, 0xa1, 0xa0, 0x00, 0x00, + 0x28, 0x20, 0x00, 0x09, 0xa1, 0x21, 0x94, 0x01, 0x05, 0x05, 0x15, 0x34, 0x6c, 0xa0, 0x06, 0xab, + 0x40, 0xfe, 0x8f, 0x60, 0xff, 0xbc, 0x80, 0x60, 0x30, 0x21, 0x21, 0x39, 0x26, 0xa0, 0x00, 0x80, + 0x38, 0x02, 0x20, 0x00, 0x02, 0x03, 0x6c, 0x80, 0x67, 0x10, 0x20, 0x00, 0x06, 0xa0, 0x06, 0xbe, + 0x60, 0xfe, 0x6f, 0x22, 0x80, 0xff, 0x6c, 0x26, 0x94, 0x60, 0x00, 0xde, 0x01, 0x20, 0x00, 0x04, + 0x22, 0x80, 0x00, 0x6c, 0x21, 0x94, 0x20, 0xff, 0xef, 0x22, 0x80, 0x01, 0x6c, 0x26, 0x60, 0x00, + 0x0d, 0x20, 0x00, 0x07, 0x26, 0xa0, 0x07, 0x38, 0x40, 0x00, 0xb0, 0x80, 0x01, 0x6c, 0x26, 0x80, + 0x0e, 0x33, 0xa0, 0x20, 0x00, 0x80, 0x00, 0x07, 0x80, 0x03, 0x1a, 0xa0, 0x06, 0xd8, 0x38, 0xa0, + 0x00, 0x00, 0x60, 0x00, 0x96, 0x20, 0x00, 0x0a, 0x01, 0x8a, 0x20, 0xff, 0xe8, 0x22, 0x22, 0x80, + 0x00, 0x6c, 0x03, 0x06, 0x80, 0x00, 0x08, 0x80, 0x70, 0x1f, 0x1d, 0x0f, 0xa0, 0x00, 0x03, 0x38, + 0x94, 0x20, 0x00, 0x03, 0x22, 0x4f, 0x6c, 0x94, 0x80, 0x32, 0x09, 0x20, 0x00, 0x03, 0xc0, 0x20, + 0x5d, 0x94, 0x80, 0x6b, 0x09, 0x20, 0x00, 0x03, 0xc0, 0x80, 0x5d, 0x94, 0x80, 0x72, 0x09, 0x20, + 0x00, 0x03, 0xc0, 0x40, 0x5d, 0x21, 0x40, 0xff, 0xd7, 0x80, 0x00, 0x81, 0x80, 0xfb, 0x13, 0x06, + 0xa0, 0x07, 0x6b, 0xa1, 0x80, 0xfa, 0x33, 0x15, 0x80, 0x21, 0x18, 0x80, 0x18, 0x13, 0xa0, 0x05, + 0x94, 0x6c, 0x80, 0xec, 0x32, 0xa0, 0x00, 0x01, 0x39, 0x94, 0x60, 0xff, 0xeb, 0x60, 0xfe, 0x69, + 0x80, 0xde, 0x33, 0x6c, 0xce, 0xbb, 0x00, 0x00, 0x21, 0x94, 0x20, 0xff, 0xfb, 0x6c, 0x26, 0x60, + 0xff, 0xf7, 0x24, 0x39, 0x6c, 0x2f, 0x94, 0x20, 0x00, 0x05, 0x14, 0x54, 0x4f, 0x08, 0x6c, 0x94, + 0xd4, 0x4f, 0x09, 0x20, 0xff, 0xf4, 0x21, 0x61, 0x40, 0xff, 0xeb, 0x2f, 0xd4, 0x94, 0x4f, 0x09, + 0x20, 0x00, 0x02, 0x61, 0x21, 0x74, 0x34, 0x6f, 0x28, 0x6c, 0x80, 0x30, 0x19, 0x06, 0x80, 0x0a, + 0x0b, 0x20, 0x00, 0x0d, 0x80, 0x27, 0x19, 0x06, 0x80, 0x10, 0x0b, 0x20, 0x00, 0x03, 0x02, 0x80, + 0xff, 0x6c, 0xe0, 0x00, 0x00, 0xc0, 0x40, 0x7f, 0x94, 0x60, 0xff, 0xde, 0xc0, 0x00, 0x0f, 0x78, + 0x21, 0x94, 0x20, 0xff, 0xf0, 0x22, 0x6f, 0x6c, 0x80, 0x00, 0x05, 0x05, 0x94, 0x80, 0x20, 0x0a, + 0x20, 0x00, 0x01, 0x95, 0x21, 0x94, 0x20, 0xff, 0xf3, 0x15, 0x6c, 0x2f, 0x94, 0x80, 0x00, 0xef, + 0x35, 0x61, 0x21, 0x94, 0x20, 0xff, 0xf5, 0x22, 0x62, 0x6c, 0x94, 0x80, 0x19, 0x17, 0x21, 0x94, + 0x20, 0xff, 0xf7, 0x22, 0x6c, 0xa0, 0x27, 0x10, 0xe0, 0x00, 0xfb, 0xbb, 0xa0, 0x00, 0x0a, 0xbb, + 0x3a, 0x39, 0x44, 0x88, 0x07, 0xcf, 0x08, 0x1c, 0x20, 0x00, 0x08, 0x06, 0x80, 0x30, 0x18, 0x80, + 0x19, 0x17, 0x41, 0x22, 0xa0, 0x00, 0x0a, 0x3b, 0x44, 0x41, 0xcf, 0x20, 0xff, 0xdd, 0x62, 0x22, + 0x22, 0x6c, 0x2d, 0x2d, 0x20, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x3a, 0x20, 0x00, 0x52, 0x45, + 0x53, 0x45, 0x54, 0x00, 0x41, 0x73, 0x73, 0x65, 0x6d, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x00, 0x20, + 0x69, 0x6e, 0x20, 0x00, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x28, 0x00, 0x29, 0x2e, 0x0a, 0x00, + 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x00, 0x21, 0x21, 0x20, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x3a, 0x20, 0x00, 0x44, 0x75, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x00, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x00, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x00, 0x53, 0x75, 0x62, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x00, 0x44, 0x69, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x00, 0x5a, 0x65, + 0x72, 0x6f, 0x2d, 0x70, 0x61, 0x67, 0x65, 0x00, 0x4c, 0x49, 0x54, 0x49, 0x4e, 0x43, 0x50, 0x4f, + 0x50, 0x4e, 0x49, 0x50, 0x53, 0x57, 0x50, 0x52, 0x4f, 0x54, 0x44, 0x55, 0x50, 0x4f, 0x56, 0x52, + 0x45, 0x51, 0x55, 0x4e, 0x45, 0x51, 0x47, 0x54, 0x48, 0x4c, 0x54, 0x48, 0x4a, 0x4d, 0x50, 0x4a, + 0x43, 0x4e, 0x4a, 0x53, 0x52, 0x53, 0x54, 0x48, 0x4c, 0x44, 0x5a, 0x53, 0x54, 0x5a, 0x4c, 0x44, + 0x52, 0x53, 0x54, 0x52, 0x4c, 0x44, 0x41, 0x53, 0x54, 0x41, 0x44, 0x45, 0x49, 0x44, 0x45, 0x4f, + 0x41, 0x44, 0x44, 0x53, 0x55, 0x42, 0x4d, 0x55, 0x4c, 0x44, 0x49, 0x56, 0x41, 0x4e, 0x44, 0x4f, + 0x52, 0x41, 0x45, 0x4f, 0x52, 0x53, 0x46, 0x54, 0x42, 0x52, 0x4b, 0x7c, 0x02, 0x82, 0x24, 0x02, + 0x89, 0x40, 0x02, 0x94, 0x26, 0x02, 0x98, 0x23, 0x02, 0xd5, 0x7d, 0x02, 0xdd, 0x2c, 0x02, 0x9f, + 0x5f, 0x02, 0xa4, 0x2e, 0x02, 0xab, 0x2d, 0x02, 0xb0, 0x3b, 0x02, 0xb8, 0x3d, 0x02, 0xbd, 0x3f, + 0x02, 0xc4, 0x21, 0x02, 0xca, 0x22, 0x02, 0xd9, 0x7e, 0x02, 0xe1, + }; + + const mem: [0xFFFF]u8 = undefined; + const ws: [0xFF]u8 = undefined; + const rs: [0xFF]u8 = undefined; + var uxn = Uxn{ + .mem = mem, + .ws = .{ .s = ws, .sp = 0 }, + .rs = .{ .s = rs, .sp = 0 }, + .pc = 0x100, + }; + @memcpy(uxn.mem[0x100 .. 0x100 + rom.len], &rom); + + while (true) uxn.loop(); +}