Almost passing all the tests with my uxn emulator, written in uxn itself. It's very bizarre project, it makes me wonder if there were 6502 emulators written in 6502.
@neauoire Generally speaking, you don't emulate a CPU on a CPU of the same architecture because you could just run the instructions directly. But what makes most 6502 machines what they are are the peripheral ICs put around the 6502, and an emulator would need to emulate those...you know, implementing the NES PPU on C64 by using the C64 graphics hardware instead.
@neauoire Yeah, the distinctions break down a bit, but "emulate CPU X on CPU X" is kinda how a VM works. You just direct-execute anything that doesn't require emulation and you trap-and-emulate everything that does.
@roadriverrail in this case the memory is all virtual, so I can't just run through the host opcodes, but in a normal situation it's what I would do :)
@neauoire Yeah, this is now a fun question in general. Most (all?) 6502 machines have no MMU and no memory protection; a classic VM can't therefore rely on a trap and would have to scan the binary for load/store ops known to interact with addresses reserved for peripheral ICs and "fix up" those to instead use emulation routines.
@roadriverrail @neauoire somewhere you store compiled basic blocks (runs on instructions without branches) for execution (or more thorough optimisation) later. basic blocks can end up quite a bit longer than one might expect, because of things that are variables at compile time, but known at runtime (eg. constant parameters to a given function call), and that's where the gains come from - turns out a lot of conditionals can be collapsed at runtime, where the values are known just before the code depending on them is compiled
@patrick Oh wow! the vizualizer is soo good! that's kind of what I'm going for here, they've done an excellent job at it.
@neauoire i read a little later and found it - if i'd done so initially i'd have included it too... but it's in kind of a strange format, and hard to read - partly because it's printed on an old drum printer in all uppercase, and partly because the author wrote it by hand and retrofitted his own mnemonics for publication
I wrote this by hand, pencil and paper assembly... and much of the simulator was written as I rode the bus to and from work… ;)
About the tools used to create this program:
Honestly, I don’t remember for certain… BUT… MORE THAN LIKELY, it is a FAKE – i.e., I probably just text-edited a listing in “assembler listing” format for the purpose of publishing the code and “looking professional”… ;)
@neauoire i'm sure someone has had a go at translating it into a more modern (and more machine readable) format, but i can't find it right now. but there's an Apple ][ port online too, to which the article also links, so it could probably be extracted from that
Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.