cc65 / cc65

cc65 - a freeware C compiler for 6502 based systems

Home Page:https://cc65.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

void VAR = {} data is being stored as 2 bytes

brad-colbert opened this issue · comments

Hello,

(cc65 V2.19 - Git 4f87c7c)

I'm not sure where to ask this. I'm trying to define some pre initialized variables that are arrays of data. The examples show using or defining the variables as void but the data I'm defining is being generated as two bytes instead of single bytes. I'm not sure what I'm doing wrong. Any help is appreciated.

I'll paste snipets here.

.cfg file SEGMENTS section:

SEGMENTS {
...
    GFX8_DL:                  load = MAIN,             type = rw,  align = $0100,  define = yes;
    GFX8_CONSOLE_DL: load = MAIN,             type = rw,  align = $0100,  define = yes;
    GFX9_CONSOLE_DL: load = MAIN,             type = rw,  align = $0100,  define = yes;
...
}

The variable declaration:

#pragma data-name (push,"GFX8_DL")
void graphics_8_dl = {
    0x70,
    0x4f, &framebuffer[0], 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x4f, 0x00, 0x60, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x4f,
    0x00, 0x70, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x41, &graphics_8_dl
};
#pragma data-name (pop)

.lbl file entries:

...
al 004200 ._graphics_8_console_dl
al 004000 ._graphics_8_dl
al 004400 ._graphics_9_console_dl
...

Snapshot from debugger:
image

I figured out one portion of the problem.

This development is for an Atari target and there are predefines for the data I'm generating (display lists) that have build in casts to unsigned char. This fixed it.

Changed the data block to look like the following:

void graphics_9_console_dl = {
    DL_BLK8,
    DL_LMS(DL_GRAPHICS9), &framebuffer[0], DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9,
    DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9,
    DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9, DL_GRAPHICS9,

Thank you!