Re: [cc65-devel] Random (funny, hopefully interesting) question
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Oliver S. <ol...@we...> - 2021-03-19 15:32:09
|
Hi,
Well these other assemblers make the first 2 bytes the start address; so if
> it starts at $1234, the first two bytes would be 34 and then 12 (is that
> "little-Endian" order?). I think the C64 uses this format too (or it looks
> that way based on a hex dump). Looking at the docs, it looks like I might
> get it to work using the --start-addr command-line option... idk tho.
>
--start-addr is used to set the start address for the generated code (think
.org of traditional assemblers) but has nothing to do with writing some
header (or not).
To get the 2-byte load address header you describe you modify cfg/none.cfg
to look like this (name it e.g. load.cfg):
FEATURES {
STARTADDRESS: default = $1000;
}
SYMBOLS {
__LOAD__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__STACKSTART__: type = weak, value = $8000;
__ZPSTART__: type = weak, value = $0080;
}
MEMORY {
ZP: file = "", define = yes, start = __ZPSTART__, size = $001F;
LOAD: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size =
__STACKSTART__ - __STACKSIZE__ - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
LOAD: load = LOAD, type = ro;
STARTUP: load = MAIN, type = ro, optional = yes;
LOWCODE: load = MAIN, type = ro, optional = yes;
ONCE: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = rw;
DATA: load = MAIN, type = rw;
BSS: load = MAIN, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__,
segment = ONCE;
CONDES: type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__,
segment = RODATA;
CONDES: type = interruptor,
label = __INTERRUPTOR_TABLE__,
count = __INTERRUPTOR_COUNT__,
segment = RODATA,
import = __CALLIRQ__;
}
then create an assembler file named e.g. load.s looking like this:
.export __LOAD__: absolute = 1
.segment "LOAD"
.addr *+2
Now build your program with:
cl65 -t none -C load.cfg test.c load.s
Regards,
Oliver
Anyway, what are the other "all kinds of headers" you can add / how would I
> add them? Currently chasing the __EXEHDR__ keyword down this fun little
> rabbit-hole. :)
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, March 18, 2021 6:27 PM, Oliver Schmidt <ol...@we...> wrote:
>
> Hi,
>
> that two-byte header exists.
>>
>
> I don't know what "that" two-byte header is.
>
>
>> Cuz then it comes down to finding a way to add that header.
>>
>
> You can have cc65 create all kinds of headers.
>
>
>> Is there a way to add it from the command-line, or a config setting?
>>
>
> That depends on the header you need - see above.
>
> Regards,
> Oliver
>
>
>
|