Page 1 of 1

Blinky robot with emulated 6502

Posted: Tue Dec 20, 2022 6:58 pm
by Druzyek
Just for fun, I made a blinky robot with a PIC32 emulating a 6502. Pictures and description on my blog.
blinky-robot-front.jpg
The PIC32 is running a 65C02 emulator I wrote in MIPS assembly. Partly to test the emulator, I got Tali Forth 2 running on it and now use QEMU for MIPS so I can have Tali Forth 2 in my Linux terminal (blog post here). MIPS assembly is now my favorite assembly of all and a lot of fun to use.

The 65C02 program running inside the emulator is itself a 65C02 emulator (GitHub link). On the code I tested, it emulates at about 1/20th the speed of the real thing. When this emulator starts, it points to its own program code so you get an emulator in an emulator. Each new emulator emulates another emulator until it's five levels deep. The fifth level of emulation runs a tight loop blinking the LED eyes on and off as fast as possible. All the layers of emulation combine to reduce the execution speed down to a few hertz so the blink rate is once every 2 seconds or so.

Emulator 1 (MIPS) -> Emulator 2 (65C02) -> Emulator 3 (65C02) -> Emulator 4 (65C02) -> Emulator 5 (65C02) -> Emulator 6 (65C02) -> Blinky (65C02)

Re: Blinky robot with emulated 6502

Posted: Tue Dec 20, 2022 9:53 pm
by BigEd
Most obscure way to manage a timing loop!

Re: Blinky robot with emulated 6502

Posted: Tue Dec 20, 2022 10:48 pm
by BigDumbDinosaur
Yes, but can it brew beer?

Re: Blinky robot with emulated 6502

Posted: Wed Dec 21, 2022 3:24 pm
by Dr Jefyll
BigEd wrote:
Most obscure way to manage a timing loop!
I'll say it is!

Brilliantly perverse.

Makes me think of the omni-computer in the Douglas Adams books, "Hitchhiker's Guide To the Galaxy." Could it have been because of nested emulations that Deep Thought took centuries to deliver the enigmatic answer, forty-two? :lol:

-- Jeff

Re: Blinky robot with emulated 6502

Posted: Sat Dec 24, 2022 1:34 pm
by Druzyek
Hehe, could be, Dr Jefyll! I was thinking more like the movie Inception or The Matrix if the humans in the matrix had invented machines again and the machines made a matrix in that matrix.