blargg wrote:
Maybe I was unclear.
On the contrary -- you were crystal.
Quote:
If it passes, great, but if it fails, the author might want to step through the simulated 6502 to find where his simulator is messing up. I'm not seeing how this could be automated.
I'm not trying to be offensive when I say this, but rather honest. Not seeing how it could be automated is not the same as affirming that it cannot be automated. To believe so is just inexperience with automated testing procedures. There are two methods of testing at your disposal: internal and external. Internal testing would rely on the emulated 65816/6502 itself (assuming it is "correct enough" to do so), while External testing relies on instrumenting the simulator itself.
Internal testing depends on some amount of sweat-equity. Basically, you need a certain minimum set of opcodes to implement a unit test framework -- those opcodes need to be verified manually. However, such a framework will positively not rely on ALL of the CPU's instructions and addressing modes. Therefore, you can still rely on the unit testing framework you've written to exercise those instructions.
Once the CPU is verified, then you can use that to do some tests on well-known I/O peripherals too. Indeed, this is what most BIOS ROMs do during their "self-test." RAM size determination, keyboard I/O check, etc. All that isn't
really for the user's benefit. The user couldn't really care less about the adequacy of RAM from boot to boot -- statistics says if it booted before, it'll boot again. Those tests are really for the BIOS and manufacturer's benefit -- if a peripheral fails to respond, it'll spew an error message, or beep a certain number of times, etc. This allows a computer
technician, not a user!, to determine the fault, and replace motherboards appropriately.
External testing relies on instrumenting the simulator or emulator itself. This works by thorough modularization of the simulator's code. For example, my Kestrel emulator, written as a spike and not even fully tested in an automated fashion, is built modularly to facilitate easy testing. Address decoding, MGIA, keyboard/mouse, SerBus, and even the CPU core itself are all separate modules, all fully re-usable in other projects, with well-defined interfaces that are easy to test. Indeed, the SerBus implementation and the disk storage system were the first two components that I rigorously unit-tested. You can find the source to these in the Kestrel emulator's source package on my website. The unit tests exercise SerBus down to individual register-level transfers, completely without the aid of the emulated CPU.
I don't want to make myself out like I'm beating my chest. That's not my intent. I'm just saying, "yes," it is possible to automate the testing and verification of hardware against a software model (heck, that's what I did at Hifn as post-silicon verification technician!). For those who are interested in techniques on how to do this, there are volumes of websites on test-driven development, behavior-driven development, mock-object testing, etc. I'm not going to repeat them here.
Quote:
Sure; got a macro to automatically assign message indicies and generate the message table? It's got to be really convenient to use.
Me? No. Again, failure for you to think of how this is done does not mean it cannot be done.
Here's an idea,
using a completely hypothetical assembly language syntax, based on my recollection of a 68000 assembler I used on the Amiga called A68K all the time.
Code:
Print MACRO Msg
SECTION RODATA
L_Msg: DC.B Msg, 0
SECTION MsgTableLoSection
idx SET (*-MsgTableLoOrigin)
DC.B <L_Msg
SECTION MsgTableHiSection
DC.B >L_Msg
SECTION CODE
LDX #idx
JSR printIndexedMessage
ENDM
If your assembler provides a feature-set analogous to the above (the critical point here is that SET functions like EQU, but allows symbol re-definition), then it be structurally similar to the above. This even works across multiple compilation/assembly units -- the linker would coalesce all like-named sections appropriately, and take care of any load-time fixups.
At least, if it were a good system.
I'm pretty sure ca65 offers a macro processor powerful enough for this, but I've never used it, so my memory could be incorrect. Fachat's assembler (xa65 IIRC) might also be powerful enough to support this kind of construct.