BillG wrote:
White Flame wrote:
The .o65 output from ca65/ld65 generates relocation tables. These come from the linker itself, which resolves the references into the output bytes, knowing which references refer to locations within the binary itself, vs which are outside of it.
Thanks, but that looks very complicated.
I've considerably tried to keep it as simple as possible to load. You can use block load for the program and data, and relocate after loading. Here is the description of the format:
http://6502.org/users/andre/o65/Oh, and btw, the file format supports pagewise relocation, and there is a sample loader code available.
Quote:
Allow me to clarify more specifically what I am after.
The FLEX EXEC command on the 6809 loads into the Utility Command Space. It checks MEMEND and copies itself to the top of the main RAM and lowers MEMEND to protect itself. EXEC is a utility to execute a series of commands from a file. MEMEND is a FLEX system variable which contains the address of the highest usable location of user RAM.
It does its business, then restores MEMEND before exiting.
I am looking to build something similar for the 6502 and 6800 neither of which readily supports writing position independent code. EXEC for the 6800 currently loads at a fixed location just below the 32K mark, meaning it cannot be used on a machine with less than 32K of main RAM or if other "terminate and stay resident" programs are already loaded into that area.
I prefer something fairly simple which will work with code generated by most tools, though I am currently using either the FLEX ASMB assembler or my own cross assembler. I do not want to be tied to one assembler, compiler or linker. Eventually, it would be nice to be able to build a relocatable program entirely using tools hosted by FLEX. The bit map builder tool originally runs on a PC, but will later be built as a FLEX program.
I don't know what FLEX is. o65 is supported by xa65 and ca65 at least.
If you need a different type of relocatable file format, you could provide a converter from o65 to your format to increase coverage by other assemblers.
Quote:
If this works out well, I may try to create something like MOVCPM to allow the end user to move a 6502 FLEX system image without having to rebuild it from source.
I assume you don't want to relocate a "running" program, but just relocate at load time? There are so many other things to consider relocating a running program (values in variables, stack) that this looks a rather challenging task. o65 for example saves space by putting an offset to the referenced variable in the code/data section where the relocated address should go, and just adds the referenced variable to it. ... to relocate a running program you'd have to make sure to add the relocation offset (new minus old variable value, which should be constant), but also have to make sure you consider special values, like $0000 as a flag for example.
André
_________________
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content:
http://6502.org/users/andre/