Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

524 lines
9.6 KiB

  1. ; DOS Interface Macros - Version 1.0 - for Microsoft Macro Assembler 5.0
  2. ; (C) Copyright Microsoft Corporation, 1987, 1988.
  3. .XCREF
  4. .XLIST
  5. IF1
  6. ; Internal
  7. __LdAdr MACRO reg, adr
  8. IF (.TYPE (adr)) AND 00010000b ;; Register
  9. mov reg, adr
  10. ELSEIF (.TYPE (adr)) AND 00000100b ;; Constant
  11. mov reg, adr
  12. ELSEIF TYPE (adr) EQ 1 ;; Bytes
  13. mov reg, OFFSET adr
  14. ELSEIF TYPE (adr) EQ 2 ;; Near pointer
  15. mov reg, adr
  16. ELSEIF TYPE (adr) EQ 4 ;; Far pointer
  17. lds reg, adr
  18. ELSE
  19. .ERR
  20. %OUT Illegal argument
  21. ENDIF
  22. ENDM
  23. ; Internal
  24. __LdSeg MACRO dest, src
  25. IFIDNI <src>, <es> ;; Segment register
  26. mov ax, src
  27. mov dest, ax
  28. ELSEIFIDNI <src>, <ss>
  29. mov ax, src
  30. mov dest, ax
  31. ELSEIFIDNI <src>, <ds>
  32. mov ax, src
  33. mov dest, ax
  34. ELSEIFIDNI <src>, <ds>
  35. mov ax, src
  36. mov dest, ax
  37. ELSEIF (.TYPE (src)) AND 00000100b ;; Constant
  38. mov ax, src
  39. mov dest, ax
  40. ELSE ;; Memory or general register
  41. mov dest, src
  42. ENDIF
  43. ENDM
  44. ; 01h, 07h, 08h, 0Ch
  45. @GetKey MACRO echo, cc, clear
  46. LOCAL funct, disp
  47. IFDIF <echo>, <0>
  48. IFDIF <cc>, <0>
  49. funct = 01h
  50. ELSE
  51. funct = 07h
  52. disp = 02h
  53. ENDIF
  54. ELSE
  55. IFDIF <cc>, <0>
  56. funct = 08h
  57. ELSE
  58. funct = 07h
  59. ENDIF
  60. ENDIF
  61. IFB <clear>
  62. mov ah, funct
  63. ELSE
  64. IFIDN <clear>, <0>
  65. mov ah, funct
  66. ELSE
  67. mov ah, 0Ch
  68. mov al, funct
  69. ENDIF
  70. ENDIF
  71. int 21h
  72. IFDEF disp
  73. mov dl, al
  74. mov ah, disp
  75. int 21h
  76. ENDIF
  77. ENDM
  78. ; 0Ah
  79. @GetStr MACRO ofset, terminator, limit, segmnt
  80. __LdAdr dx, <ofset>
  81. IFNB <segmnt>
  82. __LdSeg ds, <segmnt>
  83. ENDIF
  84. mov ah, 0Ah
  85. mov si, dx
  86. IFNB <limit>
  87. mov BYTE PTR [si], limit
  88. ENDIF
  89. int 21h
  90. inc si
  91. mov bl, [si]
  92. sub bh, bh
  93. inc si
  94. IFNB <terminator>
  95. mov BYTE PTR [bx+si], terminator
  96. ENDIF
  97. ENDM
  98. ; 02h
  99. @DispCh MACRO ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10
  100. mov ah, 02h
  101. IRP char, <ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10>
  102. IFB <char>
  103. EXITM
  104. ENDIF
  105. mov dl, char
  106. int 21h
  107. ENDM
  108. ENDM
  109. ; 05h
  110. @PrtCh MACRO ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10
  111. mov ah, 05h
  112. IRP char, <ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10>
  113. IFB <char>
  114. EXITM
  115. ENDIF
  116. mov dl, char
  117. int 21h
  118. ENDM
  119. ENDM
  120. ; 09h
  121. @DispStr MACRO ofset, segmnt
  122. __LdAdr dx, <ofset>
  123. IFNB <segmnt>
  124. __LdSeg ds, <segmnt>
  125. ENDIF
  126. mov ah, 9
  127. int 21h
  128. ENDM
  129. ; 3Fh
  130. @Read MACRO ofset, bytes, handle, segmnt
  131. IFNB <handle>
  132. mov bx, handle
  133. ELSE
  134. sub bx, bx
  135. ENDIF
  136. mov cx, bytes
  137. __LdAdr dx, <ofset>
  138. IFNB <segmnt>
  139. __LdSeg ds, <segmnt>
  140. ENDIF
  141. mov ah, 3Fh
  142. int 21h
  143. ENDM
  144. ; 40h
  145. @Write MACRO ofset, bytes, handle, segmnt
  146. IFNB <handle>
  147. mov bx, handle
  148. ELSE
  149. mov bx, 1
  150. ENDIF
  151. mov cx, bytes
  152. __LdAdr dx, <ofset>
  153. IFNB <segmnt>
  154. __LdSeg ds, <segmnt>
  155. ENDIF
  156. mov ah, 40h
  157. int 21h
  158. ENDM
  159. ; 3Ch
  160. @MakFil MACRO path, atrib, segmnt, kind
  161. IFB <atrib>
  162. sub cx, cx
  163. ELSE
  164. mov cx, atrib
  165. ENDIF
  166. __LdAdr dx, <path>
  167. IFNB <segmnt>
  168. __LdSeg ds, <segmnt>
  169. ENDIF
  170. IFIDNI <kind>, <tmp>
  171. mov ah, 5Ah
  172. ELSEIFIDNI <kind>, <new>
  173. mov ah, 5Bh
  174. ELSE
  175. mov ah, 3Ch
  176. ENDIF
  177. int 21h
  178. ENDM
  179. ; 3Dh
  180. @OpenFil MACRO path, access, segmnt
  181. __LdAdr dx, <path>
  182. IFNB <segmnt>
  183. __LdSeg ds, <segmnt>
  184. ENDIF
  185. mov ax, 3D00h + (access AND 0FFh)
  186. int 21h
  187. ENDM
  188. ; 3Eh
  189. @ClosFil MACRO handle
  190. mov bx, handle
  191. mov ah, 3Eh
  192. int 21h
  193. ENDM
  194. ; 41h
  195. @DelFil MACRO path, segmnt
  196. __LdAdr dx, <path>
  197. IFNB <segmnt>
  198. __LdSeg ds, <segmnt>
  199. ENDIF
  200. mov ah, 41h
  201. int 21h
  202. ENDM
  203. ; 56h
  204. @MoveFil MACRO old, new, segold, segnew
  205. __LdAdr dx, <old>
  206. __LdAdr di, <new>
  207. IFNB <segold>
  208. __LdSeg ds, <segold>
  209. ENDIF
  210. IFNB <segnew>
  211. __LdSeg es, <segnew>
  212. ENDIF
  213. mov ah, 56h
  214. int 21h
  215. ENDM
  216. ; 4Eh
  217. @GetFirst MACRO path, atrib, segmnt
  218. IFNB <atrib>
  219. mov cx, atrib
  220. ELSE
  221. sub cx, cx
  222. ENDIF
  223. __LdAdr dx, <path>
  224. IFNB <segmnt>
  225. __LdSeg ds, <segmnt>
  226. ENDIF
  227. mov ah, 4Eh
  228. int 21h
  229. ENDM
  230. ; 4Fh
  231. @GetNext MACRO
  232. mov ah, 4Fh
  233. int 21h
  234. ENDM
  235. ; 2Fh
  236. @GetDTA MACRO
  237. mov ah, 2Fh
  238. int 21h
  239. ENDM
  240. ; 1Ah
  241. @SetDTA MACRO buffer, segmnt
  242. __LdAdr dx, <buffer>
  243. IFNB <segmnt>
  244. __LdSeg ds, <segmnt>
  245. ENDIF
  246. mov ah, 1Ah
  247. int 21h
  248. ENDM
  249. ; Internal
  250. __LdDub MACRO dub
  251. IF TYPE (dub) EQ 2
  252. sub cx, cx
  253. mov dx, dub
  254. ELSEIF TYPE (dub) EQ 4
  255. mov cx, dub[2]
  256. mov dx, dub[0]
  257. ELSEIF TYPE (dub) EQ 0
  258. sub cx, cx
  259. mov dx, dub
  260. ELSE
  261. .ERR
  262. %OUT Illegal argument
  263. ENDIF
  264. ENDM
  265. ; 42h
  266. @GetFilSz MACRO handle
  267. mov bx, handle
  268. sub cx, cx
  269. sub dx, dx
  270. mov ax, 4202h
  271. int 21h
  272. push dx
  273. push ax
  274. sub dx, dx
  275. mov ax, 4200h
  276. int 21h
  277. pop ax
  278. pop dx
  279. ENDM
  280. ; 42h
  281. @MovePtrAbs MACRO handle, distance
  282. IFNB <distance>
  283. __LdDub <distance>
  284. ENDIF
  285. mov bx, handle
  286. mov ax, 4200h
  287. int 21h
  288. ENDM
  289. ; 42h
  290. @MovePtrRel MACRO handle, distance
  291. IFNB <distance>
  292. __LdDub <distance>
  293. ENDIF
  294. mov bx, handle
  295. mov ax, 4201h
  296. int 21h
  297. ENDM
  298. ; 39h
  299. @MkDir MACRO path, segmnt
  300. __LdAdr dx, <path>
  301. IFNB <segmnt>
  302. __LdSeg ds, <segmnt>
  303. ENDIF
  304. mov ah, 39h
  305. int 21h
  306. ENDM
  307. ; 3Ah
  308. @RmDir MACRO path, segmnt
  309. __LdAdr dx, <path>
  310. IFNB <segmnt>
  311. __LdSeg ds, <segmnt>
  312. ENDIF
  313. mov ah, 3Ah
  314. int 21h
  315. ENDM
  316. ; 3Bh
  317. @ChDir MACRO path, segmnt
  318. __LdAdr dx, <path>
  319. IFNB <segmnt>
  320. __LdSeg ds, <segmnt>
  321. ENDIF
  322. mov ah, 3Bh
  323. int 21h
  324. ENDM
  325. ; 47h
  326. @GetDir MACRO buffer, drive, segmnt
  327. IFNB <drive>
  328. mov dl, drive
  329. ELSE
  330. sub dl, dl
  331. ENDIF
  332. __LdAdr si, <buffer>
  333. IFNB <segmnt>
  334. __LdSeg ds, <segmnt>
  335. ENDIF
  336. mov ah, 47h
  337. int 21h
  338. ENDM
  339. ; 19h
  340. @GetDrv MACRO
  341. mov ah, 19h
  342. int 21h
  343. ENDM
  344. ; 0Eh
  345. @SetDrv MACRO drive
  346. mov dl, drive
  347. mov ah, 0Eh
  348. int 21h
  349. ENDM
  350. ; 36h
  351. @ChkDrv MACRO drive
  352. IFNB <drive>
  353. mov dl, drive
  354. ELSE
  355. sub dl, dl
  356. ENDIF
  357. mov ah, 36h
  358. int 21h
  359. ENDM
  360. ; 4Ch
  361. @Exit MACRO return
  362. IFB <return>
  363. mov ah, 4Ch
  364. ELSE
  365. mov ax, 4C00h + (return AND 0FFh)
  366. ENDIF
  367. int 21h
  368. ENDM
  369. ; 4Bh
  370. @Exec MACRO path, parms, segpath, segparms, overlay
  371. __LdAdr dx, <path>
  372. __LdAdr bx, <parms>
  373. IFNB <segpath>
  374. __LdSeg ds, <segpath>
  375. ENDIF
  376. IFNB <segparms>
  377. __LdSeg es, <segparms>
  378. ENDIF
  379. IFB <overlay>
  380. mov ax, 4B00h
  381. ELSE
  382. mov ax, 4B03h
  383. ENDIF
  384. int 21h
  385. ENDM
  386. ; 4Dh
  387. @GetRet MACRO
  388. mov ah, 4Dh
  389. int 21h
  390. ENDM
  391. ; 31h
  392. @TSR MACRO paragraphs, return
  393. mov dx, paragraphs
  394. IFB <return>
  395. mov ah, 31h
  396. ELSE
  397. mov ax, 3100h + (return AND 0FFh)
  398. ENDIF
  399. int 21h
  400. ENDM
  401. ; 49h
  402. @FreeBlok MACRO segmnt
  403. IFNB <segmnt>
  404. __LdSeg es, <segmnt>
  405. ENDIF
  406. mov ah, 49h
  407. int 21h
  408. ENDM
  409. ; 48h
  410. @GetBlok MACRO graphs
  411. LOCAL tryit
  412. mov bx, graphs
  413. tryit: mov ah, 48h
  414. int 21h
  415. jc tryit
  416. ENDM
  417. ; 4Ah
  418. @ModBlok MACRO graphs, segmnt
  419. IFNB <segmnt>
  420. __LdSeg es, <segmnt>
  421. ENDIF
  422. mov bx, graphs
  423. mov ah, 4Ah
  424. int 21h
  425. ENDM
  426. ; 2Ah
  427. @GetDate MACRO
  428. mov ah, 2Ah
  429. int 21h
  430. ENDM
  431. ; 2Bh
  432. @SetDate MACRO month, day, year
  433. mov cx, year
  434. mov dh, month
  435. mov dl, day
  436. mov ah, 2Bh
  437. int 21h
  438. ENDM
  439. ; 2Ch
  440. @GetTime MACRO
  441. mov ah, 2Ch
  442. int 21h
  443. ENDM
  444. ; 2Dh
  445. @SetTime MACRO hour, minutes, seconds, hundredths
  446. mov ch, hour
  447. mov cl, minutes
  448. mov dh, seconds
  449. mov dl, hundredths
  450. mov ah, 2Dh
  451. int 21h
  452. ENDM
  453. ; 30h
  454. @GetVer MACRO
  455. mov ah, 30h
  456. int 21h
  457. ENDM
  458. ; 35h
  459. @GetInt MACRO interrupt
  460. mov ax, 3500h + (interrupt AND 0FFh)
  461. int 21h
  462. ENDM
  463. ; 25h
  464. @SetInt MACRO interrupt, vector, segmnt
  465. IF TYPE (vector) GE 0FFFEh
  466. mov dx, OFFSET vector
  467. mov ax, SEG vector
  468. mov ds, ax
  469. ELSE
  470. __LdAdr dx, <vector>
  471. IFNB <segmnt>
  472. __LdSeg ds, <segmnt>
  473. ENDIF
  474. ENDIF
  475. mov ax, 2500h + (interrupt AND 0FFh)
  476. int 21h
  477. ENDM
  478. ENDIF ; Pass 1
  479. .CREF
  480. .LIST