Search code examples
cmicrocontrollerextern

Looking for explanation on variable or keyword "code" in extern statement "extern SensLocationStruct code SensLocation[];"


I'm currently figuring out the function and structure of someone else's code, if you have any advice about that it would be appreciated as well.

Anyway, I have come across a word that is included in some extern lines. Here are several lines of code that I have come across.

extern unchar code Sdrr[];
extern SensLocationStruct code SensLocation[];
extern SensorConfigStruct code SensorConfig[];
extern unchar code DefaultFruData[];
extern FruLocationStruct code FruDevice[];

Now, the word I am talking about is "code".

After sifting through the code, I see no special declaration or definition of the word "code". It does not seem to even been called in a function later on either. It only appears in these extern statements.

The structs are:

typedef struct
{
    unsigned char device;
    unsigned char addr;
    unsigned char bus;
} SensLocationStruct;


typedef struct
{
    unsigned char SensNum;
    unsigned char device;
    unsigned char IOType;
    unsigned char regIO;
    unsigned char calib;
} SensorConfigStruct;

typedef struct
{
    unsigned char device;
    unsigned char addr;
    unsigned char bus;
    unsigned char frusize;
} FruLocationStruct;

Does anyone have any idea of what this is or does? Anything will help.


Solution

  • This is usually used to define the memory space where the variable resides. Intel uses the von Neumann architecture. There is only one address space, an address like 0x100 clearly identifies the target. On the other hand the Harvard architecture have this address twice: In the program code memory and in the data memory space. The 8051 family have three memory spaces: ProgramCode, InternalRAM and externalRAM. Each of them requires different instruction for access on assembler level.