6510 emulator written in 6510-machine code?

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
autoboy
Posts: 2
Joined: 26 Apr 2003
Contact:

6510 emulator written in 6510-machine code?

Post by autoboy »

This might sound like a really screwed up question, but does anyone know of a 6510-emulator written in 6510 machine code? I don't wanna write one if it really exists.

If someone feel they need an explanation, here it is:
I need to be able to test automatically generated code (on a c64) before actually letting it lose on the real CPU, to make sure it behaves. (No out of bounds memory access and only execution of permitted opcodes for example).

Anyone?

/Autoboy
blargg
Posts: 42
Joined: 30 Dec 2003
Contact:

Post by blargg »

You can let the CPU do most of the decoding for you, after you do as much decoding as necessary to validate the instruction (and possibly modify it). Once it's validated/modified, copy it to an execution area in RAM which restores the processor state, has a NOP-padded slot for the instruction, then saves processor state again. I've used this in a couple of debugger/monitors on other 8-bit CPUs for their single-step mode and even on the PowerPC processor which is quite a different beast than the 6502.
User avatar
Mike Naberezny
Site Admin
Posts: 293
Joined: 30 Aug 2002
Location: Northern California
Contact:

Re: 6510 emulator written in 6510-machine code?

Post by Mike Naberezny »

autoboy wrote:
This might sound like a really screwed up question, but does anyone know of a 6510-emulator written in 6510 machine code? I don't wanna write one if it really exists.
Check out Cameron Kaiser's KIMplement:
http://www.floodgap.com/retrobits/kim-1/

It looks like he's done what you'd like to do, perhaps he'll share his source code with you.

Regards,
Mike
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

Re: 6510 emulator written in 6510-machine code?

Post by 6502inside »

This is a really old necropost, but I figured it was worth tacking on: the plan is to opensource 6o6 with the next release ("1.0") of the KIMplement, which will also be opensourced now that I'm satisfied with code quality, years and years later. 6o6 is the "6502-on-6502" virtualizer that it uses.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: 6510 emulator written in 6510-machine code?

Post by BigEd »

Sounds like a good development!
gregorio
Posts: 77
Joined: 07 Feb 2023

Re: 6510 emulator written in 6510-machine code?

Post by gregorio »

There is such a program in Polish (SYMULATOR 6510) and German (6510 Einzelschritt-Simulator) but writen in BASIC.
The Polish version is in the attachment.
The instructions are in the program, if you have any problems, I can translate them.
Attachments
Symulator_6510.zip
(7.24 KiB) Downloaded 83 times
User avatar
strik
Posts: 14
Joined: 24 Mar 2022

Re: 6510 emulator written in 6510-machine code?

Post by strik »

gregorio wrote:
There is such a program in Polish (SYMULATOR 6510) and German (6510 Einzelschritt-Simulator) but writen in BASIC.
The Polish version is in the attachment.
The instructions are in the program, if you have any problems, I can translate them.
That's obviously the "Einzelschrittsimulator" from the book Das Maschinensprache Buch zum C64 by Lothar Englisch. There is also an English language version of the book.

The version you offered seems to be the german version, but with instructions in Polish added before the simulator is started.
Post Reply