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

Dallas contiguous mode : two doubts

Hi,

I have the following two doubts:

1)
When should I use Dallas contiguous mode:512k vs Dallas contiguous mode: 16M ?
512k is enough for me but I do not know if I get some advantages with 16M mode!?

2)
How to locate all functions in a file to a specific location: example 102H?
filename: ulm.c

Thanks
joao

  • "2) How to locate all functions in a file to a specific location: example 102H?
    filename: ulm.c"


    Well, they can't all go at the same location, can they?! ;-)

    This is a job for the Linker (or, to be precise, the Locator) - not the Compiler:
    http://www.keil.com/forum/docs/thread3487.asp

  • When should I use Dallas contiguous mode:512k vs Dallas contiguous mode: 16M ?
    512k is enough for me but I do not know if I get some advantages with 16M mode!?


    Refer to the compiler manual for an explanation of 512K vs 16M.

    http://www.keil.com/support/man/docs/c51/c51_rom.htm

    The only real difference is the size of jmp and call instructions. Obviously, the longer instructions (for 16M) take longer to execute because they must fetch an extra byte. They also use up more code space.

    Jon

  • 1)
    Mr. Jon Ward
    Thanks.
    I have a program with just 4355 bytes of code on both modes! It uses Cx51 and Lx51.

    Probably you are wright regarding speed but size is not very clear to me since 19 and 24 bit both use 3 byte pointers!

    My guess is that the compiler must know if we are using paged or segmented mode but I was wondered if any other "compiler effects" could happen!

    speed if of course important:)

    2)
    Mr.Andrew Neil
    Thanks.

    After looking I have found and tested with success : ?PR?*?ulm(C:0x0102)

    But looking at the map another doubt come in to me:
    I use FVAR on ulm.c
    FVAR is calling ?C?CLDPTR and ?C?CSTPTR
    Also I am seing a call to ?C?ULSHR and ?C?CLDPTR.
    I need to have every code executed "within" ulm.c placed on internal memory so I also have to locate these functions.
    Do they belong to ?C?LIB_CODE ? So, I just need to locate it!

  • Probably you are wright regarding speed but size is not very clear to me since 19 and 24 bit both use 3 byte pointers!

    Wrong.

    The size of an AJMP instruction on the Dallas 390/400/5240 is 3 bytes and the size of the LJMP instruction is 4 bytes.

    The AJMP instruction has a 19-bit address. 3 of those bits are encoded in the opcode. Ergo, there are 8 AJMP instructions.

    Jon

  • I have a program with just 4355 bytes of code on both modes! It uses Cx51 and Lx51.

    Then there may be no need at all for using any contiguous mode. Not yet. Contiguous mode only pays off if you have more than 64 KB of code and/or 64KB of data to manage.

  • Some comments:

    1) My program is a LOADER so I need to access 512k of far data.
    I am now trying the compact mode.
    If I use FVAR macros does the compiler generates correct code for far data access on other mode than contiguous?!
    if so I have one huge doubt:) How the compiler knows I am using 24-bit paged addressing mode and not 24-bit contiguous addressing mode!? The assembler to generate is different.
    I have to investigate this.

    By the way I have noted that I can not use _lrol_ macro on contiguous mode!?


    2) It is true that in 16M mode the LCALL,LJMP and MOV DPTR are 4 bytes long. I believe that because I have "linker code packing" turned on the size is the same in my case for both contiguous modes!

    But speed and size are not linear on both modes. I feel we can have 16M code faster and tiny than 512K! On 512K "I think" the compiler uses paged mode so page switch must happen even on interrupts!


    Joao

  • But speed and size are not linear on both modes. I feel we can have 16M code faster and tiny than 512K! On 512K "I think" the compiler uses paged mode so page switch must happen even on interrupts!

    You think wrongly, then. 512K and 16M mode really only differ in the maximum allowed distance between any two addresses in code memory. Neither is more similar to paged mode than the other: they will both have to save DPX on entry to interrupt handlers, since that's an integral part of the DPTR now, not because it might be a code banking page register.

    In principle, you could indeed stay with COMPACT model code and use FVAR macros to access your 512K of RAM, but you'ld have to use paged XRAM address mode to implement far data memory accesses, i.e. you'ld have to fiddle with the runtime setup files (START390.A51 and XBANKING.A51).

    But if you want it simple and have the tools (i.e. the full PK51 kit), just stick with contiguous mode. Paged addressing is more trouble than it's worth, IMHO.

  • First thanks for your comments.
    I now understand that I need to study carefully:)

    I have tested with the following code:

    char far a _at_ 0x12000L;
    char xdata b;
    
    char farfunc(void)
    {
        return a+b;
    }
    
    void main(void)
    {
        farfunc();
        while(1);
    }
    

    The farfunc is located at 0x010000

    On 512k mode the assembler is:
    ; FUNCTION farfunc (BEGIN)
                                               ; SOURCE LINE # 6
                                               ; SOURCE LINE # 7
                                               ; SOURCE LINE # 9
    0000 90000000    R     MOV     DPTR,#b
    0004 E0                MOVX    A,@DPTR
    0005 FF                MOV     R7,A
    0006 90000000    R     MOV     DPTR,#a
    000A E0                MOVX    A,@DPTR
    000B FE                MOV     R6,A
    000C EF                MOV     A,R7
    000D 2E                ADD     A,R6
    000E FF                MOV     R7,A
                                               ; SOURCE LINE # 10
    000F         ?C0001:
    000F 22                RET
                 ; FUNCTION farfunc (END)
    
                 ; FUNCTION main (BEGIN)
                                               ; SOURCE LINE # 13
                                               ; SOURCE LINE # 14
                                               ; SOURCE LINE # 15
    0000 110000      R     ACALL   farfunc
    0003         ?C0002:
                                               ; SOURCE LINE # 16
    0003 80FE              SJMP    ?C0002
                 ; FUNCTION main (END)
    

    MOVX DPTR are always 4 bytes(XDATA and HDATA) and the compiler uses ACALL(19 bit addr) - 3 bytes.

    On 16M mode the assembler is:
    ; FUNCTION farfunc (BEGIN)
                                               ; SOURCE LINE # 6
                                               ; SOURCE LINE # 7
                                               ; SOURCE LINE # 9
    0000 90000000    R     MOV     DPTR,#b
    0004 E0                MOVX    A,@DPTR
    0005 FF                MOV     R7,A
    0006 90000000    R     MOV     DPTR,#a
    000A E0                MOVX    A,@DPTR
    000B FE                MOV     R6,A
    000C EF                MOV     A,R7
    000D 2E                ADD     A,R6
    000E FF                MOV     R7,A
                                               ; SOURCE LINE # 10
    000F         ?C0001:
    000F 22                RET
                 ; FUNCTION farfunc (END)
    
                 ; FUNCTION main (BEGIN)
                                               ; SOURCE LINE # 13
                                               ; SOURCE LINE # 14
                                               ; SOURCE LINE # 15
    0000 12000000    R     LCALL   farfunc
    0004         ?C0002:
                                               ; SOURCE LINE # 16
    0004 80FE              SJMP    ?C0002
                 ; FUNCTION main (END)
    
    MOVX DPTR are still 4 bytes(XDATA and HDATA) and the compiler uses LCALL(24 bit addr) - 4 bytes.

    No paging for data access.
    In conclusion I must always configure the DS5250 for 24-bit contiguous mode.


    Just on note from the assembler: it seems that is generating one unnecessary MOV operation on the farfunc but this is another story.

    Thanks for all your comments.
    My biggest problem is that the projects timmings are really small so there is phew time for first understanding what really is going on!

    Joao