Re: Constructing a relocation page table

From: Marko Mäkelä (
Date: 2003-07-19 19:33:56

On Tue, Apr 29, 2003 at 10:44:17AM -0600, Steve Judd wrote:
> You might take a look at the code relocation function in Jammon.  For the
> most part it's pretty easy to relocate ML code.  As I recall, the main
> issue is when there's data embedded in the code.  The way I got around
> that was to put all the data at the end of the code, then specify three
> addresses to the code relocater: code start, code end, data end.

I took an even simpler approach: find a range of bytes that does not occur
in the non-relocated program, say from $51 onwards, and assemble the code
to $5100.  Now, the relocation procedure becomes very simple: if the data
byte is between $51 and, say, $54, subtract $51 from it and add, say, $c0
to relocate the code to $c000.

Of course, this method requires some care whenever the code is modified.

The target address is reconfigured by changing the number of a BASIC
line.  In this way, the machine code will "see" it in binary format.

The loader itself is also relocatable with 256-byte increments.  Including
the BASIC header, it occupies 119 bytes on most systems, and 121 on the C128,
where some of the pointers are not within the zero page.

You can see the programs at, file (source code in cbmlink-cbmsrc.tar.gz).


       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.