#960 initializing code data at fixed address


In my C code, when I write at the last lines :

struct IDT_s
uint8_t ljmp;
void (*function)(void);

code at 0x10000 - sizeof(struct IDT_s) struct IDT_s IDT
= {LJMP_OPCODE, soft_interrupt};

where soft_interrupt is a function with prototype :

void soft_interrupt (void);

sdcc correctly set the address of IDT to be able to
referance it in the code but do not initialize the value.

the .ihx file do not contain any line to set the
addresses 0xFFFD with LJMP_OPCODE, 0xFFFE with
soft_interrupt >> 8 and 0xFFFF with soft_interrup.

And the assembly generate code does not seem to contain
any initialization code.

you will find attached to this mail 4 files "config"
"Makefile", "updater.c" and "updater.ihx".

just type make to generate evry other ones.

I currently use :

2.5.1 #1058 (Jul 13 2005) (UNIX)

If you want to contact me my e-mail address is :


Best regards, and sorry for my poor english.


  • Nobody/Anonymous

    An archive containing mentionned files.

  • Maarten Brock

    Maarten Brock - 2005-07-29

    Logged In: YES

    This is already RFE 859412.

    But there is a work-around in SDCC 2.5.2. Put this line in a
    separate file idt.c

    code struct IDT_s IDT = {LJMP_OPCODE, soft_interrupt};

    compile it with:

    sdcc --codeseg IDTSEG -c idt.c

    and link it with:

    sdcc -Wl-b IDTSEG=0xFFFD updater.rel config.rel idt.rel

    Hope this helps,

  • Maarten Brock

    Maarten Brock - 2005-07-29
    • status: open --> closed-later
  • Jesus Calvino-Fraga

    Logged In: YES

    Hummm, at the very end of your source file you could add the
    code below (otherwise any code after this function will be at
    an absolute code area, not a relocatable one):

    void my_dummy_function (void) _naked
    .area MYAREA (ABS)
    .org 0xfffd
    ljmp _soft_interrupt

    With this code you will receive a warning:

    "warning: extended linear address encountered; you probably
    want the -r flag."

    because the program counter after the ljmp is 0x10000, but
    that is ok and harmless. (You won't get the warning if you
    place the code at address 0xff00 for example) Any other
    relocatable code segments will be concatenated after
    whatever you pass using --code-loc (default is 0), and the hex
    file will have a record with the ljmp at the right address:

    :03FFFD0002F524E6 <---Here it is!


  • Nobody/Anonymous

    Logged In: NO

    Thanks for all.
    For now I use jesusc work-around, which work quiet well.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks