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

Re: Questions on EDASM reloc ($FE) files



In article <voOdnfM3qdn3YqTZnZ2dneKdnZydnZ2d@comcast.com>,
 "Michael J. Mahon" <mjmahon@aol.com> wrote:

> John B. Matthews wrote:
> > Contiki could check the auxiliary type for validity, while existing 
> > EDASM RLOAD wouldn't need to do anything different. I would advocate 
> > choosing an auxiliary type that would be an unlikely ORG of a 
> > relocatable segment: e.g. $FFFF.
> 
> That would be a good choice if the assembler can be convinced, but I
> think it's REL file format is already settled.  At this point, it would
> just be up to the "consuming" programs to check for what they expect.
> It seems likely that any "loader" program would do some validity checks,
> since they have the potential to overwrite almost anything if they work
> "blindly".

Indeed. The RLOAD program checks the file type, which presumably was 
created by EDASM, not Contiki:-) The question is how to use the REL file 
type for two different formats without requiring a change to the 
existing tools that use the type.

Empirically, when EDASM creates a REL ($FE) file, it sets the auxiliary 
type to the value of the (last) ORG directive. As described in Appendix 
E of the ProDOS Assembler Tools manual, the file includes the code 
length, the code itself and an appended relocation dictionary. At 
runtime, RLOAD lowers HIMEM and loads the relocatable file. It uses the 
auxiliary type and the relocation dictionary to relocate the code. 

The auxiliary type is used by RLOAD as the base address for relocation. 
In the worst case scenario, a user would have to mistakenly use RLOAD 
(via USR(0)) on a Contiki REL file. The result is hard to predict. A 
cursory look suggests that RLOAD would "relocate" a single byte and 
return its address, depending on the value of mode.

While the "right" answer is not to recycle the type at all, that surely 
is overly restrictive. Because an auxiliary type must be defined when 
the file is created, it only makes sense to choose the auxiliary type 
that is least likely to break existing code. In practice, EDASM forbids 
using an ORG < $100 for a relocatable file, so an auxiliary type of 
$0000 would be a reasonable alternative.

> -michael
[...]
-- 
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/