This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C166: Call-segmented to a ram-address does not work

Hello,

I use a ST10F269 (SMALL-modell) with Keil C166 v6.
I try to call a RAM-routine (in XRAM2) from ROM (in Segment 2 => all code is located within 64kB in Segment 2) via assembler routine:

BCLR IEN
CALLS #0,#SOF fls_ram
BSET IEN

fls_ram is a variable at address 0xDBBE

What I expect is, that the call is to address 0xDBBE but it is to address 0x9BBE (14bit address).

When I use:
MOV R4, #SOF fls_ram
it works fine, I have the 16bit-address in register R4 but not with CALLS, JMPS, ..

Are there restrictions for the use of #SOF?
How can I jump to the RAM-area (in a different segment)?

Thanks for the help!

Best Regards,
Josef Aspelmayr

Parents
  • I left off the reference to the DPP in the extern reference in the separate assembly file.

    It appears the environment always assumes a data access (which it should) and this is why the DPP is causing you an issue (you don't want this).

    If you want to jump to a variable then I would create a function pointer assigned to the data variable address and then call it (keeping everything in C). Here is an example.

    unsigned int fls_ram[50];
    
    void (far *MyFunc)(void) = (void far *)(&fls_ram[0]);
    
    void main (void) {
    
      fls_ram[0] = 0x00DB;  /* RETS instruction */
    
      (*MyFunc)();          /* call MyFunc in XRAM */
    
      for(;;);
    }
    

    Best regards,
    Chris

Reply
  • I left off the reference to the DPP in the extern reference in the separate assembly file.

    It appears the environment always assumes a data access (which it should) and this is why the DPP is causing you an issue (you don't want this).

    If you want to jump to a variable then I would create a function pointer assigned to the data variable address and then call it (keeping everything in C). Here is an example.

    unsigned int fls_ram[50];
    
    void (far *MyFunc)(void) = (void far *)(&fls_ram[0]);
    
    void main (void) {
    
      fls_ram[0] = 0x00DB;  /* RETS instruction */
    
      (*MyFunc)();          /* call MyFunc in XRAM */
    
      for(;;);
    }
    

    Best regards,
    Chris

Children
  • Despite the DPP-addressing, the SOF-Operator shall use the 16bit-address (and this should be done with any opcode-variant).

    I was in contact with Keil and according to Support-Team this is a compiler-issue and will be solved.

    Thanks for all the help!

    Best Regards,
    Josef

  • I was in contact with Keil and according to Support-Team this is a compiler-issue and will be solved.

    Seems like you've found a bug! Nice work (reporting it)!

    I was thinking it might help to explicitly declare the fls_ram variable as huge/xhuge in the C file? To make sure it doesn't use near/DPP. But this would generate the same #SOF instruction I guess, not sure.

    Regards,
    Joost Leeuwesteijn