[comp.sys.mac.programmer] A-Trap length

upl@gumby.cs.wisc.edu (Undergrad Projects Lab) (04/03/90)

I'm writing a little program for myself and I need to copy some of the ROM
traps to RAM. I know how to get the address of the trap, but I have know idea
how to get the length to copy it to RAM. Is there any way (short of searching
for the next trap) to get the length?

thanks in advance,
Brad Koehn
"Fly like an Emu!"

rdclark@Apple.COM (Richard Clark) (04/09/90)

In article <4598@daffy.cs.wisc.edu> upl@gumby.cs.wisc.edu (Undergrad Projects Lab) writes:
:I'm writing a little program for myself and I need to copy some of the ROM
:traps to RAM. 

  Don't try it. Assuming that you get the "correct" length (BTW -- the traps
in ROM are not necesarily sorted according to their trap numbers), you still
have to deal with the following questions: 1) Did I actually get the trap,
or somebody's patch to it?, and 2) What do I do about the PC-relative jumps
encoded in the trap codes themselves? (Surprise! There are some utility
routines in ROM which get called directly.)
 
  If you can describe *why* you want to get the code out of ROM, we all can
probably find a better way to do what you want.
 
...Richard



-- 
-----------------------------+-----------------------------------------------
Richard Clark                | "If you don't know where you're going,
Instructor/Designer          |  don't go there" -- Sybalski's Law	
Apple Developer University   +-----------------------------------------------
AppleLink, GEnie, Delphi, MCI, Internet: rdclark  CI$: 71401, 2071

Invader@cup.portal.com (Michael K Donegan) (04/12/90)

Copying traps from ROM to RAM?  This is so fraught with danger I can't
believe that you are considering it.  For one thing, getting the trap
address is easy, but it doesn't guarantee that it is in ROM.  Many traps
are patched.  They begin in RAM, wander back to ROM, etc.  And those
patches often depend on the code being in ROM.  So if the trap you are
considering moving calls another trap via the A-trap (instead of just
calling it) the patches that check for things like "Was I called from
MoveWindow?" won't work anymore.  Also many traps use PC-relative data
and will flat fail if you move the code and not the data, too.  Finally and
most obviously, this is not like compiled code where all of one routine is
together in one place.  Heck no!  This is ASSEMBLER and it can go anywhere.
Whatever you are trying to do, there must be a better way.  What ARE you
doing?
	mkd