Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!mattd
From: mattd@Apple.COM (Matt Deatherage)
Newsgroups: comp.sys.apple
Subject: Re: Code Fragment question
Message-ID: <34111@apple.Apple.COM>
Date: 18 Aug 89 18:35:59 GMT
References: <8908151859.AY00046@adam.DG.COM>
Organization: Apple Computer Inc, Cupertino, CA
Lines: 43

In article <8908151859.AY00046@adam.DG.COM> KAHN%void.mceo.dg.com@relay.cs.net writes:
>CEO summary:
>  I was taking a look at possibly porting MAC.TRANS.GS to C and 
>adding a nicer interface to it but I have to "port" the ML routine as 
>well.  I cant decypher one part:
>  JSR     $C50A
>  LDX     #00
>  BCC     1:
>  TAX
>1: STX    338
>  The routine saves the memory region 42.47, loads it with values, 
>makes the call, and then restores the region.  I cant find any 
>reference to it any any of my manuals.  Can someone help me with what 
>this code fragment does and what the values at 42.47 are used for (my 
>map of zero page does not describe them)?  I would like to know what 
>C50A does and what params it takes.  
>                                   Bruce (KAHN@ADAM.DG.COM)

As Dave said when we were discussing this one, "I hope that's self-modifying
code."

$C50A on a IIgs *happens* to be the ProDOS firmware protocol entry point.  This
is calculated by adding the contents of $C5FF ($0A) to $C500.  Whoever wrote
this should *not* be depending on it as being $C50A always (since we apparently
have this annoying habit of making new ROMs :). (This is all for internal slot
5 only, and it just so happens that $C50A is still the entry point on ROM 03.
Whoever lucked out, big time.)

The protocol is documented in the ProDOS 8 Technical Reference Manual, so you
can figure out from there what's being done.  Hopefully you can figure out a
way to do it with standard GS/OS calls (Format, Read, Write, Status), since
this kind of stuff is definitely illegal under GS/OS.


-----------------------------------------------------------------------------
Matt Deatherage, Apple Computer, Inc. | "The opinions expressed in this tome
Send PERSONAL mail ONLY (please) to:  | should not be construed to imply that
AppleLink PE: Matt DTS  GEnie: AIIDTS | Apple Computer, Inc., or any of its
CompuServe: 76703,3030                | subsidiaries, in whole or in part,
Usenet:  mattd@apple.com              | have any opinion on any subject."
UUCP:  (other stuff)!ames!apple!mattd | "So there."
-----------------------------------------------------------------------------