|
|
III.10.2 IFxx and ELSEIFxx Instructions The particular IFxx instructions are working as follows:
The corresponding ELSEIFxx instructions are working respectively.
IF .. ELSE .. ENDIF construction
TARGET EQU 0 ;configuration: 1 for application board
;-------------- 0 for evaluation board
IF TARGET
ORG 0 ;program start address of application board
ELSE
ORG 8000H ;program start address of evaluation board
ENDIF
Currently the program is configured for the evaluation board version.
IFNDEF .. ELSE .. ENDIF construction
;EVA_537 EQU 0 ;symbol undefined: 80C537 application board
;symbol defined: 80C537 evaluation board
IFNDEF EVA_537
CLOCK EQU 16 ;clock frequency of application board
CSEG AT 0 ;program start address of application board
ELSE
CLOCK EQU 12 ;clock frequency of evaluation board
CSEG AT 8000H ;program start address of evaluation board
ENDIF
Currently the program is configured for the application board version.
IFB .. ELSE .. ENDIF construction
DECIDE MACRO X, Y
IFB <X&Y>
NOP
NOP
ELSE
DB '&X,&Y'
ENDIF
ENDM
If the above macro is invoked as follows,
DECIDE Nonsense
the parameter X will be replaced by "Nonsense" and the parameter Y by a zero length string. Thus the IFB literal becomes <Nonsense>, and the macro will be expanded to:
DB 'Nonsense,'
If the macro will be invoked without arguments,
DECIDE
the parameters X and Y will be replaced by zero length strings both, and the IFB literal becomes <>. Thus the macro will be expanded to:
NOP
NOP
Macros are explained in detail in chapter "III.11 Macro Processing".
IFNDEF .. ELSEIF .. ELSEIF .. ELSE .. ENDIF construction
IFNDEF BAUDRATE
LJMP AUTOBAUD ;automatic baudrate detection
ELSEIF BAUDRATE EQ 9600
MOV TH1, #0FDH ;9600 baud
ELSEIF BAUDRATE EQ 1200
MOV TH1, #0E8H ;1200 baud
ELSE
$ERROR(baudrate not implemented)
ENDIF
If the symbol BAUDRATE is not defined at all, a jump to the label AUTOBAUD is performed.
|