Question about LD65 Memory Config File(align attribute)

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
georgjz
Posts: 2
Joined: 27 Sep 2017

Question about LD65 Memory Config File(align attribute)

Post by georgjz »

I have a question about the align attribute in my memory config:

Code: Select all

MEMORY {
    BANK00:     start=$8000, size=$8000, fill=yes;
    BANK01:     start=$f000, size=$8000, fill=yes;
}

SEGMENTS {
    CODE:       load=BANK00, align=$8000;           # bank 0 at $00:$8000
    HEADER:     load=BANK00, start=$ffc0;
    ROMINFO:    load=BANK00, start=$ffd5;
    VECTOR:     load=BANK00, start=$ffe4;
    GRAPHICS:   load=BANK01, align=$8000;           # bank 1 at $01:$8000
}
Background: I'm playing around with programming SNES game bits for fun, the code is working fine. For ease of use I decided to have one 32KB segment/bank for my code(include the reset vectors and SNES specific data) and a second 32KB bank for the graphics I use(note that both data could fit completely into one bank, I simply do this for educational reasons).

Now, when I build my program the output file is as expected 64KB in size, so I except my code to start at $0000 of the output file, and the graphics data at $8000. Yet my graphics data starts at $9000. I also get this warning from ld65:

Code: Select all

ld65: Warning: lorom128.cfg(11): The first segment in memory area `BANK01' needs fill bytes for alignment.
When I remove the second align attribute in the last line, my graphics are placed at $8000 as expected. I understand the align attribute to be a tool to make sure, that segements of a certain size won't overlap.

What am I getting wrong about align and why does it move my data to $9000 instead of $8000?
leepivonka
Posts: 168
Joined: 15 Apr 2016

Re: Question about LD65 Memory Config File(align attribute)

Post by leepivonka »

In "MEMORY", in "BANK01", you have "start=$f000" - should this be $18000?

I think LD65 is inserting 4KBytes of padding so GRAPHICS can be aligned on a $8000 boundary.
georgjz
Posts: 2
Joined: 27 Sep 2017

Re: Question about LD65 Memory Config File(align attribute)

Post by georgjz »

Sorry for my late reply. I haven't got behind it yet, since I kept working on it with my old config file. When I find more time, I'll investigate further and keep you posted.
iLavr
Posts: 7
Joined: 24 Dec 2014

Re: Question about LD65 Memory Config File(align attribute)

Post by iLavr »

Hi, georgjz !

I have a question to you, but I can't find how to send a private message here.

How can I contact you?
User avatar
GARTHWILSON
Forum Moderator
Posts: 8774
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Question about LD65 Memory Config File(align attribute)

Post by GARTHWILSON »

iLavr wrote:
but I can't find how to send a private message here.

How can I contact you?
HowToSendPM.gif
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
iLavr
Posts: 7
Joined: 24 Dec 2014

Re: Question about LD65 Memory Config File(align attribute)

Post by iLavr »

Thanks, GARTHWILSON !

I have a habit that a "private message" button must be on top... ))))
Post Reply