Every assembly time expression is assigned a segment type, depending on its operands and operators. The segment type indicates the address space, the expression result might belong to, if it were used as an address. There are six possible segment types:
CODE DATA IDATA XDATA BIT NUMBER (typeless)
Most expression results have the segment type NUMBER. That means they are assumed to be typeless. However, in some cases it may be useful to assign a particular segment type! The following six rules apply when the segment type is evaluated:
Examples:
The following symbols have been defined in a program:OFFSET EQU 16 START CODE 30H DOIT CODE 0100H REDLED BIT P1.3 VARIAB4 DATA 20H PORT DATA 0C8H RELAY EQU 5
1.) The expression START+OFFSET+3 will have the segment type CODE. 2.) The expression START+DOIT will be typeless. 3.) The expression DOIT-REDLED will be typeless. 4.) The expression 2*VARIAB4 will be typeless. 5.) The expression PORT.RELAY will have the segment type BIT.
The segment type is checked, when expressions appear as addresses. If the
expression result is not typeless and does not have the segment type of the
corresponding segment, the instruction is flagged with an error message.
The only exceptions are the segment types DATA and IDATA, which are assumed
to be compatible in the address range of 0 to 7FH. Since
Example:
Line I Addr Code Source 1: N 30 DSEG AT 030H ;internal RAM 2: 30 N 01 COUNT: DS 1 ;counter variable 3: 4: CSEG ;ROM 5: 0000 C2 30 START: CLR COUNT ^ @@@@@ segment type mismatch @@@@@
The CLR instruction is flagged with the error message “segment type mismatch” in the assembler list file, because only a BIT type address is allowed here. However, COUNT is a label with the segment type DATA!