[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mockingboard emulator (was: Late night musings...)



hochstrasse@ubaclu.unibas.ch (Urs Hochstrasser) wrote:

>What do you think of the following method: 
>1. You scan the code in place with your disassembler-like program for
>   'special cases'
>2. You patch the program directly in memory with a JSR into your own
>   code when such a "special case" is encountered
>3. You execute the modified program at full speed
>This way there may be a little delay on launch, but the program itself
>should execute at a fairly high speed.

This would be fine if I knew that I would have the space to put a JSR,
or JSL which would more likely be required, in the place of the
special instruction.  I would still have to stop execution after the
special case to replace any code that may have been overwritten by my
JSR/JSL.

I was thinking, however, of using the COP instruction to do this sort
of thing.  A COP instruction only takes two bytes and can be used to
generate up to 256 different breaks.  I haven't yet gone through the
6502/65C02 instruction set to see if there are any instructions that
might access special areas that only require one byte.

This method still has its problems because it would be very difficult,
if not impossible (self-modifying code raises its ugly head here), to
trace the entire execution of the program to be able to patch what I
have to with COPs.  Even if the entire execution could be traced, it
would probably take a significant amount of time and most people
wouldn't want to wait that long to get a program up and running.  It
might still work okay if I continue to limit how much code gets
executed at full speed at any one time.