Table of Contents        Previous topic       Next topic       

CROSS ASSEMBLER->Bankable Segments

The C compiler directly supports code bank switching, but bankable code and xdata segments can also be created using the SEGMENT directive.  Bankable segments will be located into the specified ROM or RAM bank and the address ranges of these banks can overlap with each other.

<segment name>  SEGMENT  <segment type> <bank attributes>

<segment type> can be CODE or XDATA.

<bank attributes> is:

BANK,<bank number>[,<bank switch location>,<bank switch attributes>]

<bank number> is a numerical value between 0 and 255.  This must correspond to the bank number used a /ROM or /XRAM linker option.

<bank switch location> and <bank switch attributes> are required for CODE banks if you wish the Crossware 8051 Virtual Workshop to be able to control bank switching.

<bank switch location> can be PORT, SFR or XDATA and signifies the memory area that is written to to switch banks.

<bank switch attributes> is a 32 bit number.  The least significant word is the address written to to switch banks, the next significant byte is the mask to use during the write operation and the most significant byte is the value to write.

For example:


This creates a bankable code segment numbered bank 1.


This creates a bankable code segment numbered bank 2.  The Virtual Workshop will write a 2 into 8051 Port 1 (address 0X90) in order to activate this bank and load the code into it.

    DS    2

This creates a bankable xdata segment numbered bank 1.