home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l231 / 3.ddi / INCLUDE / DOS.IN$ / DOS
Encoding:
Text File  |  1992-09-28  |  30.1 KB  |  1,130 lines

  1. ; DOS Interface Macros - Version 1.2 - for Microsoft Macro Assembler 6.1
  2. ; (C) Copyright Microsoft Corporation, 1987, 1988, 1989, 1990
  3.  
  4. ; Typedefs for testing pointers
  5. NPVOID  TYPEDEF NEAR PTR
  6. FPVOID  TYPEDEF FAR  PTR
  7.  
  8. ; Internal
  9. __LdAdr MACRO reg:REQ, adr:REQ
  10.     IF (OPATTR (adr)) AND 00010000y
  11.         mov     reg, adr               ;; Register
  12.     ELSEIF (OPATTR (adr)) AND 00000100y
  13.         mov     reg, adr               ;; Constant
  14.     ELSEIF (TYPE (adr) EQ BYTE)  OR (TYPE (adr) EQ SBYTE)
  15.         mov    reg, OFFSET adr         ;; Bytes
  16.     ELSEIF (TYPE (adr) EQ NPVOID) OR (TYPE (adr) EQ WORD)
  17.         mov    reg, adr                ;; Near pointer
  18.     ELSEIF (TYPE (adr) EQ FPVOID) OR (TYPE (adr) EQ DWORD)
  19.         mov    reg, WORD PTR adr[0]    ;; Far pointer
  20.         mov    ds,  WORD PTR adr[2]
  21.     ELSE
  22.         .ERR <Illegal argument>
  23.     ENDIF
  24. ENDM
  25.  
  26.  
  27. ; Internal
  28. __LdSeg MACRO dest:REQ, src:REQ
  29.     IFIDNI <src>, <es>                 ;; Segment register
  30.         mov     ax, src
  31.         mov     dest, ax
  32.     ELSEIFIDNI <src>, <ss>
  33.         mov     ax, src
  34.         mov     dest, ax
  35.     ELSEIFIDNI <src>, <ds>
  36.         mov     ax, src
  37.         mov     dest, ax
  38.     ELSEIFIDNI <src>, <cs>
  39.         mov     ax, src
  40.         mov     dest, ax
  41.     ELSEIF (OPATTR (src)) AND 00000100y ;; Constant
  42.         mov     ax, src
  43.         mov     dest, ax
  44.     ELSE                                ;; Memory or general register
  45.         mov     dest, src
  46.     ENDIF
  47. ENDM
  48.  
  49. ; Internal
  50. __LdDub MACRO dub:REQ
  51.     IF ((OPATTR (dub)) AND 00000100y)
  52.         IF ((dub) LE 0FFFFh)
  53.              sub  cx, cx
  54.              mov  dx, dub
  55.         ELSE
  56.              sub  cx, HIGWORD dub
  57.              mov  dx, LOWWORD dub
  58.         ENDIF
  59.     ELSEIF   TYPE (dub) EQ 2
  60.         sub  cx, cx
  61.         mov  dx, dub
  62.     ELSEIF TYPE (dub) EQ 4
  63.         mov  cx, dub[2]
  64.         mov  dx, dub[0]
  65.     ELSEIF TYPE (dub) EQ 0
  66.         sub     cx, cx
  67.         mov     dx, dub
  68.     ELSE
  69.         .ERR
  70.         ECHO Illegal argument
  71.     ENDIF
  72. ENDM
  73.  
  74. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  75. ;
  76. ;  Syntax:    @GetChar [echo] [,[break] [,clearbuf]]
  77. ;
  78. ;  Summary:   Gets a keystroke from the keyboard
  79. ;
  80. ;  Arguments: <echo>         Nonzero to echo keystroke; default yes.
  81. ;                 Must be a constant.
  82. ;
  83. ;          <break>         Nonzero to accept CTRL+C; default yes. Must
  84. ;                 be a constant.
  85. ;
  86. ;          <clearbuf>     Nonzero to clear keyboard buffer; default
  87. ;                 no. Must be a constant.
  88. ;
  89. ;          NOTE: Arguments can be omitted to get defaults.
  90. ;
  91. ;  Returns:   ASCII code of key in AL
  92. ;
  93. ;  Modifies:  AX, else DL used if echo on and CTRL+C off
  94. ;
  95. ;  Uses:      Interrupt 21h Function 01h, 07h, 08h, 0Ch
  96. ;
  97. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  98. @GetChar MACRO ech:=<1>, cc:=<1>, clear:=<0>
  99.     LOCAL   funct, disp
  100.     disp    = 1
  101.     IF  ech
  102.         IF  cc
  103.             funct   = 01h       ;; Echo with break checking
  104.         ELSE
  105.             funct   = 07h       ;; Echo without break checking
  106.             disp    = 02h       ;; Need separate call to echo
  107.         ENDIF
  108.     ELSE
  109.         IF  cc
  110.             funct   = 08h       ;; No echo with break checking
  111.         ELSE
  112.             funct   = 07h       ;; No echo without break checking
  113.         ENDIF
  114.     ENDIF
  115.     IFE clear
  116.         mov     ah, funct       ;; Load function directly
  117.     ELSE
  118.         mov     ah, 0Ch         ;; If clear set, call function
  119.         mov     al, funct       ;;  indirectly with function 0Ch
  120.     ENDIF
  121.     int     21h                 ;; Call DOS
  122.     IF disp EQ 02h              ;; Separate call for echo without
  123.         mov     dl, al          ;;  break checking
  124.         mov     ah, disp
  125.         int     21h
  126.     ENDIF
  127. ENDM
  128.  
  129. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  130. ;
  131. ;  Syntax:    @GetStr buffer [,[terminator] [,[limit] [,segment]]]
  132. ;
  133. ;  Summary:   Gets a string from the keyboard
  134. ;
  135. ;  Arguments: <buffer>           Offset of buffer for string. Must be an
  136. ;                   offset address.
  137. ;
  138. ;                   Byte 1     Maximum length of string before
  139. ;                     call.
  140. ;                   Byte 2     Actual length of string after
  141. ;                     call.
  142. ;                   Byte 3+     Bytes of string.
  143. ;
  144. ;          <terminator>     Terminating byte: null (0) or $ (24h).
  145. ;                   May be a constant or register, but not memory.
  146. ;
  147. ;          <limit>           Maximum length of string. Must be a
  148. ;                   constant. If not given as an argument,
  149. ;                   must be in buffer before call.
  150. ;
  151. ;          <segment>        Segment of buffer; DS if not given.
  152. ;
  153. ;  Returns:   Pointer to string in SI, length of string in BX
  154. ;
  155. ;  Modifies:  AX, DX, BX, SI
  156. ;
  157. ;  Uses:      Interrupt 21h Function 0Ah
  158. ;
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. @GetStr MACRO ofset:REQ, terminator, limit, segmnt
  161.     __LdAdr dx, <ofset>
  162.     IFNB    <segmnt>
  163.         __LdSeg ds, <segmnt>
  164.     ENDIF
  165.     mov     ah, 0Ah
  166.     mov     si, dx
  167.     IFNB    <limit>
  168.         mov     BYTE PTR [si], limit
  169.     ENDIF
  170.     int     21h
  171.     inc     si
  172.     mov     bl, [si]
  173.     sub     bh, bh
  174.     inc     si
  175.     IFNB    <terminator>
  176.         mov     BYTE PTR [bx+si], terminator
  177.     ENDIF
  178. ENDM
  179.  
  180. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  181. ;
  182. ;  Syntax:    @ShowChar char [,char]...
  183. ;
  184. ;  Summary:   Displays one or more characters to screen
  185. ;
  186. ;  Argument:  <char>     8-bit ASCII code
  187. ;
  188. ;  Returns:   No return value
  189. ;
  190. ;  Modifies:  AX, DL
  191. ;
  192. ;  Uses:      Interrupt 21h Function 02h
  193. ;
  194. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  195. @ShowChar MACRO chr:VARARG
  196.     mov     ah, 02h
  197.     FOR arg, <chr>
  198.         IFDIFI  <arg>, <dl>
  199.             mov     dl, arg
  200.         ENDIF
  201.         int     21h
  202.     ENDM
  203. ENDM
  204.  
  205. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  206. ;
  207. ;  Syntax:    @PrtChar char [,char]...
  208. ;
  209. ;  Summary:   Prints one or more characters to LPT1
  210. ;
  211. ;  Argument:  <char>     8-bit ASCII code
  212. ;
  213. ;  Returns:   No return value
  214. ;
  215. ;  Modifies:  AX, DL
  216. ;
  217. ;  Uses:      Interrupt 21h Function 05h
  218. ;
  219. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  220. @PrtChar MACRO chr:VARARG
  221.     mov     ah, 05h
  222.     FOR arg, <chr>
  223.         IFDIFI  <arg>, <dl>
  224.             mov     dl, arg
  225.         ENDIF
  226.         int     21h
  227.     ENDM
  228. ENDM
  229.  
  230. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  231. ;
  232. ;  Syntax:    @ShowStr address [,segment]
  233. ;
  234. ;  Summary:   Displays a $-terminated string
  235. ;
  236. ;  Arguments: <address>     Address of string terminated by "$" (24h).
  237. ;                Must be an offset address.
  238. ;
  239. ;          <segment>     Segment of address string; DS if not given.
  240. ;
  241. ;  Returns:   No return value
  242. ;
  243. ;  Modifies:  AX, DX; DS if segment changed
  244. ;
  245. ;  Uses:      Interrupt 21h Function 09h
  246. ;
  247. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  248. @ShowStr MACRO ofset:REQ, segmnt
  249.     LOCAL  msg, sseg
  250.     IF @InStr( 1, ofset, <!"> ) EQ 1
  251.         sseg    TEXTEQU @CurSeg
  252.         .DATA
  253.         msg     BYTE    ofset, "$"
  254.     @CurSeg ENDS
  255.         sseg    SEGMENT
  256.         mov     dx, OFFSET msg
  257.     ELSE
  258.         __LdAdr dx, ofset
  259.         IFNB    <segmnt>
  260.             __LdSeg ds, <segmnt>
  261.         ENDIF
  262.     ENDIF
  263.     mov     ah, 9
  264.     int     21h
  265. ENDM
  266.  
  267. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  268. ;
  269. ;  Syntax:    @Read buffer, length [,[handle] [,segment]]
  270. ;
  271. ;  Summary:   Reads data from a file or device
  272. ;
  273. ;  Arguments: <buffer>        Offset of buffer where data will be stored.
  274. ;                Must be an offset address.
  275. ;
  276. ;          <length>        Length of data in bytes.
  277. ;
  278. ;          <handle>        File or device handle; if none given,
  279. ;                keyboard (handle 0) is assumed.
  280. ;
  281. ;          <segment>     Segment of address string; DS if not given.
  282. ;
  283. ;  Returns:   If carry: clear, bytes read in AX
  284. ;
  285. ;  Modifies:  AX, DX, BX, CX; DS if segment changed
  286. ;
  287. ;  Uses:      Interrupt 21h Function 3Fh
  288. ;
  289. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  290. @Read MACRO ofset:REQ, bytes:REQ, handle:=<0>, segmnt
  291.     IFDIF   <handle>, <0>
  292.         mov     bx, handle
  293.     ELSE
  294.         sub     bx, bx
  295.     ENDIF
  296.     mov     cx, bytes
  297.     __LdAdr dx, <ofset>
  298.     IFNB    <segmnt>
  299.         __LdSeg ds, <segmnt>
  300.     ENDIF
  301.     mov     ah, 3Fh
  302.     int     21h
  303. ENDM
  304.  
  305. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  306. ;
  307. ;  Syntax:    @Write buffer, length [,[handle] [,segment]]
  308. ;
  309. ;  Summary:   Writes data to a file or device
  310. ;
  311. ;  Arguments: <buffer>        Offset of buffer where data is stored. Must
  312. ;                be an offset address.
  313. ;
  314. ;          <length>        Length of data in bytes.
  315. ;
  316. ;          <handle>        File or device handle; if none given, screen
  317. ;                (handle 1) is assumed.
  318. ;
  319. ;          <segment>     Segment of address string; DS if not given.
  320. ;
  321. ;  Returns:   If carry: clear, bytes written in AX
  322. ;
  323. ;  Modifies:  AX, DX, BX, CX; DS if segment changed
  324. ;
  325. ;  Uses:      Interrupt 21h Function 40h
  326. ;
  327. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  328. @Write MACRO ofset:REQ, bytes:REQ, handle:=<1>, segmnt
  329.     mov     bx, handle
  330.     mov     cx, bytes
  331.     __LdAdr dx, <ofset>
  332.     IFNB    <segmnt>
  333.         __LdSeg ds, <segmnt>
  334.     ENDIF
  335.     mov     ah, 40h
  336.     int     21h
  337. ENDM
  338.  
  339. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  340. ;
  341. ;  Syntax:    @MakeFile path [,[attrib] [,[segment] [,kind]]]
  342. ;
  343. ;  Summary:   Creates a file
  344. ;
  345. ;  Arguments: <path>        ASCIIZ string of file. Must be an offset
  346. ;                address.
  347. ;
  348. ;          <attrib>        File attribute; 0 is default if none given.
  349. ;
  350. ;          <segment>     Segment of address string; DS if not given.
  351. ;
  352. ;          <kind>        If none given, a file is created even if one
  353. ;                already exists. Under DOS 3.x, "tmp" can be
  354. ;                given to create a unique file or "new" to
  355. ;                create a file only if one doesn't already
  356. ;                exist.
  357. ;
  358. ;  Returns:   If carry: clear, file handle in AX
  359. ;
  360. ;  Modifies:  AX, DX, CX; DS if segment changed
  361. ;
  362. ;  Uses:      Interrupt 21h Function 3Ch, 5Ah, 5Bh
  363. ;
  364. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  365. @MakeFile MACRO path:REQ, atrib:=<0>, segmnt, kind
  366.     IFDIF   <atrib>, <0>
  367.         mov     cx, atrib
  368.     ELSE
  369.         sub     cx, cx
  370.     ENDIF
  371.     __LdAdr dx, <path>
  372.     IFNB    <segmnt>
  373.         __LdSeg ds, <segmnt>
  374.     ENDIF
  375.     IFIDNI  <kind>, <tmp>
  376.         mov     ah, 5Ah
  377.     ELSEIFIDNI <kind>, <new>
  378.         mov    ah, 5Bh
  379.     ELSE
  380.         mov    ah, 3Ch
  381.     ENDIF
  382.     int     21h
  383. ENDM
  384.  
  385. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  386. ;
  387. ;  Syntax:    @OpenFile path, access [,segment]
  388. ;
  389. ;  Summary:   Opens a file for input or output
  390. ;
  391. ;  Arguments: <path>        ASCIIZ string of file. Must be an offset
  392. ;                address.
  393. ;
  394. ;          <access>        File access code. Must be a constant. The
  395. ;                default value is 0 (normal read/write file).
  396. ;
  397. ;          <segment>     Segment of address string; DS if not given.
  398. ;
  399. ;  Returns:   If carry: set, error code in AX
  400. ;
  401. ;  Modifies:  AX, DX; DS if segment changed
  402. ;
  403. ;  Uses:      Interrupt 21h Function 3Dh
  404. ;
  405. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  406. @OpenFile MACRO path:REQ, access:=<0>, segmnt
  407.     __LdAdr dx, <path>
  408.     IFNB    <segmnt>
  409.         __LdSeg ds, <segmnt>
  410.     ENDIF
  411.     mov     ax, 3D00h + (access AND 0FFh)
  412.     int     21h
  413. ENDM
  414.  
  415. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  416. ;
  417. ;  Syntax:    @CloseFile handle
  418. ;
  419. ;  Summary:   Closes an open file handle
  420. ;
  421. ;  Argument:  <handle>       Previously opened file handle
  422. ;
  423. ;  Returns:   If carry: set, error code in AX
  424. ;
  425. ;  Modifies:  AX, BX
  426. ;
  427. ;  Uses:      Interrupt 21h Function 3Eh
  428. ;
  429. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  430. @CloseFile MACRO handle:REQ
  431.     mov     bx, handle
  432.     mov     ah, 3Eh
  433.     int     21h
  434. ENDM
  435.  
  436. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  437. ;
  438. ;  Syntax:    @DelFile path [,segment]
  439. ;
  440. ;  Summary:   Deletes a specified file
  441. ;
  442. ;  Arguments: <path>        Offset of ASCIIZ file specification. Must
  443. ;                be an offset address.
  444. ;
  445. ;          <segment>     Segment of path; DS if none given.
  446. ;
  447. ;  Returns:   If carry: set, error code in AX
  448. ;
  449. ;  Modifies:  AX, DX; DS if segment changed
  450. ;
  451. ;  Uses:      Interrupt 21h Function 41h
  452. ;
  453. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  454. @DelFile MACRO path:REQ, segmnt
  455.     __LdAdr dx, <path>
  456.     IFNB    <segmnt>
  457.         __LdSeg ds, <segmnt>
  458.     ENDIF
  459.     mov     ah, 41h
  460.     int     21h
  461. ENDM
  462.  
  463. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  464. ;
  465. ;  Syntax:    @MoveFile old, new [,[segold] [,segnew]]
  466. ;
  467. ;  Summary:   Moves or renames a file by changing its path specification
  468. ;
  469. ;  Arguments: <old>       Offset of file specification to be renamed.
  470. ;               Must be an offset address.
  471. ;
  472. ;          <new>       Offset of new file specification. Must be an
  473. ;               offset address.
  474. ;
  475. ;          <segold>       Segment of old name; DS if none given.
  476. ;
  477. ;          <segnew>       Segment of new name; ES if none given.
  478. ;
  479. ;  Returns:   If carry: set, error code in AX
  480. ;
  481. ;  Modifies:  AX, DX, DI; DS, ES if corresponding segments changed
  482. ;
  483. ;  Uses:      Interrupt 21h Function 56h
  484. ;
  485. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  486. @MoveFile MACRO old:REQ, new:REQ, segold, segnew
  487.     __LdAdr dx, <old>
  488.     __LdAdr di, <new>
  489.     IFNB    <segold>
  490.         __LdSeg ds, <segold>
  491.     ENDIF
  492.     IFNB    <segnew>
  493.         __LdSeg es, <segnew>
  494.     ENDIF
  495.     mov     ah, 56h
  496.     int     21h
  497. ENDM
  498.  
  499.  
  500. ;* File information returned from GetFirst procedure
  501. FILE_INFO       STRUCT
  502.   pad           BYTE    21 DUP (?)      ; pad to 43 bytes
  503.   Attrib        BYTE    ?               ; file attribute
  504.   Time          WORD    ?               ; file time
  505.   Date          WORD    ?               ; file date
  506.   Len           DWORD   ?               ; file size
  507.   FName         BYTE    13 DUP (?)      ; file name
  508. FILE_INFO       ENDS
  509.  
  510. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  511. ;
  512. ;  Syntax:    @GetFirst path [,[attribute] [,segment]]
  513. ;          @GetNext
  514. ;
  515. ;  Summary:   Converts file specifications (optionally including wild
  516. ;          cards) into filenames. These macros are usually used with
  517. ;          @GetDTA and @SetDTA. Use @SetDTA to set the address where
  518. ;          the data for each file will be stored.
  519. ;
  520. ;  Arguments: <path>          Offset address of fully specified ASCIIZ
  521. ;                  file name; can have wild cards. Must be an
  522. ;                  offset address.
  523. ;
  524. ;          <attribute>     File attribute to search for; 0 for normal
  525. ;                  if none given.
  526. ;
  527. ;          <segment>       Segment of path; uses DS if none given.
  528. ;
  529. ;  Returns:   If carry: set, error code in AX
  530. ;
  531. ;  Modifies:  For @GetFirst, AX, CX, DX; DS if segment changed;
  532. ;          for @GetNext, AX only
  533. ;
  534. ;  Uses:      Interrupt 21h Function 4Eh
  535. ;
  536. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  537. @GetFirst MACRO path:REQ, atrib, segmnt
  538.     IFNB    <atrib>
  539.         mov     cx, atrib
  540.     ELSE
  541.         sub     cx, cx
  542.     ENDIF
  543.     __LdAdr dx, <path>
  544.     IFNB    <segmnt>
  545.         __LdSeg ds, <segmnt>
  546.     ENDIF
  547.     mov     ah, 4Eh
  548.     int     21h
  549. ENDM
  550.  
  551.  
  552. ; 4Fh
  553. @GetNext MACRO
  554.     mov     ah, 4Fh
  555.     int     21h
  556. ENDM
  557.  
  558. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  559. ;
  560. ;  Syntax:    @GetDTA
  561. ;
  562. ;          @SetDTA buffer [,segment]
  563. ;
  564. ;  Summary:   Gets or sets the Disk Transfer Address (DTA). These
  565. ;          macros are usually used to set the address for file
  566. ;          information data used by @GetFirst and @GetNext.
  567. ;
  568. ;  Arguments: <buffer>        Offset of new DTA buffer. Must be an offset
  569. ;                address.
  570. ;
  571. ;          <segment>     Segment of new DTA buffer; DS if none given.
  572. ;
  573. ;  Returns:   @GetDTA: ES:BX points to DTA
  574. ;          @SetDTA: No return value
  575. ;
  576. ;  Modifies:  AX for both; ES, BX for @GetDTA; DS, DX for @SetDTA
  577. ;
  578. ;  Uses:      Interrupt 21h Function 2Fh
  579. ;
  580. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  581. @GetDTA MACRO
  582.     mov     ah, 2Fh
  583.     int     21h
  584. ENDM
  585.  
  586. ; 1Ah
  587. @SetDTA MACRO buffer:REQ, segmnt
  588.     __LdAdr dx, <buffer>
  589.     IFNB    <segmnt>
  590.         __LdSeg ds, <segmnt>
  591.     ENDIF
  592.     mov     ah, 1Ah
  593.     int     21h
  594. ENDM
  595.  
  596. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  597. ;
  598. ;  Syntax:    @GetFileSize handle
  599. ;
  600. ;  Summary:   Gets the file size by moving the file pointer to
  601. ;          end-of-file
  602. ;
  603. ;          NOTE: The file pointer is reset to zero. Thus this
  604. ;            macro should not be called during operations that move
  605. ;            the pointer.
  606. ;
  607. ;  Argument:  <handle>       Previously opened file handle.
  608. ;
  609. ;  Returns:   If carry: clear, file length in DX:AX
  610. ;
  611. ;  Modifies:  AX, BX, CX, DX
  612. ;
  613. ;  Uses:      Interrupt 21h Function 42h
  614. ;
  615. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  616. @GetFileSize MACRO handle:REQ
  617.     mov     bx, handle
  618.     sub     cx, cx
  619.     sub     dx, dx
  620.     mov     ax, 4202h
  621.     int     21h
  622.     push    dx
  623.     push    ax
  624.     sub     dx, dx
  625.     mov     ax, 4200h
  626.     int     21h
  627.     pop     ax
  628.     pop     dx
  629. ENDM
  630.  
  631. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  632. ;
  633. ;  Syntax:    @MovePtrAbs handle [,distance]
  634. ;
  635. ;          @MovePtrRel handle [,distance]
  636. ;
  637. ;  Summary:   Moves the file pointer in an open file. The pointer can be
  638. ;          moved to an absolute position, or relative to its current
  639. ;          position.
  640. ;
  641. ;  Arguments: <handle>         Previously opened file handle.
  642. ;
  643. ;          <distance>     Distance to move pointer (16-bit) constant
  644. ;                 or a 16- or 32-bit variable; or leave
  645. ;                 blank and set distance in CX:DX before
  646. ;                 macro call.
  647. ;
  648. ;  Returns:   If carry: clear, file pointer position in DX:AX
  649. ;
  650. ;  Modifies:  AX, BX, CX, DX
  651. ;
  652. ;  Uses:      Interrupt 21h Function 42h
  653. ;
  654. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  655. @MovePtrAbs MACRO handle:REQ, distance
  656.     IFNB    <distance>
  657.         __LdDub <distance>
  658.     ENDIF
  659.     mov     bx, handle
  660.     mov     ax, 4200h
  661.     int     21h
  662. ENDM
  663.  
  664. ; 42h
  665. @MovePtrRel MACRO handle:REQ, distance
  666.     IFNB    <distance>
  667.         __LdDub <distance>
  668.     ENDIF
  669.     mov     bx, handle
  670.     mov     ax, 4201h
  671.     int     21h
  672. ENDM
  673.  
  674. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  675. ;
  676. ;  Syntax:    @MkDir path [,segment]
  677. ;
  678. ;          @RmDir path [,segment]
  679. ;
  680. ;          @ChDir path [,segment]
  681. ;
  682. ;  Summary:   Creates, deletes, or changes to the specified directory
  683. ;
  684. ;  Arguments: <path>        Offset of ASCIIZ string containing
  685. ;                directory. Must be offset address.
  686. ;
  687. ;          <segment>     Segment of path; DS if none given.
  688. ;
  689. ;  Returns:   If carry: set, error code in AX
  690. ;
  691. ;  Modifies:  AX, DX; DS if segment changed
  692. ;
  693. ;  Uses:      Interrupt 21h Function 39h
  694. ;
  695. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  696. @MkDir MACRO path:REQ, segmnt
  697.     __LdAdr dx, <path>
  698.     IFNB    <segmnt>
  699.         __LdSeg ds, <segmnt>
  700.     ENDIF
  701.     mov     ah, 39h
  702.     int     21h
  703. ENDM
  704.  
  705. ; 3Ah
  706. @RmDir MACRO path:REQ, segmnt
  707.     __LdAdr dx, <path>
  708.     IFNB    <segmnt>
  709.         __LdSeg ds, <segmnt>
  710.     ENDIF
  711.     mov     ah, 3Ah
  712.     int     21h
  713. ENDM
  714.  
  715. ; 3Bh
  716. @ChDir MACRO path:REQ, segmnt
  717.     __LdAdr dx, <path>
  718.     IFNB    <segmnt>
  719.         __LdSeg ds, <segmnt>
  720.     ENDIF
  721.     mov     ah, 3Bh
  722.     int     21h
  723. ENDM
  724.  
  725. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  726. ;
  727. ;  Syntax:    @GetDir buffer [,[drive] [,segment]]
  728. ;
  729. ;  Summary:   Returns the current directory of the specified drive
  730. ;
  731. ;  Arguments: <buffer>        Offset of buffer to receive ASCIIZ
  732. ;                directory. Must be an offset address.
  733. ;
  734. ;          <drive>        8-bit drive number (0 = current, 1 = A,
  735. ;                2 = B, ...; 0 if none given).
  736. ;
  737. ;          <segment>     Segment of path; DS if none given.
  738. ;
  739. ;  Returns:   If carry: set, error code in AX
  740. ;
  741. ;  Modifies:  AX, SI, DL; DS if segment changes
  742. ;
  743. ;  Uses:      Interrupt 21h Function 47h
  744. ;
  745. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  746. @GetDir MACRO buffer:REQ, drive, segmnt
  747.     IFNB    <drive>
  748.         mov     dl, drive
  749.     ELSE
  750.         sub     dl, dl
  751.     ENDIF
  752.     __LdAdr si, <buffer>
  753.     IFNB    <segmnt>
  754.         __LdSeg ds, <segmnt>
  755.     ENDIF
  756.     mov     ah, 47h
  757.     int     21h
  758. ENDM
  759.  
  760. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  761. ;
  762. ;  Syntax:    @GetDrv
  763. ;
  764. ;          @SetDrv drive
  765. ;
  766. ;  Summary:   Gets or sets the current drive
  767. ;
  768. ;  Argument:  <drive>      8-bit drive number (0 = A, 1 = B, ...)
  769. ;
  770. ;  Returns:   For @GetDrv, drive number in AL (0 = A, 1 = B, ...);
  771. ;          for @SetDrv, number of drives in AL
  772. ;
  773. ;  Modifies:  AX for both; DL for @SetDrv
  774. ;
  775. ;  Uses:      Interrupt 21h Function 19h
  776. ;
  777. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  778. @GetDrv MACRO
  779.     mov     ah, 19h
  780.     int     21h
  781. ENDM
  782.  
  783. ; 0Eh
  784. @SetDrv MACRO drive:REQ
  785.     mov     dl, drive
  786.     mov     ah, 0Eh
  787.     int     21h
  788. ENDM
  789.  
  790. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  791. ;
  792. ;  Syntax:    @ChkDrv [drive]
  793. ;
  794. ;  Summary:   Gets various data about a disk
  795. ;
  796. ;  Argument:  <drive>      8-bit drive number (0 = current, A = 1,
  797. ;              B = 2, ...); if none given, current assumed
  798. ;
  799. ;  Returns:   AX     Sectors per cluster; -1 if drive invalid
  800. ;          BX     Available clusters
  801. ;          CX     Bytes per sector
  802. ;          DX     Clusters per drive
  803. ;
  804. ;  Modifies:  AX, BX, CX, DX
  805. ;
  806. ;  Uses:      Interrupt 21h Function 1Ch
  807. ;
  808. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  809. @ChkDrv MACRO drive
  810.     IFNB    <drive>
  811.         mov     dl, drive
  812.     ELSE
  813.         sub     dl, dl
  814.     ENDIF
  815.     mov     ah, 1Ch
  816.     int     21h
  817. ENDM
  818.  
  819. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  820. ;
  821. ;  Syntax:    @Exit [return]
  822. ;
  823. ;  Summary:   Exits to DOS with return code
  824. ;
  825. ;  Argument:  <return>       8-bit code to return to DOS; if none given,
  826. ;               AL is used. If given, must be a constant.
  827. ;
  828. ;  Returns:   No return value
  829. ;
  830. ;  Modifies:  AX
  831. ;
  832. ;  Uses:      Interrupt 21h Function 4Ch
  833. ;
  834. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  835. @Exit MACRO return
  836.     IFB     <return>
  837.         mov     ah, 4Ch
  838.     ELSE
  839.         mov     ax, 4C00h + (return AND 0FFh)
  840.     ENDIF
  841.     int     21h
  842. ENDM
  843.  
  844. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  845. ;
  846. ;  Syntax:    @TSR paragraphs [,return]
  847. ;
  848. ;  Summary:   Terminates a program, but leaves it resident in memory
  849. ;
  850. ;  Arguments: <paragraphs>     Memory in paragraphs (16 bytes) to
  851. ;                   allocate for resident program.
  852. ;          <return>           Code to return to DOS; if none, AL used.
  853. ;                   Must be a constant.
  854. ;
  855. ;  Returns:   No return value
  856. ;
  857. ;  Modifies:  AX, DX
  858. ;
  859. ;  Uses:      Interrupt 21h Function 31h
  860. ;
  861. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  862. @TSR MACRO paragraphs:REQ, return
  863.     mov     dx, paragraphs
  864.     IFB     <return>
  865.         mov     ah, 31h
  866.     ELSE
  867.         mov     ax, 3100h + (return AND 0FFh)
  868.     ENDIF
  869.     int     21h
  870. ENDM
  871.  
  872. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  873. ;
  874. ;  Syntax:    @FreeBlock [segment]
  875. ;
  876. ;  Summary:   Frees a block of memory
  877. ;
  878. ;  Argument:  <segment>     Starting address of memory to be freed; if
  879. ;                none given, ES address assumed
  880. ;
  881. ;  Returns:   If carry: set, error code in AX
  882. ;
  883. ;  Modifies:  AX; ES if segment given
  884. ;
  885. ;  Uses:      Interrupt 21h Function 49h
  886. ;
  887. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  888. @FreeBlock MACRO segmnt
  889.     IFNB    <segmnt>
  890.         __LdSeg es, <segmnt>
  891.     ENDIF
  892.     mov     ah, 49h
  893.     int     21h
  894. ENDM
  895.  
  896. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  897. ;
  898. ;  Syntax:    @GetBlock paragraphs [, retry]
  899. ;
  900. ;  Summary:   Allocates a block of memory
  901. ;
  902. ;  Argument:  <paragraphs>     Paragraphs (16 bytes) of memory wanted
  903. ;          <retry>           If nonzero, allocate largest block
  904. ;                   available
  905. ;
  906. ;  Returns:   AX     If carry: clear, the segment of the allocated
  907. ;             memory. If carry: set, an error code
  908. ;          BX     Paragraphs actually allocated. If <retry> is not
  909. ;             zero, it may be less than requested.
  910. ;
  911. ;  Modifies:  AX, BX
  912. ;
  913. ;  Uses:      Interrupt 21h Function 48h
  914. ;
  915. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  916. @GetBlock MACRO graphs:REQ, retry:=<0>
  917.     LOCAL   tryit
  918.     mov     bx, graphs
  919.     tryit:  mov     ah, 48h
  920.     int     21h
  921.  
  922.     IF        retry
  923.     jc  tryit
  924.     ENDIF
  925. ENDM
  926.  
  927. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  928. ;
  929. ;  Syntax:    @ModBlock paragraphs [,segment]
  930. ;
  931. ;  Summary:   Modifies an allocated block of memory
  932. ;
  933. ;  Arguments: <paragraphs>     Paragraphs (16 bytes) of memory wanted.
  934. ;
  935. ;          <segment>        Starting address of memory to be freed; if
  936. ;                   none given, ES address assumed.
  937. ;
  938. ;  Returns:   If carry is set, the error code is returned in AX;
  939. ;        otherwise, the ES register contains the segment address of
  940. ;        allocated memory. If carry is clear, the BX register contains
  941. ;        the number of paragraphs allocated.
  942. ;
  943. ;  Modifies:  AX, BX; ES if segment given
  944. ;
  945. ;  Uses:      Interrupt 21h Function 4Ah
  946. ;
  947. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  948. @ModBlock MACRO graphs:REQ, segmnt
  949.     IFNB    <segmnt>
  950.         __LdSeg es, <segmnt>
  951.     ENDIF
  952.     mov     bx, graphs
  953.     mov     ah, 4Ah
  954.     int     21h
  955. ENDM
  956.  
  957. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  958. ;
  959. ;  Syntax:    @GetDate
  960. ;
  961. ;  Summary:   Gets the system date
  962. ;
  963. ;  Arguments: None
  964. ;
  965. ;  Returns:   AL     Day of week (0 = Sunday, 1 = Monday, ...)
  966. ;          CX     Year (1980-2099)
  967. ;          DH     Month (1-12)
  968. ;          DL     Day (1-31)
  969. ;
  970. ;  Modifies:  AX, CX, DX
  971. ;
  972. ;  Uses:      Interrupt 21h Function 2Ah
  973. ;
  974. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  975. @GetDate MACRO
  976.     mov     ah, 2Ah
  977.     int     21h
  978. ENDM
  979.  
  980. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  981. ;
  982. ;  Syntax:    @SetDate month, day, year
  983. ;
  984. ;  Summary:   Sets the system date
  985. ;
  986. ;  Arguments: <month>      8-bit month (1-12)
  987. ;
  988. ;          <day>      8-bit day (1-31)
  989. ;
  990. ;          <year>      16-bit year (1980-2099)
  991. ;
  992. ;  Returns:   AL     If date was valid 0, else -1
  993. ;
  994. ;  Modifies:  AX, CX, DX
  995. ;
  996. ;  Uses:      Interrupt 21h Function 2Bh
  997. ;
  998. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  999. @SetDate MACRO month:REQ, day:REQ, year:REQ
  1000.     mov     cx, year
  1001.     mov     dh, month
  1002.     mov     dl, day
  1003.     mov     ah, 2Bh
  1004.     int     21h
  1005. ENDM
  1006.  
  1007. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1008. ;
  1009. ;  Syntax:    @GetTime
  1010. ;
  1011. ;  Summary:   Gets the system time
  1012. ;
  1013. ;  Arguments: None
  1014. ;
  1015. ;  Returns:   CH     Hour (0-23)
  1016. ;          CL     Minute (0-59)
  1017. ;          DH     Second (0-59)
  1018. ;          DL     Hundredth (0-99)
  1019. ;
  1020. ;  Modifies:  AX, CX, DX
  1021. ;
  1022. ;  Uses:      Interrupt 21h Function 2Ch
  1023. ;
  1024. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1025. @GetTime MACRO
  1026.     mov     ah, 2Ch
  1027.     int     21h
  1028. ENDM
  1029.  
  1030. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1031. ;
  1032. ;  Syntax:    @SetTime hour,minute,second,hundredth
  1033. ;
  1034. ;  Summary:   Sets the system time
  1035. ;
  1036. ;  Arguments: <hour>          8-bit hours (0-23)
  1037. ;
  1038. ;          <minute>          8-bit minutes (0-59)
  1039. ;
  1040. ;          <second>          8-bit seconds (0-59)
  1041. ;
  1042. ;          <hundredth>     8-bit hundredth of seconds (0-99)
  1043. ;
  1044. ;  Returns:   AL     If time was valid 0, else -1
  1045. ;
  1046. ;  Modifies:  AX, CX, DX
  1047. ;
  1048. ;  Uses:      Interrupt 21h Function 2Dh
  1049. ;
  1050. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1051. @SetTime MACRO hour:REQ, minutes:REQ, seconds:REQ, hundredths:REQ
  1052.     mov     ch, hour
  1053.     mov     cl, minutes
  1054.     mov     dh, seconds
  1055.     mov     dl, hundredths
  1056.     mov     ah, 2Dh
  1057.     int     21h
  1058. ENDM
  1059.  
  1060. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1061. ;
  1062. ;  Syntax:    @GetVer
  1063. ;
  1064. ;  Summary:   Gets the DOS version
  1065. ;
  1066. ;  Arguments: None
  1067. ;
  1068. ;  Returns:   AL    Major version (0 for versions prior to 2.0)
  1069. ;          AH    Minor version
  1070. ;          BH    OEM serial number
  1071. ;          BL:CX    24-bit user number
  1072. ;
  1073. ;  Modifies:  AX, BX, CX
  1074. ;
  1075. ;  Uses:      Interrupt 21h Function 30h
  1076. ;
  1077. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1078. @GetVer MACRO
  1079.     mov     ah, 30h
  1080.     int     21h
  1081. ENDM
  1082.  
  1083. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1084. ;
  1085. ;  Syntax:    @GetInt interrupt
  1086. ;
  1087. ;          @SetInt interrupt, vector [,segment]
  1088. ;
  1089. ;  Summary:   Gets or sets the vector for a specified interrupt
  1090. ;          routine
  1091. ;
  1092. ;  Arguments: <interrupt>     8-bit interrupt number. Must be a
  1093. ;                  constant.
  1094. ;
  1095. ;          <vector>          Offset of interrupt routine.
  1096. ;
  1097. ;          <segment>       Segment of routine; if none given, DS
  1098. ;                  assumed for data; segment ignored for
  1099. ;                  code labels.
  1100. ;
  1101. ;  Returns:   For @GetInt, ES:BX points to interrupt routine;
  1102. ;          for @SetInt, no return value
  1103. ;
  1104. ;  Modifies:  AX for both; ES and BX for @GetInt; DS and DX for
  1105. ;          @SetInt
  1106. ;
  1107. ;  Uses:      Interrupt 21h Function 35h
  1108. ;
  1109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1110. @GetInt MACRO    interrupt:REQ
  1111.     mov     ax, 3500h + (interrupt AND 0FFh)
  1112.     int     21h
  1113. ENDM
  1114.  
  1115. ; 25h
  1116. @SetInt MACRO interrupt:REQ, vector:REQ, segmnt
  1117.     IF  (TYPE (vector) EQ NPVOID) OR (TYPE (vector) EQ FPVOID)
  1118.         mov     dx, OFFSET vector
  1119.         mov     ax, SEG vector
  1120.         mov     ds, ax
  1121.     ELSE
  1122.         __LdAdr dx, <vector>
  1123.         IFNB    <segmnt>
  1124.             __LdSeg ds, <segmnt>
  1125.         ENDIF
  1126.     ENDIF
  1127.     mov     ax, 2500h + (interrupt AND 0FFh)
  1128.     int     21h
  1129. ENDM
  1130.