Quote:
Delegation and aggregation can do anything and everything that inheritance can do. However, for such a limited scope application as this, why are you using delegation? Does C# not provide inheritance?
Just curious, because if your code is portable enough, I can perhaps volunteer some amount of time to get it running under LInux.
Actually, I started out with the inheritance model but to do so means I have to make all my methods virtual. At least, in C#, after exhaustive performance tested, the virtual methods added 30% overhead, in some cases, even more. If enough of the methods in the call stack were virtual, rather than getting 800,000 iteration/sec on the adc/bit/rol opcodes I was getting 150,000. Remove the three virtual calls in the call chain and it jumps to 750,000 -- 820,000 max on my PIII 1Ghz 512MB Ram. Delegates are roughly the same as virtual methods in terms of performance. When optimizing. always look for the bottlenecks. In this case, every method on the CPU core is the inner loop, so it has to be tight. I found myself obfuscating the C# beyond maintanency to gain performance and I don't have those problems in C++.
Concerning C++. I haven't run any benchmarks on that core yet. I don't know how much overhead it adds.
Okay. I am intending to write the core in C++ seperated from any specific technology. The cpu_65c02.cpp file is raw C++. Because it isn't easy to mix manged/unmanaged in the way I desire, I have to aggregate. So I have another cpu_65c02_managed.cpp file that created a managed object that (can't inherit an unmanged object) so it has to create a class-member object of type cpu_65c02 and then aggregate the calls. But that adds overhead because the .NET runtime has to marshal the pointers. I can interop into a dll but that also adds roughly the same performance overhead (not as significant as the C# overhead).
Personally, I think the CPU cores should be portable to any platform, its just for my purposes, I'm abstracting the managed layer away for that use but I'm not going to tie it into the main CPU core and I'm not going to use COM. COM is a mess.
As a win32 assembly programmer, I can probly do the CPU in asm but I want to keep it easier to maintain. If I need that kind of performance I'll hand optimize the code in question in asm if needed. However, the optimizer has to be plugable to the CPU in some way. This way, myself or others can write other optimizers. Like I said, I'm not the best C++ programmer so I'm trying to figure all this stuff out. In C#, no problem, it's easy.
I'm not against require the CPU core to be inherited but in the C# world, by doing so, I'll need to override some methods and that adds more overhead than I am confortable with.
If you are truly willing to help, I can share my design notes with you and we can hammer this out together. If I can figure out how to install RedHat 9 in my Virtual PC (I keep getting problems) then I'm more than willing to work it out. Just remembre, primarily, I'm a Windows developer with Windows specific goals in mind. But I'm more than happy to make it portable in what ways I can. The best way, is to design it that way and not have too much platform specific code integrated into the cores or the memory manager. Currencly, in my C++ design, the only platform specific code I have is two API's for the high-resolution frequency timer.
But, I haven't figured out a good or successful way to throttle the CPU to 1/2MHz yet. I also haven't found anyone willing to help me with that area (even explain to me a technique) and examine the code to MAME, Nestopia and others are too difficult for me to isolate the relevent code or identify the general technique.
Thanks,
Leabre