mdos.mac
来自「汇编&c语言code」· MAC 代码 · 共 1,638 行 · 第 1/3 页
MAC
1,638 行
else
ifb <HandlDrive>
ErrMsg
else
ifb <Count>
ErrMsg
else
ifnb <BufferOfs> ; Assume that the buffer
LoadSegment <ds>, <BufSegDevInfo> ; 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 <DOS_IOCTL>
endif
endif
endif
endm
DuplicateHandle macro Handle
ifb <Handle>
display "Caller must provide Handle parameter to DuplicateHandle."
err
else
mov bx, Handle
DosCall <DOS_DUPLICATE_HANDLE>
endif
endm
ForceDupHandle macro OriginalHandle, HandleCopy
ErrMsg macro
display "Caller must provide handle parameters to ForceDupHandle."
err
endm
ifb <Original>
ErrMsg
else
ifb <Copy>
ErrMsg
else
mov bx, OriginalHandle
mov cx, HandleCopy
DosCall <DOS_FORCE_DUP_HANDLE>
endif
endif
endm
GetCurrentDir macro Drive, StringSeg, StringOfs
ErrMsg macro
display "You must provide Drive and address parameters to GetCurrentDir."
err
endm
ifb <Drive>
ErrMsg
else
ifb <StringSeg>
ErrMsg
else
ifb <StringOfs>
ErrMsg
else
ifidni <ds>, <StringSeg>
; Do nothing
else
LoadSegment <ds>, <StringSeg>
endif
mov si, StringOfs
mov dl, Drive
DosCall DOS_GET_DIRECTORY
endif
endif
endif
endm
AllocateMemory macro Paragraphs
ifb <Paragraphs>
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 <BlockAddress>
display "You must provide the BlockAddress parameter to FreeMemory."
err
else
LoadSegment <es>, <BlockAddress>
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 <Size>
ErrMsg
else
ifb <MemoryBlock>
ErrMsg
else
ifidni <es>, <MemoryBlock>
; Do nothing
else
LoadSegment <es>, <MemoryBlock>
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 <Type>
ErrMsg
else
ifb <ParmSeg>
ErrMsg
else
ifb <ParmOfs>
ErrMsg
else
ifb <ProgramSeg>
ErrMsg
else
ifb <ProgramOfs>
ErrMsg
else
mov al, Type
LoadSegment <es>, <ParmSeg>
mov bx, ParmOfs
LoadSegment <ds>, <ProgramSeg>
mov dx, ProgramOfs
DosCall <DOS_EXEC>
endif
endif
endif
endif
endif
endm
TerminateProgram macro ErrorLevel
ifnb <ErrorLevel>
mov al, ErrorLevel ; Return optional errorlevel to DOS
endif
DosCall DOS_TERMINATE_EXE
endm
GetReturnCode macro
DosCall <DOS_GET_RETURN_CODE>
endm
FindFirst macro Attributes, StringSeg, StringOfs
ErrMsg macro
display "You must provide Attributes and address parameters to FindFirst."
err
endm
ifb <Attributes>
ErrMsg
else
ifb <StringSeg>
ErrMsg
else
ifb <StringOfs>
ErrMsg
else
ifidni <ds>, <StringSeg>
; Do nothing
else
LoadSegment <ds>, <StringSeg>
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 <DOS_GET_VERIFY_FLAG>
endm
RenameFile macro OrigSeg, OrigOfs, NewSeg, NewOfs
ErrMsg macro
display "Caller must provide address parameters to RenameFile."
err
endm
ifb <OrigSeg>
ErrMsg
else
ifb <OrigOfs>
ErrMsg
else
ifb <NewSeg>
ErrMsg
else
ifb <NewOfs>
ErrMsg
else
LoadSegment <es>, <NewSeg>
LoadSegment <ds>, <OrigSeg>
mov dx, OrigOfs
mov di, NewOfs
DosCall <DOS_RENAME_FILE>
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 <GetSet>
ErrMsg
else
ifb <Handle>
ErrMsg
else
ifnb <Time>
mov cx, Time
ifb <Date>
display "You must provide the Date parameter to GetSetFileDateTime."
err
else
mov dx, Date
endif
mov bx, Handle
mov al, GetSet
DosCall <DOS_GET_SET_DATE_TIME>
endif
endif
endif
endm
GetSetAllocationStrategy macro
DosCall <DOS_GET_SET_ALLOCATION>
endm
GetExtendedErrors macro
xor bx, bx
DosCall <DOS_GET_EXTENDED_ERRORS>
endm
CreateTemporaryFile macro Attribute, FilenameSeg, FilenameOfs
ErrMsg macro
display "Caller must provide Attribute and address parameters to CreateTemporaryFile."
err
endm
ifb <Attribute>
ErrMsg
else
ifb <FilenameSeg>
ErrMsg
else
ifb <FilenameOfs>
ErrMsg
else
LoadSegment <ds>, <FilenameSeg>
mov dx, FilenameOfs
mov cx, Attribute
DosCall <DOS_CREATE_TEMP_FILE>
endif
endif
endif
endm
CreateNewFile macro Attribute, FilenameSeg, FilenameOfs
ErrMsg macro
display "Caller must provide Attribute and address parameters to CreateNewFile."
err
endm
ifb <Attribute>
ErrMsg
else
ifb <FilenameSeg>
ErrMsg
else
ifb <FilenameOfs>
ErrMsg
else
LoadSegment <ds>, <FilenameSeg>
mov dx, FilenameOfs
mov cx, Attribute
DosCall <DOS_CREATE_NEW_FILE>
endif
endif
endif
endm
ControlFileAccess macro LockUnlock, Handle, OffsetHigh, OffsetLow, LengthHigh, LengthLow
ErrMsg macro
display "Caller must provide the function, file handle, record position and size"
display "parameters to ControlFileAccess."
err
endm
ifb <LockUnlock>
ErrMsg
else
ifb <Handle>
ErrMsg
else
ifb <OffsetHigh>
ErrMsg
else
ifb <OffsetLow>
ErrMsg
else
ifb <LengthHigh>
ErrMsg
else
ifb <LengthLow>
ErrMsg
else
mov al, LockUnlock
mov bx, Handle
mov cx, OffsetHigh
mov dx, OffsetLow
mov si, LengthHigh
mov di, LengthLow
DosCall <DOS_CONTROL_ACCESS>
endif
endif
endif
endif
endif
endif
endm
GetMachineName macro BufferSeg, BufferOfs
ErrMsg macro
display "Caller must provide buffer address parameters to GetMachineName."
err
endm
ifb <BufferSeg>
ErrMsg
else
ifb <BufferOfs>
ErrMsg
else
LoadSegment <ds>, <BufferSeg>
mov dx, BufferOfs
xor al, al
DosCall <NET_GET_MACHINE_NAME>
endif
endif
endm
SetupPrinter macro BufferSeg, BufferOfs, ListIndex, StrLength
ErrMsg macro
display "Caller must provide buffer address, Index and length parameters"
display "to SetupPrinter."
err
endm
ifb <BufferSeg>
ErrMsg
else
ifb <BufferOfs>
ErrMsg
else
ifb <ListIndex>
ErrMsg
else
ifb <StrLength>
ErrMsg
else
mov al, 2
mov bx, ListIndex
mov cx, StrLength
LoadSegment <ds>, <BufferSeg>
mov si, BufferOfs
DosCall <NET_SET_PRINTER_SETUP>
endif
endif
endif
endif
endm
GetPrinterSetup macro BufferSeg, BufferOfs, ListIndex
ErrMsg macro
display "Caller must provide buffer address and Index parameters GetPrinterSetup."
err
endm
ifb <BufferSeg>
ErrMsg
else
ifb <BufferOfs>
ErrMsg
else
ifb <ListIndex>
ErrMsg
else
mov al, 3
mov bx, ListIndex
LoadSegment <es>, <BufferSeg>
mov di, BufferOfs
DosCall <NET_GET_PRINTER_SETUP>
endif
endif
endif
endm
GetListEntry macro ListIndex, DeviceSeg, DeviceOfs, NetworkSeg, NetworkOfs
ErrMsg macro
display "Caller must provide ListIndex and buffer address parameters to GetListEntry."
err
endm
ifb <ListIndex>
ErrMsg
else
ifb <DeviceSeg>
ErrMsg
else
ifb <DeviceOfs>
ErrMsg
else
ifb <NetworkSeg>
ErrMsg
else
ifb <NetworkOfs>
ErrMsg
else
mov al, 2
mov bx, ListIndex
LoadSegment <ds>, <DeviceSeg>
LoadSegment <es>, <NetworkSeg>
mov si, DeviceOfs
mov di, NetworkOfs
DosCall <NET_GET_REDIRECTION_LIST>
endif
endif
endif
endif
endif
endm
GetListEntry macro Type, Save, DeviceSeg, DeviceOfs, NetworkSeg, NetworkOfs
ErrMsg macro
display "Caller must provide ListIndex and buffer address parameters to GetListEntry."
err
endm
ifb <Type>
ErrMsg
else
ifb <Save>
ErrMsg
ifb <DeviceSeg>
ErrMsg
else
ifb <DeviceOfs>
ErrMsg
else
ifb <NetworkSeg>
ErrMsg
else
ifb <NetworkOfs>
ErrMsg
else
mov al, 3
mov bl, Type
mov cx, Save
LoadSegment <ds>, <DeviceSeg>
LoadSegment <es>, <NetworkSeg>
mov si, DeviceOfs
mov di, NetworkOfs
DosCall <NET_REDIRECT_DEVICE>
endif
endif
endif
endif
endif
endif
endm
GetListEntry macro DeviceSeg, DeviceOfs
ErrMsg macro
display "Caller must provide ListIndex and buffer address parameters to GetListEntry."
err
endm
ifb <DeviceSeg>
ErrMsg
else
ifb <DeviceOfs>
ErrMsg
else
mov al, 4
mov cx, Save
LoadSegment <ds>, <DeviceSeg>
mov si, DeviceOfs
DosCall <NET_CANCEL_REDIRECT>
endif
endif
endm
GetPSPAddress macro
DosCall <DOS_GET_PSP>
endm
LeadByteTable macro Function, Console
ifb <Function>
display "Caller must provide Function parameter to LeadByteTable."
err
else
ifnb <Console>
mov dl, Console
else
mov al, Function
DosCall <DOS_GET_LEAD_BYTE_TABLE>
endif
endif
endm
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?