[cc65] bug when casting function pointers

From: Groepaz <groepaz1gmx.net>
Date: 2008-12-25 23:53:14
using 2.12.9 (latest snapshot) the following doesnt give the expected result:

#include <stdint.h>

#define CINV (*(uint16_t *) 0x0314)

void newirq(void);

int main(void)
    CINV = (uint8_t) newirq;

void newirq(void)

the generated asm for main() is this:

        lda     #<(_newirq)
        ldx     #>(_newirq)
        sta     $0314
        stx     $0314+1

which is wrong (the cast to 8 bit type is ignored, the highbyte should be 0). 
after changing the assignment to CINV = (uint8_t)0x1234; it will correctly 
result in

        ldx     #$00
        lda     #$34
        sta     $0314
        stx     $0314+1

i havent further investigated if the problem is actually related to function 
pointers, or if it happens every time some kind of label/symbol is involved. 
anyway, it's a bug :=)

(merry christmas to everyone too! :=))


http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

last time I tried the c64-test on a date she fell asleep after just 4 hours of 
demos. That was when I knew she wasnt right for me. i mean.. falling asleep 
after just a few hours of c64 demos?  We have a word for that stuff on the 
scene. L A M E. (: 

To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Dec 25 23:53:18 2008

This archive was generated by hypermail 2.1.8 : 2008-12-25 23:53:21 CET