Each module in the symbol file contains a linked list of segment definitions. To obtain a pointer to the first segment definition, multiply the value of the ppSegDef member in the current MAPDEF structure by 16, as follows:
/* File is loaded at pFileBuffer. */
pSegDef = (SEGDEF *)(pFileBuffer + (md.ppSegDef * 16));
Each segment definition contains a pointer to the next segment definition in the chain. This pointer is a 16-bit number that, when multiplied by 16, gives the byte offset of the next segment definition in the file, as follows:
pNextSegDef = (SEGDEF *)(pFileBuffer + (pSegDef->ppNextSeg * 16));
The pointer in the last segment definition is not zero. The linked list of segment definitions is circular—the pointer in the last segment definition gives the offset of the first segment definition. You can use the cSegs member in the MAPDEF structure to determine the number of segments in the module.
The SEGDEF structure for these lists has the following form:
typedef struct {
WORD ppNextSeg; /* paragraph pointer to next segment */
WORD cSymbols; /* count of symbols in list */
WORD pSymDef; /* offset of symbol chain */
WORD wReserved1; /* reserved */
WORD wReserved2; /* reserved */
WORD wReserved3; /* reserved */
WORD wReserved4; /* reserved */
BYTE bFlags; /* symbol types */
BYTE bReserved1; /* reserved */
WORD ppLineDef; /* offset of line-number record */
BYTE bReserved2; /* reserved */
BYTE bReserved3; /* reserved */
BYTE cbSegName; /* length of segment name */
char achSegName[1]; /* n bytes of segment-name member */
} SEGDEF;
Following are the members of the SEGDEF structure:
ppNextSeg
Specifies the offset from the beginning of the file to the next SEGDEF structure in the chain. Multiply the value of the ppNextSeg member by 16 to obtain the offset.
cSymbols
Specifies the number of symbols in this segment.
pSymDef
Specifies the offset from the beginning of the segment definition to an array of pointers to symbol definitions. This value is not multiplied by 16 to obtain the offset. For more details, see Section 12.3, “Symbol Definitions.”
wReserved1
Reserved.
wReserved2
Reserved.
wReserved3
Reserved.
wReserved4
Reserved.
bFlags
Specifies the type of symbols in this segment. The bFlags member can be one or more of the following values:
Value | Meaning |
0 | Contains 16-bit symbols. |
1 | Contains 32-bit symbols. |
2 | Includes alphabetic symbol table. |
bReserved1
Reserved.
ppLineDef
Specifies the offset from the beginning of the file to the first line-number definition. Multiply the value of the ppLineDef member by 16 to obtain the offset.
bReserved2
Reserved.
bReserved3
Reserved.
cbSegName
Specifies the length of the segment name.
achSegName
Specifies a variable-length array of characters containing the segment name. The name is not null-terminated.