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

setting up paging options

I'm using an ASIC that pages into its RAM/ROM.
So it has 16k blocks that are paged using registers, PAGEA,PAGEB,PAGEC.
It has 128k of code and ram space. How do i setup the compiler to access the ram correctly? I know under options i can set the size of the ram but it wouldn't know about the page registers.

Do i have to declare variables in certain pages myself or will the compiler know when to put the variable into a different page? Will it know to toggle the page registers to access the data?

David

Parents
  • // Example of using page registers with 16 bit Keil addressing
    
    typedef unsigned char BYTE;
    
    enum { ptROM, ptRAM, ptIO };
    
    sfr PageType = 0x9A;
    
    #define PAGETYPEFOR4000(pt) ( PageType = ( PageType & ~0x03 ) |   (pt) )
    #define PAGETYPEFOR8000(pt) ( PageType = ( PageType & ~0x0C ) | ( (pt) << 2 ) )
    #define PAGETYPEFORC000(pt) ( PageType = ( PageType & ~0x30 ) | ( (pt) << 4 ) )
     
    sfr PageFor4000 = 0x9B;
    sfr PageFor8000 = 0x9C;
    sfr PageForC000 = 0x9D;
    
    #define PAGESZ 0x8000
    
    #define PAGE(PhysicalAddr)   ( (unsigned int)(PhysicalAddr) >> 14 )
    #define OFFSET(PhysicalAddr) ( (unsigned int)(PhysicalAddr) & (PAGESZ-1) ) 
    
    //ROM   00_0000 to 01_FFFF
    //RAM   00_0000 to 01_FFFF
    //CGROM 20_0000 to 23_FFFF
    
    //Define type and physical_address for objects
    typedef BYTE typVar1[ 0x1000 ];
    #define phyVar1  0x11020   //check PAGE( &phyVar1[0] ) = PAGE( &phyVar1[ 0x0fff] )
    
    typedef BYTE typVar2;
    #define phyVar2  0x05023
    
    void main( void )
    {
       PAGETYPEFOR4000( ptRAM ); 
       PageFor4000 = PAGE( phyVar1 );
       #define pVar1 ( (typVar1 xdata*)( OFFSET(phyVar1) || 0x4000) )
    
       PAGETYPEFORC000( ptRAM ); 
       PageForC000 = PAGE( phyVar2 );
       #define pVar2 ( (typVar2 xdata*)( OFFSET(phyVar2) || 0xC000) )
    
       (*pVar1)[20] = *pVar2;
    }
    

Reply
  • // Example of using page registers with 16 bit Keil addressing
    
    typedef unsigned char BYTE;
    
    enum { ptROM, ptRAM, ptIO };
    
    sfr PageType = 0x9A;
    
    #define PAGETYPEFOR4000(pt) ( PageType = ( PageType & ~0x03 ) |   (pt) )
    #define PAGETYPEFOR8000(pt) ( PageType = ( PageType & ~0x0C ) | ( (pt) << 2 ) )
    #define PAGETYPEFORC000(pt) ( PageType = ( PageType & ~0x30 ) | ( (pt) << 4 ) )
     
    sfr PageFor4000 = 0x9B;
    sfr PageFor8000 = 0x9C;
    sfr PageForC000 = 0x9D;
    
    #define PAGESZ 0x8000
    
    #define PAGE(PhysicalAddr)   ( (unsigned int)(PhysicalAddr) >> 14 )
    #define OFFSET(PhysicalAddr) ( (unsigned int)(PhysicalAddr) & (PAGESZ-1) ) 
    
    //ROM   00_0000 to 01_FFFF
    //RAM   00_0000 to 01_FFFF
    //CGROM 20_0000 to 23_FFFF
    
    //Define type and physical_address for objects
    typedef BYTE typVar1[ 0x1000 ];
    #define phyVar1  0x11020   //check PAGE( &phyVar1[0] ) = PAGE( &phyVar1[ 0x0fff] )
    
    typedef BYTE typVar2;
    #define phyVar2  0x05023
    
    void main( void )
    {
       PAGETYPEFOR4000( ptRAM ); 
       PageFor4000 = PAGE( phyVar1 );
       #define pVar1 ( (typVar1 xdata*)( OFFSET(phyVar1) || 0x4000) )
    
       PAGETYPEFORC000( ptRAM ); 
       PageForC000 = PAGE( phyVar2 );
       #define pVar2 ( (typVar2 xdata*)( OFFSET(phyVar2) || 0xC000) )
    
       (*pVar1)[20] = *pVar2;
    }
    

Children