Re: [cc65] 6502 runtime relocation

From: dominic beesley <dominic1brahms.demon.co.uk>
Date: 2005-06-23 01:48:16
Ullrich von Bassewitz wrote:

>Hi!
>
>On Wed, Jun 22, 2005 at 01:58:23PM +0100, Jonathan Graham Harston wrote:
>  
>
>>On the BBC you do not know the upper and lower bounds of memory
>>until runtime. I've got some code that relocates a 6502 program
>>loaded into the middle of memory to the bottom and jumps to it.
>>Before I start adapting it to be suitable to work with a compiled
>>'C' program is there already any code that is already suitable?
>>    
>>
>
>There are some other platforms with a variable lower memory bound, but
>on these systems, the solution was to use the "highest" low memory
>address available for the general purpose builtin configuration. 
>
>Probably the most versatile solution would be to generate o65 output and
>write a relocator that runs on arbitrary memory addresses. I don't know
>how your relocator works, but if it disassembles the code, there are
>pieces of code it won't handle correctly.
>
>Regards
>  
>
I've been fiddling with this too but thought it might be better to:

a) relocate the stack low if possible (I currently tend to use a hole at 
$400-$7FF)
b) try and split the malloc area in two to use the low memory hole if 
available

I've not really got anywhere with b) yet but haven't spent much time on 
it. The two
are however related as the malloc functions expect the stack at a "high" in
memory as far as I can tell and won't use the top of memory.

Weighing it up I'd reasoned that relocation was a bit difficult and 
ruled it out
"for now" but if you can come up with a way of doing it I would be 
interested.

The BBC is a pain as it also has differing high memory locations 
depending on
what graphics mode you are in. I've put a quick bodge in crt0.s to take 
this into
account. Not sure how to deal with this properly though. I've got a 
Master so
I tend to just do a *shadow then I know I've got $e00 - $8000 free :p 
But would
like to make something a bit safer....again this is a ways down the list.

I will get on with the library stuff but am having car troubles at the 
moment and
off on holidays next week. Then will dive in to the libraries and trying 
to get them
into a ROM which will leave a lot more space?

--

Dom

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jun 23 01:54:42 2005

This archive was generated by hypermail 2.1.8 : 2005-06-23 01:54:45 CEST