avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-chat] Retrieving Linker Label Addresses Above 64K


From: Harald Kipp
Subject: [avr-chat] Retrieving Linker Label Addresses Above 64K
Date: Sat, 01 Dec 2007 17:14:26 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Hi,

I'm trying to get the full address of various labels created by the linker, e.g. __data_load_end. This should work on devices with more than 64k program space.

After trying several type casts to uint32_t, which all failed, I ended up with an awfully ugly inline assembler code:

#define LABEL_ADDRESS(label) ({ \
    uint32_t result; \
    __asm__ \
    ( \
        "ldi r30, lo8(" label ")\n\t" \
        "mov %A0, r30\n\t" \
        "ldi r30, hi8(" label ")\n\t" \
        "mov %B0, r30\n\t" \
        "ldi r30, hlo8(" label ")\n\t" \
        "mov %C0, r30\n\t" \
        "ldi r30, hhi8(" label ")\n\t" \
        "mov %D0, r30\n\t" \
        : "=r" (result) \
        : \
        : "r30" \
    ); \
    result; \
})

uint32_t addr = LABEL_ADDRESS("__data_load_end");

There must be a nicer way to get this done. Any idea?

Thanks,

Harald





reply via email to

[Prev in Thread] Current Thread [Next in Thread]