Re: [cc65] Best way to get align memory...

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-01-07 07:41:12


Good morning!

On Mon, Jan 06, 2003 at 06:21:18PM +0100, Christian Krüger wrote:
> I like to know which is the best way to reserve a static
> buffer with a memory alignment.

Marc already posted one solution. Here is another one.

Use a separate assembler file like this:

----------------------------buffer.s-----------------------------

        .export _buffer

BUFSIZE         = 1024
BUFALIGN        = 4             ; Must be a power of 2

.bss
buf:    .res    BUFSIZE + BUFALIGN - 1

_buffer = (buf + BUFALIGN - 1) .AND (~(BUFALIGN - 1) .AND $FFFF)

-----------------------------------------------------------------

While there is no solution that will avoid the 3 bytes wasted memory, this
solution is portable, and it avoids the additional pointer that will cause the
compiler to generate less efficient code.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
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 : 2003-01-07 07:41:33 CET