Kind of a low-level question about bits and such
Hi .. I am writing an emulator for an old computer, and I want to implement a tag for each memory location (max 32K). I am thinking about using something like a ushort or uint that has specific bits defined .. maybe a value field too. Like a "breakpoint" bit. it's a 16 bit machine, so maybe the tag will something like "if the accumulator is equal to" portion. I don't want it to slow down the "CPU" too much (having to lookaside and do a bunch of calculations for each instruction. Got any thoughts on this. (I know how I would do it in assembler, but not sure how well C# handles things like this.) Thanks!
2 Replies
You might get some ideas from existing emulators like https://www.hanselman.com/blog/emulating-a-playstation-1-psx-entirely-with-c-and-net
Emulating a PlayStation 1 (PSX) entirely with C# and .NET
I was reading an older post in an emulator forum where someone was asking for a ...
This is great. I didn't think about using unsafe code to directly access "memory".
After reading some more, I think I will avoid tihis mainly because it may remove device independence from the code.
The old system is slow enough that this will run circles around it. I also decided to have a master debug bool that only checks for debug settings if it is on, and if it is, check for a null/not null in the debig array corresponding to the memory array.
Thank for the suggestion, though. Very cool.