Jump to content
IGNORED

Align ignored by cl65? unable to set segment address


Recommended Posts

Hello.

 

I'm not seem able to make my symbol get aligned properly (array for font):


I modified the segment and memory in cfg (copy form atari-xex.cfg)


 

MEMORY {
    ZP:         file = "", define = yes, start = $0082, size = $007E;
# "system check" load chunk
    SYSCHKCHNK: file = %O,               start = $2E00, size = $0300;
    FONT_RAM:    file = "", define = yes, start = $2000,  size = $1000;	
# "main program" load chunk
    MAIN:       file = %O, define = yes, start = %S,    size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S;
}
...

SEGMENTS {
    ZEROPAGE:  load = ZP,         type = zp;
...
    DATA:      load = MAIN,       type = rw;
    FONT:      load = FONT_RAM,   type = ro, align=$100, define=yes;
    INIT:      load = MAIN,       type = rw,                optional = yes;
}

 

An I'm using pragma to refer the segment:
 

#pragma data-name (push,"FONT")
#include "font.h"
#pragma data-name (pop)

in font.h

extern unsigned char GAME_FONT[];


however I have a non-aligned address for the pointer:
 

 _GAME_FONT                00541A RLA  


See the full map and cfg file in the attachments

What am I missing here ?

I've been following the documentation and examples in thread:
 

Also I found this great presentation form @Bill Kendrick
 


thx !
cc65-20150921.pdf

taco.map tacobot.cfg

Edited by Mariano DM
duplicate link
Link to comment
Share on other sites

OK .. after pulling out my hair I was able to do it !

 

a really ugly solution, hope I can do it properly

 

put the pragma in the .c file instead of the header.

 

#pragma data-name (push,"FONT")
unsigned char GAME_FONT[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0x60,0xC0,0xC3,0x66,0x3C,0x33,
0x78,0xC6,0x11,0x01,0x02,0xFC,0x00,0x00,
...
#pragma  data-name (pop)

 

Link to comment
Share on other sites

For bitmap the alignment doesn't matter.

It can't cross a 4K boundary, not sure if ALIGN could help there.

When up at the 4K boundary the mode line should start -40 bytes from it (32 or 48 if narrow/wide DMA) then the next line will need LMS in the DList to start it at the next 4K.

Generally the OS will always have RAMTOP aligned at a 4K boundary - it only does the second LMS in the hires modes that use 8K.

  • Like 2
Link to comment
Share on other sites

Your solution by putting the #pragma data-name directive to the font.c is correct.

And that is exactly where it should have been in the first place.

 

Why is that?

 

The extern unsigned char GAME_FONT[]; statement doesn't generate any machine code or data. It is just a symbol for the compiler that will be resolved later by the linker. Therefore, there is no code or data that could go to the FONT segment. That is also clear from the .map file. The .map file has no mention of the FONT segment.

 

So, if you want to use the #pragma data-name directive, use it where the data is defined, not where it is declared.

 

 

 

 

 

 

 

Edited by baktra
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...