Table of Contents        Previous topic       Next topic       

The Extension Interface->Variant Specific Interface Calls->GetRegisters()

extern "C" LONG GetRegisters(LONG nExtensionState)

This call allows the extension to set the register names and addresses that will be displayed in the registers window of the Virtual Workshop.

The extension should return a struct tagRegisters* that points to the start of an array of structures containing information on the registers to be displayed.

If an extension does not wish to handle this call then is should return NULL.

struct tagRegisters
    char* pszName;
    BYTE nWidthInBits;
    BYTE nSfrAddress;
pszNameThis points to the name of the SFR that will be displayed in the registers window.  For the last structure in the array, this element should be NULL.
nWidthInBitsThis contains the width in bits of the SFR and will be either 8 or 16.
nSfrAddressThis contains the address of the SFR.  For 16 bit SFR's is should contain the address of the low byte.

The following example illustrates the array of structures that would be used for the Atmel AT89C52:

struct tagRegisters regAT89C52[] = {
    "ACC", 8, 0XE0,
    "B", 8, 0XF0,
    "TCON", 8, 0X88,
    "T2CON", 8, 0XC8,
    "T2MOD", 8, 0XC9,
    "TMOD", 8, 0X89,
    "TH0", 8, 0X8C,
    "TL0", 8, 0X8A,
    "TH1", 8, 0X8D,
    "TL1", 8, 0X8B,
    "TH2", 8, 0XCD,
    "TL2", 8, 0XCC,
    "RCAP2H", 8, 0XCB,
    "RCAP2L", 8, 0XCA,
    "SCON", 8, 0X98,
    "SBUFi", 8, 0X99 - 0X80,
    "SBUFo", 8, 0X99,
    "P0", 8, 0X80,
    "P0pin", 8, 0X80 - 0X80,
    "P1", 8, 0X90,
    "P1pin", 8, 0X90 - 0X80,
    "P2", 8, 0XA0,
    "P2pin", 8, 0XA0 - 0X80,
    "P3", 8, 0XB0,
    "P3pin", 8, 0XB0 - 0X80,
    "IE", 8, 0XA8,
    "IP", 8, 0XB8,
    "PCON", 8, 0X87,
    "PSW", 8, 0XD0,
    "SP", 8, 0X81,
    "DPTR", 16, 0X82,    // the address of the low byte
    0            // terminator

The extension should return (LONG)&regAT89C52[0] in response to the GetRegisters() call.

Note the addresses for SBUFi, P0pin, P1pin, P2pin and P3pin in the above array.  These are the addresses of SBUF, P0, P1, P2 and P3 displaced by 0X80. Since SBUF, P0,P1, P2 and P3 are associated with two values (input and output) two values need to be stored for each them.  The simulator therefore stores the second value in the lower half of the 256 byte array that is used for SFR storage.