1           .XLIST
  2           PAGE      58,132
  3 ;**
  4 ;
  5 ; This macro library defines the operating environment for the 8086 S
  6 ; memory model, which allows 64Kbytes of data and 64Kbytes of program.
  7 ;
  8 ;**
  9 MSDOS     EQU       2
 10 
 11 ;**
 12 ;
 13 ; The following symbols define the 8086 memory mode being used.  Set LPROG
 14 ; to 1 for a large program segment (greater than 64K-bytes), and set LDATA
 15 ; to 1 for a large data segment.  Set COM to 1 to generate .COM files
 16 ; instead of .EXE files.  Note that if COM is not zero, then LPROG and
 17 ; LDATA must be 0.
 18 ;
 19 ;**
 20 COM       EQU       0
 21 LPROG     EQU       0
 22 LDATA     EQU       0
 23 
 24 ;**
 25 ;
 26 ; The following symbols are established via LPROG and LDATA as follows:
 27 ;
 28 ;         S8086     set for small model (small prog, small data)
 29 ;         D8086     set for model with large data, small prog
 30 ;         P8086     set for model with large prog, small data
 31 ;         L8086     set for large model
 32 ;
 33 ;**
 34           IF        (LPROG EQ 0) AND (LDATA EQ 0)
 35 S8086     EQU       1
 36 D8086     EQU       0
 37 P8086     EQU       0
 38 L8086     EQU       0
 39           ENDIF
 40 
 41           IF        (LPROG EQ 0) AND (LDATA NE 0)
 42 S8086     EQU       0
 43 D8086     EQU       1
 44 P8086     EQU       0
 45 L8086     EQU       0
 46           ENDIF
 47 
 48           IF        (LPROG NE 0) AND (LDATA EQ 0)
 49 S8086     EQU       0
 50 D8086     EQU       0
 51 P8086     EQU       1
 52 L8086     EQU       0
 53           ENDIF
 54 
 55           IF        (LPROG NE 0) AND (LDATA NE 0)
 56 S8086     EQU       0
 57 D8086     EQU       0
 58 P8086     EQU       0
 59 L8086     EQU       1
 60           ENDIF
 61 
 62 
 63 ;**
 64 ;
 65 ; The DSEG and PSEG macros are defined to generate the appropriate GROUP
 66 ; and SEGMENT statements for the memory model being used.  The ENDDS and
 67 ; ENDPS macros are then used to end the segments.
 68 ;
 69 ;**
 70 DSEG      MACRO
 71 DGROUP    GROUP     DATA
 72 DATA      SEGMENT   WORD PUBLIC 'DATA'
 73           ASSUME    DS:DGROUP
 74           ENDM
 75 ENDDS     MACRO
 76 DATA      ENDS
 77           ENDM
 78 
 79           IF        S8086
 80 PSEG      MACRO
 81 PGROUP    GROUP     PROG
 82 PROG      SEGMENT   BYTE PUBLIC 'PROG'
 83           ASSUME    CS:PGROUP
 84           ENDM
 85 ENDPS     MACRO
 86 PROG      ENDS
 87           ENDM
 88           ENDIF
 89 
 90           IF        D8086
 91 PSEG      MACRO
 92 CGROUP    GROUP     CODE
 93 CODE      SEGMENT   BYTE PUBLIC 'CODE'
 94           ASSUME    CS:CGROUP
 95           ENDM
 96 ENDPS     MACRO
 97 CODE      ENDS
 98           ENDM
 99           ENDIF
100 
101           IF        P8086
102 PSEG      MACRO
103 _CODE     SEGMENT   BYTE
104           ASSUME  CS:_CODE
105           ENDM
106 ENDPS     MACRO
107 _CODE     ENDS
108           ENDM
109           ENDIF
110 
111           IF        L8086
112 PSEG      MACRO
113 _PROG     SEGMENT   BYTE
114           ASSUME    CS:_PROG
115           ENDM
116 ENDPS     MACRO
117 _PROG     ENDS
118           ENDM
119           ENDIF
120 
121 ;**
122 ;
123 ; The BEGIN and ENTRY macros establish appropriate function entry points
124 ; depending on whether NEAR or FAR program addressing is being used.  The
125 ; only difference between the two is that BEGIN generates a PROC operation
126 ; to start a segment.
127 ;
128 BEGIN     MACRO     NAME                          ; begin a function
129           PUBLIC  NAME
130           IF        LPROG
131 NAME      PROC      FAR
132           ELSE
133 NAME      PROC      NEAR
134           ENDIF
135           ENDM
136 
137 ENTRY     MACRO     NAME
138           PUBLIC    NAME
139           IF        LPROG
140 NAME      LABEL     FAR
141           ELSE
142 NAME      LABEL     NEAR
143           ENDIF
144           ENDM
145 
146 ;**
147 ;
148 ; The following symbols are defined to help set up a STRUC defining the
149 ; stack frame:
150 ;
151 ;         CPSIZE -> code pointer size (2 or 4)
152 ;         DPSIZE -> data pointer size (2 or 4)
153 ;
154 ; These wouldn't be necessary if it were possible to use macros or even
155 ; conditionals within a STRUC.
156 ;
157           IF        LPROG
158 CPSIZE    EQU       4
159           ELSE
160 CPSIZE    EQU       2
161           ENDIF
162           IF        LDATA
163 DPSIZE    EQU       4
164           ELSE
165 DPSIZE    EQU       2
166           ENDIF
167           .LIST