Article View: comp.arch
Article #2619Re: Self-modifying code
From: Allen J. Baum
Date: Mon, 16 Oct 1989 21:29
Date: Mon, 16 Oct 1989 21:29
39 lines
1647 bytes
1647 bytes
Reply-To: baum@apple.UUCP (Allen Baum)
Distribution: net
--------
[]
>In article <274@ssp1.idca.tds.philips.nl> roelof@idca.tds.PHILIPS.nl (R. Vuurboom) writes:
>
>I came up with the following little routine:
>
> save real registers/condition codes
> load registers/condition codes from emulated registers
>
> nop
> nop
> nop
> nop
>
> save registers and condition codes to emulated registers
> load real register/condition code values
>
>
>By loading the instruction I wanted to trace in the area with nop's
>and calling the routine I could let the Z80 "calculate" the condition codes
>and the changed registers for me. The next step was to calculate the
>new pc and load the following instruction to be traced.
>
>Of course, this was pretty primitive. It wouldn't work for branches
>(but I could determine if a branch would take place and set the
>emulated pc accordingly and continue from there). Nor would it
>work for io instructions :-) but they didn't occur often anyway.
The original Apple II monitor ROM had a single step/trace routine that
did exactly that. I think for branches I just replaced the offset,
so it always branched to a fixed place, and updated the emulated PC
with the offset if it did.
--
baum@apple.com (408)974-3385
{decwrl,hplabs}!amdahl!apple!baum
Technical Details
Message-ID:
<35710@apple.Apple.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!baumShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!baum From: baum@Apple.COM (Allen J. Baum) Newsgroups: comp.arch Subject: Re: Self-modifying code Message-ID: <35710@apple.Apple.COM> Date: 16 Oct 89 21:29:47 GMT Organization: Apple Computer, Inc. Lines: 39