diff options
Diffstat (limited to 'v2.0/source/DOSMAC_v211.ASM')
| -rw-r--r-- | v2.0/source/DOSMAC_v211.ASM | 274 |
1 files changed, 274 insertions, 0 deletions
diff --git a/v2.0/source/DOSMAC_v211.ASM b/v2.0/source/DOSMAC_v211.ASM new file mode 100644 index 0000000..3340505 --- /dev/null +++ b/v2.0/source/DOSMAC_v211.ASM | |||
| @@ -0,0 +1,274 @@ | |||
| 1 | ; | ||
| 2 | ; Macro file for MSDOS. | ||
| 3 | ; | ||
| 4 | |||
| 5 | SUBTTL BREAK a listing into pages and give new subtitles | ||
| 6 | PAGE | ||
| 7 | BREAK MACRO subtitle | ||
| 8 | SUBTTL subtitle | ||
| 9 | PAGE | ||
| 10 | ENDM | ||
| 11 | |||
| 12 | BREAK <I_NEED: declare a variable external, if necessary, and allocate a size> | ||
| 13 | |||
| 14 | ; | ||
| 15 | ; declare a variable external and allocate a size | ||
| 16 | ; | ||
| 17 | I_NEED MACRO sym,len | ||
| 18 | DATA SEGMENT BYTE PUBLIC 'DATA' | ||
| 19 | IFIDN <len>,<WORD> | ||
| 20 | EXTRN &sym:WORD | ||
| 21 | ELSE | ||
| 22 | IFIDN <len>,<DWORD> | ||
| 23 | EXTRN &sym:DWORD | ||
| 24 | ELSE | ||
| 25 | EXTRN &sym:BYTE | ||
| 26 | ENDIF | ||
| 27 | ENDIF | ||
| 28 | DATA ENDS | ||
| 29 | ENDM | ||
| 30 | |||
| 31 | ; | ||
| 32 | ; call a procedure that may be external. The call will be short. | ||
| 33 | ; | ||
| 34 | invoke MACRO name | ||
| 35 | .xcref | ||
| 36 | IF2 | ||
| 37 | IFNDEF name | ||
| 38 | EXTRN name:NEAR | ||
| 39 | ENDIF | ||
| 40 | ENDIF | ||
| 41 | .cref | ||
| 42 | CALL name | ||
| 43 | ENDM | ||
| 44 | |||
| 45 | PAGE | ||
| 46 | ; | ||
| 47 | ; jump to a label that may be external. The jump will be near. | ||
| 48 | ; | ||
| 49 | transfer MACRO name | ||
| 50 | .xcref | ||
| 51 | IF2 | ||
| 52 | IFNDEF name | ||
| 53 | EXTRN name:NEAR | ||
| 54 | ENDIF | ||
| 55 | ENDIF | ||
| 56 | .cref | ||
| 57 | JUMP name | ||
| 58 | ENDM | ||
| 59 | |||
| 60 | ; | ||
| 61 | ; get a short address in a word | ||
| 62 | ; | ||
| 63 | short_addr MACRO name | ||
| 64 | IFDIF <name>,<?> | ||
| 65 | .xcref | ||
| 66 | IF2 | ||
| 67 | IFNDEF name | ||
| 68 | EXTRN name:NEAR | ||
| 69 | ENDIF | ||
| 70 | ENDIF | ||
| 71 | .cref | ||
| 72 | DW OFFSET DOSGROUP:name | ||
| 73 | ELSE | ||
| 74 | DW ? | ||
| 75 | ENDIF | ||
| 76 | ENDM | ||
| 77 | |||
| 78 | ; | ||
| 79 | ; get a long address in a dword | ||
| 80 | ; | ||
| 81 | long_addr MACRO name | ||
| 82 | .xcref | ||
| 83 | IF2 | ||
| 84 | IFNDEF name | ||
| 85 | EXTRN name:NEAR | ||
| 86 | ENDIF | ||
| 87 | .cref | ||
| 88 | DD name | ||
| 89 | ENDM | ||
| 90 | |||
| 91 | ; | ||
| 92 | ; declare a PROC near or far but PUBLIC nonetheless | ||
| 93 | ; | ||
| 94 | procedure MACRO name,distance | ||
| 95 | PUBLIC name | ||
| 96 | name PROC distance | ||
| 97 | ENDM | ||
| 98 | |||
| 99 | PAGE | ||
| 100 | ; | ||
| 101 | ; define a data item to be public and of an appropriate size/type | ||
| 102 | ; | ||
| 103 | I_AM MACRO name,size | ||
| 104 | PUBLIC name | ||
| 105 | |||
| 106 | IFIDN <size>,<WORD> | ||
| 107 | name DW ? | ||
| 108 | ELSE | ||
| 109 | IFIDN <size>,<DWORD> | ||
| 110 | name DD ? | ||
| 111 | ELSE | ||
| 112 | IFIDN <size>,<BYTE> | ||
| 113 | name DB ? | ||
| 114 | ELSE | ||
| 115 | name DB size DUP (?) | ||
| 116 | ENDIF | ||
| 117 | ENDIF | ||
| 118 | ENDIF | ||
| 119 | ENDM | ||
| 120 | |||
| 121 | PAGE | ||
| 122 | ; | ||
| 123 | ; call the macro chain | ||
| 124 | ; | ||
| 125 | do_ext macro | ||
| 126 | endm | ||
| 127 | |||
| 128 | PAGE | ||
| 129 | |||
| 130 | ; | ||
| 131 | ; define an entry in a procedure | ||
| 132 | ; | ||
| 133 | entry macro name | ||
| 134 | PUBLIC name | ||
| 135 | name: | ||
| 136 | endm | ||
| 137 | |||
| 138 | BREAK <ERROR - print a message and then jump to a label> | ||
| 139 | |||
| 140 | error macro code | ||
| 141 | local a | ||
| 142 | .xcref | ||
| 143 | MOV AL,code | ||
| 144 | transfer SYS_RET_ERR | ||
| 145 | .cref | ||
| 146 | ENDM | ||
| 147 | |||
| 148 | BREAK <JUMP - real jump that links up shortwise> | ||
| 149 | ; | ||
| 150 | ; given a label <lbl> either 2 byte jump to another label <lbl>_J | ||
| 151 | ; if it is near enough or 3 byte jump to <lbl> | ||
| 152 | ; | ||
| 153 | |||
| 154 | jump macro lbl | ||
| 155 | local a | ||
| 156 | .xcref | ||
| 157 | a: | ||
| 158 | ifndef lbl&_J ;; is this the first invocation | ||
| 159 | JMP lbl | ||
| 160 | ELSE | ||
| 161 | IF lbl&_J GE $ | ||
| 162 | JMP lbl | ||
| 163 | ELSE | ||
| 164 | IF ($-lbl&_J) GT 126 ;; is the jump too far away? | ||
| 165 | JMP lbl | ||
| 166 | ELSE ;; do the short one... | ||
| 167 | JMP lbl&_J | ||
| 168 | ENDIF | ||
| 169 | ENDIF | ||
| 170 | ENDIF | ||
| 171 | lbl&_j = a | ||
| 172 | .cref | ||
| 173 | endm | ||
| 174 | |||
| 175 | BREAK <RETURN - return from a function> | ||
| 176 | |||
| 177 | return macro | ||
| 178 | local a | ||
| 179 | .xcref | ||
| 180 | a: | ||
| 181 | RET | ||
| 182 | ret_l = a | ||
| 183 | .cref | ||
| 184 | endm | ||
| 185 | |||
| 186 | BREAK <CONDRET - conditional return> | ||
| 187 | |||
| 188 | makelab macro l,cc,ncc | ||
| 189 | local a | ||
| 190 | j&ncc a ;; j<NCC> a: | ||
| 191 | return ;; return | ||
| 192 | a: ;; a: | ||
| 193 | ret_&cc = ret_l ;; define ret_<CC> to be ret_l | ||
| 194 | endm | ||
| 195 | |||
| 196 | condret macro cc,ncc | ||
| 197 | local a,b | ||
| 198 | ifdef ret_l ;; if ret_l is defined | ||
| 199 | if (($ - ret_l) le 126) and ($ gt ret_l) | ||
| 200 | ;; if ret_l is near enough then | ||
| 201 | a: j&cc ret_l ;; a: j<CC> to ret_l | ||
| 202 | ret_&cc = a ;; define ret_<CC> to be a: | ||
| 203 | else | ||
| 204 | makelab a,cc,ncc | ||
| 205 | endif | ||
| 206 | else | ||
| 207 | ifdef ret_&cc ;; if ret_<CC> defined | ||
| 208 | if (($ - ret_&cc) le 126) and ($ gt ret_&cc) | ||
| 209 | ;; if ret_<CC> is near enough | ||
| 210 | a: j&cc ret_&cc ;; a: j<CC> to ret_<CC> | ||
| 211 | ret_&cc = a ;; define ret_<CC> to be a: | ||
| 212 | else | ||
| 213 | makelab a,cc,ncc | ||
| 214 | endif | ||
| 215 | else | ||
| 216 | makelab a,cc,ncc | ||
| 217 | endif | ||
| 218 | endif | ||
| 219 | endm | ||
| 220 | ;condret macro cc,ncc | ||
| 221 | ; local a,b | ||
| 222 | ; ifdef ret_l ; if ret_l is defined | ||
| 223 | ; if (($ - ret_l) le 126) and ($ gt ret_l) | ||
| 224 | ; ; if ret_l is near enough then | ||
| 225 | ; a: j&cc ret_l ; a: j<CC> to ret_l | ||
| 226 | ; ret_&cc = a ; define ret_<CC> to be a: | ||
| 227 | ; exitm | ||
| 228 | ; endif | ||
| 229 | ; endif | ||
| 230 | ; ifdef ret_&cc ; if ret_<CC> defined | ||
| 231 | ; if (($ - ret_&cc) le 126) and ($ gt ret_&cc) | ||
| 232 | ; ; if ret_<CC> is near enough | ||
| 233 | ; a: j&cc ret_&cc ; a: j<CC> to ret_<CC> | ||
| 234 | ; ret_&cc = a ; define ret_<CC> to be a: | ||
| 235 | ; exitm | ||
| 236 | ; endif | ||
| 237 | ; endif | ||
| 238 | ; j&ncc a ; j<NCC> a: | ||
| 239 | ; return ; return | ||
| 240 | ; a: ; a: | ||
| 241 | ; ret_&cc = ret_l ; define ret_<CC> to be ret_l | ||
| 242 | ;endm | ||
| 243 | ; | ||
| 244 | BREAK <RETZ - return if zero, links up shortwise if necessary> | ||
| 245 | |||
| 246 | retz macro | ||
| 247 | condret z,nz | ||
| 248 | endm | ||
| 249 | |||
| 250 | BREAK <RETNZ - return if not zero, links up shortwise if necessary> | ||
| 251 | |||
| 252 | retnz macro | ||
| 253 | condret nz,z | ||
| 254 | endm | ||
| 255 | |||
| 256 | BREAK <RETC - return if carry set, links up shortwise if necessary> | ||
| 257 | |||
| 258 | retc macro | ||
| 259 | condret c,nc | ||
| 260 | endm | ||
| 261 | |||
| 262 | BREAK <RETNC - return if not carry, links up shortwise if necessary> | ||
| 263 | |||
| 264 | retnc macro | ||
| 265 | condret nc,c | ||
| 266 | endm | ||
| 267 | |||
| 268 | BREAK <CONTEXT - set the DOS context to a particular register> | ||
| 269 | |||
| 270 | context macro r | ||
| 271 | PUSH SS | ||
| 272 | POP r | ||
| 273 | ASSUME r:DOSGROUP | ||
| 274 | endm | ||