.XLIST ;; PCMac.inc--Macro INCLUDE file to be used with "Assembly Language ;; for the IBM PC Family" by William B. Jones, (c) Copyright 1992, ;; 1997, 2001, Scott/Jones, Inc. ;; This file has two versions of all the DOS call macros--one beginning '_' ;; which does not save or restore any registers, and one beginning 's' ;; that saves and restores all of the registers ax, bx, cx, and dx which ;; are used by the macro and not used to return a value. _Begin MACRO mov ax, @data mov ds, ax mov bx, ss sub bx, ax shl bx, 4 mov ss, ax add sp, bx ENDM ; The following code is necessary to get the .TYPE function to work properly ; in TASM 5. ??VERSION is a built-in variable defined ONLY in TASM IFDEF ??VERSION IF ??VERSION GE 500h OPTION DOTNAME ENDIF ENDIF _LdAddr MACRO reg, addr IF (.TYPE (addr)) AND 10000B ;; Register mov reg, addr ELSE IF (.TYPE (addr)) AND 100B ;; Constant mov reg, addr ELSE IF TYPE (addr) EQ 1 ;; Bytes lea reg, addr ELSE IF TYPE (addr) EQ 2 ;; Near pointer mov reg, addr ELSE IF TYPE (addr) EQ 4 ;; Far pointer lds reg, addr ELSE .ERR %OUT Illegal argument ENDIF ENDIF ENDIF ENDIF ENDIF ENDM _LdSeg MACRO reg, segm IFNB IFIDNI , ;; Segment register mov ax, segm mov reg, ax ELSE IFIDNI , mov ax, segm mov reg, ax ELSE IFIDNI , mov ax, segm mov reg, ax ELSE IFIDNI , mov ax, segm mov reg, ax ELSE mov ax, segm mov reg, ax ENDIF ENDIF ENDIF ENDIF ENDIF ENDM _SvRegs MACRO reglist IRP x, push x ENDM ENDM _RsRegs MACRO reglist IRP x, pop x ENDM ENDM _PutStr MACRO addr, segm _LdAddr dx, _LdSeg ds, ;; load segment second in case ax used in addr mov ah, 09h int 21h ENDM sPutStr MACRO addr, segm _SvRegs _PutStr , _RsRegs ENDM _PutCh MACRO c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 mov ah, 02h IFB int 21h ;; char already in dl ELSE IRP x, IFB EXITM ENDIF mov dl, x int 21h ENDM ENDIF ENDM sPutCh MACRO c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 _SvRegs _PutCh c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 _RsRegs ENDM _GetCh MACRO echo IFIDNI <&echo&>, mov ah, 08h ELSE IFIDNI <&echo&>, <0> mov al, 08h ELSE mov ah, 01h ENDIF ENDIF int 21h ENDM sGetCh MACRO echo _GetCh echo ENDM _BIOSCh MACRO mov ah, 0h int 16h ENDM sBIOSCh MACRO _BIOSCh ENDM _GetStr MACRO Structure, segm _LdAddr dx, _Ldseg ds, mov ah, 0Ah int 21h ENDM sGetStr MACRO Structure, segm _SvRegs _GetStr , _RsRegs ENDM _GetDate MACRO mov ah, 2ah int 21h ENDM sGetDate MACRO _GetDate ENDM _GetTime MACRO mov ah, 2ch int 21h ENDM sGetTime MACRO _GetTime ENDM _Open MACRO filename, accesstype, segm _LdAddr dx, _LdSeg ds, mov ah, 3dh IFB <&accesstype&> mov al, 0 ELSE IFIDNI <&accesstype&>, mov al, 0 ELSE IFIDNI <&accesstype&>, mov al, 1 ELSE IFIDNI <&accesstype&>, mov al, 2 ELSE mov al, accesstype ENDIF ENDIF ENDIF ENDIF int 21h ENDM sOpen MACRO filename, accesstype, segm _SvRegs _Open , , _RsRegs ENDM _Creat MACRO filename, segm sub cx, cx _LdAddr dx, _LdSeg ds, mov ah, 3ch int 21h ENDM sCreat MACRO filename, segm _SvRegs _Creat , _RsRegs ENDM _Close MACRO handle mov bx, handle mov ah, 3eh int 21h ENDM sClose MACRO handle _SvRegs _Close _RsRegs ENDM _Read MACRO handle, offs, count, segm mov cx, count mov bx, handle _LdAddr dx, _LdSeg ds, mov ah, 3fh int 21h ENDM sRead MACRO handle, offs, count, segm _SvRegs _Read , , , _RsRegs ENDM _Write MACRO handle, offs, count, segm mov cx, count mov bx, handle _LdAddr dx, _LdSeg ds, mov ah, 40h int 21h ENDM sWrite MACRO handle, offs, count, segm _SvRegs _Write , , , _RsRegs ENDM _LSeek MACRO Handle, SeekType, LoDistance, HiDistance IFNB mov cx, HiDistance mov dx, LoDistance ELSE IFDIFI , mov ax, LoDistance ENDIF cwd mov cx, dx mov dx, ax ENDIF mov bx, Handle mov ah, 42h IFIDNI , mov al, 0 ELSE IFIDNI , mov al, 1 ELSE IFIDNI , mov al, 2 ELSE mov al, SeekType ENDIF ENDIF ENDIF int 21h ENDM sLSeek MACRO Handle, SeekType, LoDistance, HiDistance _SvRegs _LSeek , , , _RsRegs ENDM _Exit MACRO ReturnVal IFNB mov al, ReturnVal ENDIF mov ah, 4ch int 21h ENDM sExit MACRO ReturnVal _Exit ENDM _SetIntVec MACRO intr, Handler push ds IF TYPE(Handler) EQ 4 lds dx, Handler ; Handler is DWORD PTR to routine ELSE IF TYPE(Handler) EQ 0FFFEh ; FAR label mov ax, SEG Handler ELSE mov ax, cs ENDIF mov ds, ax mov dx, OFFSET Handler ENDIF mov ah, 25h mov al, intr int 21h pop ds ENDM sSetIntVec MACRO intr, Handler _SvRegs _SetIntVec , _RsRegs ENDM _SaveIntVec MACRO intr, OldIntVec mov ah, 35h mov al, intr int 21h ASSUME es:NOTHING mov WORD PTR OldIntVec, bx mov WORD PTR OldIntVec+2, es ENDM sSaveIntVec MACRO intr, OldIntVec _SvRegs _SaveIntVec , _RsRegs ENDM ??? MACRO n ; Placeholder for debugging mov al, al ENDM .LIST