https://github.com/lunarlabs/EightSixteenEmu
This is a dumb little work in progress just for fun thing I'm making. Its major feature that I'm designing this around is modularity in the memory map -- instead of having a hardcoded memory map configuration, you assign devices to memory address ranges. At this stage it's very basic -- I just finished adding all the opcodes, but hopefully I can get it to something that actually functions worth a whit.
EightSixteenEmu - modular 65816 emulator
-
White Flame
- Posts: 704
- Joined: 24 Jul 2012
Re: EightSixteenEmu - modular 65816 emulator
Nice, I did similar in my JS 65c02 emulator. If I'm reading your code right, it looks like you've arrived at the same conclusions: Register each address that a device covers individually in a lookup structure.
For JS, I used a default sparse Array, which happened to currently be faster than its other datastructures when integer keys are involved. People in C♯ land have been dealing with this as well: https://stackoverflow.com/a/76915618
Another big win is if all mappable devices are in a known I/O area, so you can have a fixed range check to see if you need to do a device map lookup at all, or just hit RAM directly, since this is such a performance hot spot.
For JS, I used a default sparse Array, which happened to currently be faster than its other datastructures when integer keys are involved. People in C♯ land have been dealing with this as well: https://stackoverflow.com/a/76915618
Another big win is if all mappable devices are in a known I/O area, so you can have a fixed range check to see if you need to do a device map lookup at all, or just hit RAM directly, since this is such a performance hot spot.
Re: EightSixteenEmu - modular 65816 emulator
Well, I'm running into a problem while testing -- I'm using https://github.com/SingleStepTests/65816 as the data to test against...
is it just me or are the MVN/MVP test JSONs in that repository just wrong? For example, the first line in 54.n.json starts with the accumulator at 0xEF9B, but finishes with it at 0xEF8B, and the last two cycles seem to be fetching the opcode and the source byte... Is it just me or does it look like it just recorded the first 100 cycles and gave up? I might have to write separate block move tests if that's the case!
is it just me or are the MVN/MVP test JSONs in that repository just wrong? For example, the first line in 54.n.json starts with the accumulator at 0xEF9B, but finishes with it at 0xEF8B, and the last two cycles seem to be fetching the opcode and the source byte... Is it just me or does it look like it just recorded the first 100 cycles and gave up? I might have to write separate block move tests if that's the case!
Re: EightSixteenEmu - modular 65816 emulator
I find it impossible to say, as the json isn't really meant for human consumption.
Perhaps you could say what you think the test sets out to do, and what you find it actually doing - and perhaps submit an issue on github. If there is a mistake or limitation, it would good to have it explained, or even fixed.
Perhaps you could say what you think the test sets out to do, and what you find it actually doing - and perhaps submit an issue on github. If there is a mistake or limitation, it would good to have it explained, or even fixed.
Re: EightSixteenEmu - modular 65816 emulator
Here's a remarkable thing, which might be useful here, a real 65816 in a lab which you can send a program to - over the web - and get back a trace of 100 cycles of bus activity. 6502 also available.
https://chiplab.emulationonline.com/65816
Of course 100 cycles isn't much, but it's worth the price!
https://chiplab.emulationonline.com/65816
Of course 100 cycles isn't much, but it's worth the price!
Re: EightSixteenEmu - modular 65816 emulator
BigEd wrote:
Here's a remarkable thing, which might be useful here, a real 65816 in a lab which you can send a program to - over the web - and get back a trace of 100 cycles of bus activity. 6502 also available.
https://chiplab.emulationonline.com/65816
Of course 100 cycles isn't much, but it's worth the price!
https://chiplab.emulationonline.com/65816
Of course 100 cycles isn't much, but it's worth the price!
(Comment mostly just here so that I can find chiplab again)
Re: EightSixteenEmu - modular 65816 emulator
BigEd wrote:
Here's a remarkable thing
I have never trusted WDC documentation. Having said that, the '816 datasheet's Table 5-7 (which details cycle by cycle behavior) seems comparatively trustworthy. But even a small omission by them or misinterpretation by me could be enough to upset the apple cart. I really do care about cycle by cycle behavior, especially in corner cases (such as when indexing results in a bank crossing). And here's the ideal solution. Get the answer straight from the horse's mouth!
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
Re: EightSixteenEmu - modular 65816 emulator
With a real CPU in hand, writing a verification suite is so much easier: if it passes on the real thing, it's right! You still have to cook up an adequate set of tests, of course.
Re: EightSixteenEmu - modular 65816 emulator
Could be interesting. The "initial state" setups wouldn't work so I'd have to write a whole burn in suite.
Re: EightSixteenEmu - modular 65816 emulator
Tests have passed, so at least on a very rough level, it's cycle and logic compatible now.
Now I have to get onto working on devices -- most importantly a UART emulator that has a processor-facing interface similar to a real-world chip. Only question is what UART chip should I emulate?
Edit: I know some of you guys swear by the 28L92 but HOLY COW that's going to be a real bear to emulate!!
Now I have to get onto working on devices -- most importantly a UART emulator that has a processor-facing interface similar to a real-world chip. Only question is what UART chip should I emulate?
Edit: I know some of you guys swear by the 28L92 but HOLY COW that's going to be a real bear to emulate!!