News for hackers. Stuff that matters.
Re:Implement an emulator for a fantasy CPU in JavaScript by dnautics on Monday August 24, 2020 @12:42PM (#24262411)
yes, 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.

There are no comments on this comment yet.