3 ms·
You can use typedarrays, no? I built a fantasy emulator several years ago, and that was my strategy.
by dnautics 6y ago
You can use typedarrays, no? I built a fantasy emulator several years ago, and that was my strategy.
- MuffinFlavored 6y agolike this? const a = new Uint8Array([0xFE]) const b = new Uint8Array([0x02]) a[0] = a[0] + b[0]
- dnautics 6y agoyes, although IIRC what I did was more like this: const r_idx = {ax: 0, bx: 1...} const registers = new Uint8Array([...]) add = (r1, r2) => registers[r_idx[r1]] = registers[r_idx[r1]] + registers[r_idx[r2]] which lets you do: add("ax", "bx") which is one step closer to making it look a lot like asm syntax.