Re: [cc65] Alignment

Date view Thread view Subject view

From: Greg King (gngking_at_erols.com)
Date: 2002-07-25 20:33:24


-----Original Message-----
From:  cbmnut_at_hushmail.com
Date:  Tuesday, July 16, 2002 07:39 PM
>
> OMG, there's no working .align??  I need that to do some libraries,
> in the future.  I will need page-alignment, to get some code working with
> large tables.  And for speed, staying within a page-boundary is good.
>
> I.e.:
>
> readtable: lda sqrtable,y
>         ...
>            .align page
> sqrtable:  .byte $00,$01,$02,$04, ...

".align" works well enough for what you want -- if you are willing to use
a custom linker-configure-script.  Add a line to the script (between "DATA:" and
"BSS:") that looks like this:

TABLES: load = RAM, type = ro, align = $100;

Then, write your ca65 assembly-code, in this style:

readtable: lda sqrtable,y
        ...
        ...
        ...
           .segment "TABLES"
           .align $100
sqrtable:  .byte 0,1,4,9, ...
        ...
        ...
        ...
           .code
           lda cubetable,y
        ...
        ...
        ...
           .segment "TABLES"
           .align $100
cubetable: .byte 0,1,8,27, ...
        ...
        ...
        ...
           .rodata
        ...

My first example interweaves code and data, in the source-file; but, ca65 would
separate them, and join together the pieces of each segment.  You can arrange
the pieces any way that you wish; what is important is how ".segment" and
".align" are used:

readtable: lda sqrtable,y
        ...
           lda cubetable,y
        ...
           .bss
        ...
           .segment "TABLES"
           .align $100
sqrtable:  .byte 0,1,4,9, ...
        ...
           .align $100
cubetable: .byte 0,1,8,27, ...
        ...

That stuff is documented in "ca65.html" (section 6.4)
and "ld65.html" (section 4.6).

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-07-25 21:12:14 CEST