; FILENAME: MDOS.MAC ; ; Copyright (c) 1988, 1990 by Borland International, Inc. ; ; DESCRIPTION: This include file contains various macros that may ; be used to communicate with DOS. This include file uses Masm mode ; syntax. For documentation on each of the macros in this file see the ; file DOSMAC.DOC. ; ; NOTE: In order to use this macro file you must also include the files: ; MMACROS.MAC, KBD.INC, and DOS.INC in your module. Terminate10Program macro DosCall endm ReadKBDEcho macro DosCall endm CharacterOutput macro Character ifb display "Caller must provide Character parameter to CharacterOutput." err else mov dl, Character DosCall endif endm AuxiliaryInput macro DosCall endm AuxiliaryOutput macro Character ifb display "Caller must provide Character parameter to AuxiliaryOutput." err else mov dl, DosCall endif endm PrinterOutput macro Character ifb display "Caller must provide Character parameter to PrinterOutput." err else mov dl, DosCall endif endm ConsoleIO macro Value ifb display "Caller must provide the Value parameter to ConsoleIO." err else mov dl, Value DosCall endif endm UnfilteredCharInput macro DosCall endm CharInputNoEcho macro DosCall endm WriteString macro StringSeg, StringOfs ErrMsg macro display "You must provide the string address parameters to WriteString." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs DosCall DOS_WRITE_STRING endif endif endm BufferedInput macro StringSeg, StringOfs ErrMsg macro display "Caller must provide the address parameters to BufferedInput." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs DosCall endif endif endm GetInputStatus macro DosCall endm ResetInputBuffer macro Function, StringSeg, StringOfs ifb display "Caller must provide the Function parameter to ResetInputBuffer." err else ifb mov al, Function else ifb display "Caller must provide the StringOfs parameter to ResetInputBuffer." err else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs endif endif DosCall endif endm ResetDisk macro DosCall endm ChangeDrive macro Drive ifb display "You must provide the Drive parameter to ChangeDrive." err else mov dl, Drive DosCall DOS_CHANGE_DISK_DRIVE endif endm OpenFCBFile macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to OpenFCBFile." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm CloseFCBFile macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to CloseFCBFile." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm FindFirstFCB macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to FindFirstFCB." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm FindNextFCB macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to FindNextFCB." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm DeleteFCBFile macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to DeleteFCBFile." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm SequentialFCBRead macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to SequentialFCBRead." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm SequentialFCBWrite macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to SequentialFCBWrite." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm CreateFCBFile macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to CreateFCBFile." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm RenameFCBFile macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to RenameFCBFile." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm GetDrive macro DosCall endm SetDTA macro DTASeg, DTAOfs ErrMsg macro display "You must provide the DTASeg:DTAOfs parameters to SetDTA." err endm ifb ErrMsg else ifb ErrMsg else ; First check if the parameter is a register. If it is then ; push it and pop the value into ds. If not check if it's a ; constant or variable and act accordingly. ifidni , ; Do nothing else LoadSegment , endif mov dx, DTAOfs ; Get offset of DTA DosCall DOS_SET_DTA ; Set new DTA address endif endif endm DefaultDiskAllocation macro DosCall endm DiskAllocation macro Drive ifb display "Caller must provide Drive parameter to DiskAllocation." err else mov dl, Drive DosCall endif endm RandomFCBRead macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to RandomFCBRead." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm RandomFCBWrite macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to RandomFCBWrite." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm GetFCBFileSize macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to GetFCBFileSize." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm SetFCBFileRecord macro FCBSeg, FCBOfs ErrMsg macro display "Caller must provide FCB address to SetFCBFileRecord." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs DosCall endif endif endm SetVector macro Vector, VectorSeg, VectorOfs ErrMsg macro display "You must provide the Vector, VectorSeg and VectorOfs parameters to SetVector." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, VectorOfs mov al,Vector ; Load the number of the vector DosCall DOS_SET_VECTOR endif endif endif endm CreatePSP macro PSPSeg ifb display "Caller must provide PSPSeg parameter to CreatePSP." err else mov dx, DosCall endif endm RandomFCBBlockRead macro FCBSeg, FCBOfs, Count ErrMsg macro display "Caller must provide FCB address to RandomFCBBlockRead." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs mov cx, Count DosCall endif endif endif endm RandomFCBBlockWrite macro FCBSeg, FCBOfs, Count ErrMsg macro display "Caller must provide FCB address to RandomFCBBlockWrite." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, FCBOfs mov cx, Count DosCall endif endif endif endm ParseFCBFilename macro Flags, FilenameSeg, FilenameOfs, FCBSeg, FCBOfs ErrMsg macro display "Caller must provide the Flags and address parameters to ParseFCBFilename." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else LoadSegment , mov di, FCBOfs LoadSegment , mov si, FilenameOfs mov al, Flags DosCall endif endif endif endif endif endm GetDate macro DosCall endm SetDate macro Year, Month, Day ErrMsg macro display "Caller must provide Year, Month and Day parameters to SetDate." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else mov cx, Year mov dh, Month mov dl, Day DosCall endif endif endif endm GetTime macro DosCall endm SetTime macro Hour, Minute, Second, Hundredth ErrMsg macro display "Caller must provide Hour, Minute, Second and Hundredth parameters to SetTime." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else mov ch, Hour mov cl, Minute mov dh, Second mov dl, Hundredth DosCall endif endif endif endif endm SetVerifyFlag macro Flag ifb display "Caller must provide Flag parameter to SetVerifyFlag." err else xor dl, dl mov al, Flag DosCall endif endm GetDTA macro DosCall DOS_GET_DTA endm GetDOSVersion macro DosCall DOS_GET_DOS_VERSION endm TSR macro Result, Paragraphs ErrMsg macro display "Caller must provide Result and Paragraphs parameters to TSR." err endm ifb ErrMsg else ifb ErrMsg else mov al, Result mov dx, Paragraphs DosCall endif endif endm GetSetBREAK macro Mode, Value ifb display "Caller must provide Mode and optionally Value parameters to GetSetBREAK." err else ifnb mov dl, Value endif mov al, Mode DosCall endif endm GetVector macro Interrupt ifb display "Caller must provide Interrupt parameter to GetVector." err else mov al, Interrupt DosCall endif endm GetDiskSpace macro Disk ifb display "Caller must provide Disk parameter to GetDiskSpace." err else mov dl, Disk DosCall endif endm GetSetCountryInfo macro BufferSeg, BufferOfs, ShortCode, LongCode ErrMsg macro display "Caller must provide the buffer address and country code parameters" display "to GetSetCountryInfo." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifnb mov bx, LongCode endif mov al, ShortCode LoadSegment , mov dx, BufferOfs DosCall endif endif endif endm CreateDir macro StringSeg, StringOfs ErrMsg macro display "You must provide address parameters to CreateDir." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs DosCall DOS_MAKE_DIRECTORY endif endif endm RemoveDir macro StringSeg, StringOfs ErrMsg macro display "You must provide address parameters to RemoveDir." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs DosCall DOS_DELETE_DIRECTORY endif endif endm ChangeDirectory macro StringSeg, StringOfs ErrMsg macro display "You must provide the segment and offset of the new path to ChangeDirectory." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs ; Store the offset of the DosCall DOS_SET_CURRENT_DIR ; new path endif endif endm CreateFile macro Attributes, StringSeg, StringOfs ErrMsg macro display "You must provide Attributes and address parameters to CreateFile." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs mov cx, Attributes DosCall DOS_CREATE_FILE endif endif endif endm OpenFile macro AccessMode, StringSeg, StringOfs ErrMsg macro display "You must provide AccessMode and address parameters to OpenFile." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs mov al, AccessMode DosCall DOS_OPEN_FILE endif endif endif endm CloseFile macro Handle ifb display "You must provide a file handle to CloseFile." err else mov bx, Handle DosCall DOS_CLOSE_FILE endif endm ReadFile macro Handle, Count, StringSeg, StringOfs ErrMsg macro display "You must provide Handle, Count and address parameters to ReadFile." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs mov cx, Count mov bx, Handle DosCall DOS_READ_FROM_HANDLE endif endif endif endif endm WriteFile macro Handle, Count, StringSeg, StringOfs ErrMsg macro display "You must provide Handle, Count and address parameters to WriteFile." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs mov cx, Count mov bx, Handle DosCall DOS_WRITE_TO_HANDLE endif endif endif endif endm DeleteFile macro StringSeg, StringOfs ErrMsg macro display "You must provide address parameters to OpenFile." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs DosCall DOS_DELETE_FILE endif endif endm MoveFilePtr macro Mode, Handle, OffsetHigh, OffsetLow ErrMsg macro display "You must provide Mode, Handle and offset parameters to MoveFilePtr." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else mov al, Mode mov bx, Handle mov cx, OffsetHigh mov dx, OffsetLow DosCall DOS_MOVE_FILE_POINTER endif endif endif endif endm GetSetAttributes macro Mode, Attributes, StringSeg, StringOfs ErrMsg macro display "You must provide Mode, Attribute and address parameters to GetSetAttributes." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs mov al, Mode cmp al, 1 mov cx, Attributes DosCall DOS_GET_SET_ATTRIBUTES endif endif endif endif endm IOCTL macro Function, HandleDrive, Count, BufSegDevInfo, BufferOfs ErrMsg macro display "Caller must provide Function, HandleDrive, Count, BufferSeg," display "BufferOfs and DeviceInfo parameters to IOCTL." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifnb ; Assume that the buffer LoadSegment , ; address parameters are mov dx, BufferOfs ; are defined else ; Assume that the Device mov dx, BufSegDevinfo ; information parameter endif ; is defined mov al, Function mov bx, HandleDrive mov cx, Count DosCall endif endif endif endm DuplicateHandle macro Handle ifb display "Caller must provide Handle parameter to DuplicateHandle." err else mov bx, Handle DosCall endif endm ForceDupHandle macro OriginalHandle, HandleCopy ErrMsg macro display "Caller must provide handle parameters to ForceDupHandle." err endm ifb ErrMsg else ifb ErrMsg else mov bx, OriginalHandle mov cx, HandleCopy DosCall endif endif endm GetCurrentDir macro Drive, StringSeg, StringOfs ErrMsg macro display "You must provide Drive and address parameters to GetCurrentDir." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov si, StringOfs mov dl, Drive DosCall DOS_GET_DIRECTORY endif endif endif endm AllocateMemory macro Paragraphs ifb display "You must provide the number of paragraphs to AllocateMemory." err else mov bx, Paragraphs DosCall DOS_ALLOCATE_MEMORY endif endm FreeMemory macro BlockAddress ifb display "You must provide the BlockAddress parameter to FreeMemory." err else LoadSegment , DosCall DOS_FREE_MEMORY endif endm ModifyMemory macro Size, MemoryBlock ErrMsg macro display "You must provide the Size and MemoryBlock parameters to ModifyMemory." err endm ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov bx, Size DosCall DOS_MODIFY_MEMORY endif endif endm Exec macro Type, ParmSeg, ParmOfs, ProgramSeg, ProgramOfs ErrMsg macro display "Caller must provide Type and address parameters to Exec." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else mov al, Type LoadSegment , mov bx, ParmOfs LoadSegment , mov dx, ProgramOfs DosCall endif endif endif endif endif endm TerminateProgram macro ErrorLevel ifnb mov al, ErrorLevel ; Return optional errorlevel to DOS endif DosCall DOS_TERMINATE_EXE endm GetReturnCode macro DosCall endm FindFirst macro Attributes, StringSeg, StringOfs ErrMsg macro display "You must provide Attributes and address parameters to FindFirst." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifidni , ; Do nothing else LoadSegment , endif mov dx, StringOfs mov cx, Attributes DosCall DOS_FIND_FIRST endif endif endif endm FindNext macro DosCall DOS_FIND_NEXT endm GetVerifyFlag macro DosCall endm RenameFile macro OrigSeg, OrigOfs, NewSeg, NewOfs ErrMsg macro display "Caller must provide address parameters to RenameFile." err endm ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else ifb ErrMsg else LoadSegment , LoadSegment , mov dx, OrigOfs mov di, NewOfs DosCall endif endif endif endif endm GetSetFileDateTime macro GetSet, Handle, Time, Date ErrMsg macro display "Caller must provide GetSet and Handle parameters to GetSetFileDateTime." err endm ifb ErrMsg else ifb ErrMsg else ifnb