I am thinking about making a CPU emulator
-
Hi, i just want to experiment with CPU emulation by programming a simple cpu/system emulator on FUZE.
I don't have any particular cpu architecture in mind now, but i want to hear some suggestions from you about making this sort of programs.
I have studied some cpu architectures (8086, m68k and some risk v and 6502), but i have never tryed to do an emulator program, and i am not so mutch familiar with things like managing stacks and subroutine jumps and returns, so i need some help there.
My objective is to implement an 8 or a 16 bit architecture, with not that mutch instructions and with a decent number of general purpose registers, with a 16 bit memory addressing bus, reguarding the emulated system i'd like to have a memory mapped screen buffer witch can be switched beetween text or graphics mode) and to have access to the keyboard input (but not all the keys because it's important to have something to control the cpu execution), and some joycon buttons, so just to allow me to maybe create some simple programs which can have some user interaction.
The emulator itself must have complete registers debug and an hex memory view, and clock cycle stepping, suggestions for debug features are welcome.
Ideally i'd like to implement an 8086 emulator, because that's one of my favorite architectures, but i don't like how complex the instruction decoding is on it and also how many instructions it has, for fuze i just like something simple, other achitectures which came to my mind are risc v, with the 32 bit bare minimum instructions set and the 6502 architecture.
my questions now are:
What about implementing a cpu object as a strct?
What about having a 2^16 elements integer array in fuze?
How fast do you think it can be?
What about vblanks and interrupts? How do you manage a simple screen?So what about this project? any ideas about it? Any reccomendations from you emulator or programming experts?
I'd just like to have a pretty rudimental system emulator for now, just to have some software programmed in an hardcoded part of the ram array and having it to run, i'd be happy to have just a simple thing drawn to screen and a simple demo to test the istructions of the cpu -
Can you please do a Z80 emulator and then someone can make a Fuze ZX Spectrum emulator? ;)
tbh its light years out of my league but I wish you well with it. good luck! -
one of the first emulators i ever wrote was for space invaders back in 1999. i tried a fuze version but even with no cpu, updating the screen was terribly slow
-
I love this idea please send me a friend request if you start I'd love to test and help if I can SW-0913-0584-7700
-
This one is on my todo list as well. As @MikeDX said, it's liable to be really slow. Still a worthwhile endeavor; being able to visually step through 6502 code on my Switch would be lovely. I'm waiting on some kind of case/switch statement before I begin though, as the best way to implement it is probably one huge switch() statement. Otherwise the if/then/else ladder for every instruction in every supported addressing mode would be a nightmare.
-
@ITzTravelInTime So you would like to emulate a cpu So can we run assembly code on it ?
-
@petermeisenstein depends on what his architecture is and what assembly code you have. They have to match.
-
I think one of the coolest things to do would not be to emulate a known physical CPU but emulate a "fantasy" CPU that is of your own design and start from the ground up. A friend of mine did it physically with breadboard and 74 series logic chips last year. It was something incredible to see with all the blinking lights :) I started to do it on FPGA but as with all things, got completely sidetracked and ended up creating FPGA custom video modes instead :D