[cc65] register vars

Date view Thread view Subject view

From: Stephan Lesch (slesch_at_studcs.uni-sb.de)
Date: 2003-01-18 02:21:07


Hi,

is there a way to use statically-declared register variables? (For non-
recursive functions) That way, you could have better code generated,
but still save the overhead for saving/restoring the zeropage locations.
I tried it with V 2.9.0, but the register vars declared on top level are 
mapped to the same zp location:

register unsigned char* dest;
register unsigned char* src;

void  cmdstrappend(unsigned char *s){
    src = s;
    if (src)
	while (*src) {*dest = *src; ++src; ++dest;}
}

becomes
	ldy     #$01
	jsr     ldaxysp
	sta     regbank+0
	stx     regbank+0+1
	lda     regbank+0
	ora     regbank+0+1
	jeq     incsp2
L0007:	ldy     #$00
	lda     (regbank+0),y
	jeq     incsp2
	lda     (regbank+0),y
	sta     (regbank+0),y
	inc     regbank+0
	bne     L000D
	inc     regbank+0+1
L000D:	inc     regbank+0
	bne     L0007
	inc     regbank+0+1
	jmp     L0007

I'm compiling with  cc65 -t c64 -Oirs regtest.c
Is there a way to get the two pointer variables
assigned to different locations? (Did I overlook a bugfix, or am I 
misunderstanding the concept of register vars, and they're just not meant
to be declared static?)

Regards,
Stephan Lesch


----------------------------------------------------------------------
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-18 02:21:14 CET