Re: [cc65] Optimizations of structures

From: Marc 'BlackJack' Rintsch <>
Date: 2010-09-10 14:54:55
On Friday 10 September 2010, Jakub wrote:

> Is it possible to add a compiler switch to reorganize structures
> fields to be lineary placed in the memory?
> I know it won't work well for all the cases (f.e. nested structures).

A compiler switch won't do because it would be a global thing and other 
modules might depend on the expected layout of arrays of structures.  
So it has to be some kind of annotation to array types.

IMHO it has too many implications and breaks too much.  For example what 
will ``pos[n]`` return?  It can't be a pointer to a structure anymore.

Using an advancing pointer instead of indexing might yield a bit better 

 ; position->y = y;
	lda     _position
	sta     ptr1
	lda     _position+1
	sta     ptr1+1
	lda     _y
	ldy     #$01
	sta     (ptr1),y
 ; position->x = x;
	lda     _position
	sta     ptr1
	lda     _position+1
	sta     ptr1+1
	lda     _x
	sta     (ptr1),y
 ; ++position;
	lda     #$02
	adc     _position
	sta     _position
	bcc     L001C
	inc     _position+1

	Marc 'BlackJack' Rintsch
The Python debugger has a 'break' command;
why doesn't it have 'fix' command too?

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Sep 10 14:43:30 2010

This archive was generated by hypermail 2.1.8 : 2010-09-10 14:43:33 CEST