System information

When encountering the IF statement, the assembler evaluates the expression following the IF. All
operands in the expression must be defined ahead of the IF statement. If the expression evaluates
to a nonzero value, then statement#l through statement#n are assembled. If the expression
evaluates to zero, the statements are listed but not assembled. Conditional assembly is often used
to write a single generic program that includes a number of possible run-time environments, with
only a few specific portions of the program selected for any particular assembly. The following
program segments, for example, might be part of a program that communicates with either a
teletype or a CRT console (but not both) by selecting a particular value for TTY before the
assembly begins.
TRUE EQU 0FFFFH ;DEFINE VALUE OF TRUE
FALSE EQU NOT TRUE ;DEFINE VALUE OF FALSE
;
TTY EQU TRUE ;TRUE IF TTY, FALSE IF CRT
;
TTYBASE EQU 10H ;BASE OF TTY I/O PORTS
CRTBASE EQU 20H ;BASE OF CRT I/O PORTS
IF TTY ;ASSEMBLE RELATIVE TO
;TTYBASE
CONIN EQU TTYBASE ;CONSOLE INPUT
CONOUT EQU TTYBASE+1 ;CONSOLE OUTPUT
ENDIF
; IF NOT TTY ;ASSEMBLE RELATIVE TO
;CRTBASE
CONIN EQU CRTBASE ;CONSOLE INPUT
CONOUT EQU CRTBASE+1 ;CONSOLE OUTPUT
ENDIF
...
IN CONIN ;READ CONSOLE DATA
OUT CONTOUT ;WRITE CONSOLE DATA
In this case, the program assembles for an environment where a teletype is connected, based at
port 1 OH. The statement defining TTY can be changed to
TTY EQU FALSE
and, in this case, the program assembles for a CRT based at port 20H.
3.4 Assembler Directives CP/M Operating System Manual
3-14