From: Stephan Lesch (slesch_at_studcs.uni-sb.de)
Date: 2003-02-06 00:24:31
typedef struct{
char color1, color2;
} ROYWINCOL_T;
void setcharcolors(ROYWINCOL_T *colors);
static ROYWINCOL_T colors = {1,0};
void main(void){
setcharcolors(&colors);
}
wird compiliert zu:
_colors:
.byte $01
.byte $00
; ---------------------------------------------------------------
; void main (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _main
.segment "CODE"
lda #<(_colors)
ldx #>(_colors)
jsr pushax
jsr _setcharcolors
rts
.endproc
Du kannst colors auch lokal in main definieren, dann wird der Code
groesser, weil er einen Zeiger darauf auf dem Stack ablegt und auch
da her holt.
Mit
void __fastcall__ setcharcolors(ROYWINCOL_T *colors);
wird der Aufruf kuerzer, wenn er in der Funktion den zeiger nicht noch
abspeichern muss:
lda #<(_colors)
ldx #>(_colors)
jsr _setcharcolors
rts
Wieso man die Struktur nicht direkt im Aufruf angeben kann, a la
setcharcolors(&(ROYWINCOL_T){1,0}) weiss ich nicht. Ich bin nicht sicher,
ob das in C vorgesehen ist...
Gruss,
Stephan
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-02-06 00:26:30 CET