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

User Stack Placement

I am considering placing the user stack into internal ram. It defaults into near which is assigned to the first 16k external ram. I am a bit confused about the asm in the startup file. The section Ex.1, see below, obviously places the user stack into near (NDATA) so i assume changing this to either IDATA or SDATA will do the trick. But after this, the section Ex.2, see below, refers the user stack to NDATA. So should this change too? If i change it, i get an error A77: Missing DPP info. Can anyone help tell me what is going on and if it is a good idea to move the user stack to internal ram in the first place.

Section Ex.1
?C_USERSTACK    SECTION DATA PUBLIC 'NDATA'
?C_USRSTKBOT:
                DS      USTSZ           ; Size of User Stack
?C_USERSTKTOP:
?C_USERSTACK    ENDS

Section Ex.2
$IF NOT TINY
IF (UST1SZ > 0) AND (UST2SZ > 0)        ; Define User Stack 1 area
NDATA           DGROUP  ?C_USERSTACK, ?C_USERSTACK1, ?C_USERSTACK2
ENDIF

Parents
  • Hi, where are you refering to when you say it still belongs to NDATA?

    I was referring to the original startup file modified as suggested by Keil to place the stack to internal RAM. Then these lines remain saying that user stack is in NDATA:

    $IF NOT TINY
    IF (UST1SZ > 0) AND (UST2SZ > 0)        ; Define User Stack 1 area
    NDATA           DGROUP  ?C_USERSTACK, ?C_USERSTACK1, ?C_USERSTACK2
    .
    .
    IF (UST1SZ = 0) AND (UST2SZ = 0)
    NDATA           DGROUP  ?C_USERSTACK
    ENDIF
    $ENDIF
    

    The usage of the DPP registers is described in the compiler documentation. The default usage is:
    DPP0 Not used for C167.
    DPP1 Used for accessing near constants (NCONST)
    DPP2 Used for accessing near data (NDATA)
    DPP3 Used for accessing SYSTEM area, 0xC000-0xFFFF.

    You can change the usage with the DPPUSE directive.

    DPP addressing is explained in the XC167 User's Manual. The DPP registers are used in indirect and direct long (16 bit) modes. The two most significant bits of the 16 bit address (GPR or memory address) select the DPP register (and thus the page), and bits 13..0 are the offset into the page.

    For example:
    DPP2 = 0x0020
    R0 = 0x8040

    The two most significant bits of R0 are 10, which selects DPP2. The 24 bit address referenced then is:
    (DPP2 << 14) + (R0 & 0x3FF) = 0x80040

    The reason you don't see any difference in the speed of accessing near/huge data is that you access it with a pointer, which in hlarge model is a 24 bit pointer, and the DPP adressing mechanism is not used. If you know that a pointer always points to near data, you may want to explicitly tell the compiler so (e.g. char * near p;, if memory serves me correct).

    Sauli

Reply
  • Hi, where are you refering to when you say it still belongs to NDATA?

    I was referring to the original startup file modified as suggested by Keil to place the stack to internal RAM. Then these lines remain saying that user stack is in NDATA:

    $IF NOT TINY
    IF (UST1SZ > 0) AND (UST2SZ > 0)        ; Define User Stack 1 area
    NDATA           DGROUP  ?C_USERSTACK, ?C_USERSTACK1, ?C_USERSTACK2
    .
    .
    IF (UST1SZ = 0) AND (UST2SZ = 0)
    NDATA           DGROUP  ?C_USERSTACK
    ENDIF
    $ENDIF
    

    The usage of the DPP registers is described in the compiler documentation. The default usage is:
    DPP0 Not used for C167.
    DPP1 Used for accessing near constants (NCONST)
    DPP2 Used for accessing near data (NDATA)
    DPP3 Used for accessing SYSTEM area, 0xC000-0xFFFF.

    You can change the usage with the DPPUSE directive.

    DPP addressing is explained in the XC167 User's Manual. The DPP registers are used in indirect and direct long (16 bit) modes. The two most significant bits of the 16 bit address (GPR or memory address) select the DPP register (and thus the page), and bits 13..0 are the offset into the page.

    For example:
    DPP2 = 0x0020
    R0 = 0x8040

    The two most significant bits of R0 are 10, which selects DPP2. The 24 bit address referenced then is:
    (DPP2 << 14) + (R0 & 0x3FF) = 0x80040

    The reason you don't see any difference in the speed of accessing near/huge data is that you access it with a pointer, which in hlarge model is a 24 bit pointer, and the DPP adressing mechanism is not used. If you know that a pointer always points to near data, you may want to explicitly tell the compiler so (e.g. char * near p;, if memory serves me correct).

    Sauli

Children