Skip to main content


Every time I return home from a conference, I have a ton of materials to read, things to watch, ideas to try.

Someone suggested a little experiment and so, here I am, writing a uxn emulator in uxn. I think it might be feasible to implement Varvara's Bicycle without making use of any of the more esoteric features of the system, so I can finally get rid of that extra chunck of code from the specs altogether.
in reply to Devine Lu Linvega

Me: "Holy shit, implementing uxn in uxn is like.. wow, a match made in heaven, I can't believe the symmetry of the opcodes and.. wait, right. No that makes sense."
in reply to Devine Lu Linvega

I pinky promise, once I'm done with the new implementation of #Uxn, I'll write an implementation guide. There's a trick to implementing the opcodes quickly.

https://git.sr.ht/~rabbits/blinkengenie/tree/main/item/src/bligen.tal
#uxn
in reply to Devine Lu Linvega

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.
in reply to Devine Lu Linvega

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.
in reply to Devine Lu Linvega

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. :goose_hacker:
in reply to Kit Rhett Aultman

@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 😀
in reply to Devine Lu Linvega

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.
in reply to Devine Lu Linvega

someone did write an 8080 emulator for the 6502, which is pretty close. it took less than 1KB, which is pretty awesome
in reply to Devine Lu Linvega

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

https://www.pagetable.com/docs/8080sim/An%208080%20Simulator%20for%20the%206502,%20KIM-1%20Version.pdf
in reply to Devine Lu Linvega

ditto! here's Pagetable's coverage of it, wherein the author explains:
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”… ;)

Lo, thar be cookies on this site to keep track of your login. By clicking 'okay', you are CONSENTING to this.