📄 dosmac.doc
字号:
1 Inheritance flag, File private to 3.0
current process
---------------------------------------------------------------
StringSeg - Segment address of ASCIIZ file spec.
StringOfs - Offset within StringSeg of file spec.
Output
If function successful:
Carry flag - clear
ax - file handle
If function failed
Carry flag - set
ax - error code:
1 - Function number invalid
2 - File not found
3 - Path not found or file doesn't exist
4 - No handle available
5 - Access denied
OCH - File access code invalid
Registers modified: ax, dx, ds, Flags
Syntax: OpenFile AccessMode, StringSeg, StringOfs
CloseFile
---------
Function: Closes a file associated with a file handle.
DOS Function: 3Eh
DOS Versions: 2, 3
Input
Handle - File handle of file to close
Output
If function successful:
Carry flag - clear
If function failed:
Carry flag - set
ax - error code:
6 - handle invalid or not open
Registers modified: ax, bx, Flags
Syntax: CloseFile Handle
ReadFile
--------
Function: Reads Count bytes from the file referenced by the file handle.
DOS Function: 3Fh
DOS Versions: 2, 3
Input
Handle - DOS file handle of file to read from
Count - # of bytes to read
StringSeg - Segment address of buffer to store data in
StringOfs - offset within StringSeg of storage buffer
Output
If function successful:
Carry flag - clear
ax - # of bytes read(0 if EOF)
If function failed
Carry flag - set
ax - error code:
5 - Access denied
6 - Invalid handle or file not open
Registers modified: ax, bx, cx, ds, Flags
Syntax: ReadFile Handle, Count, StringSeg, StringOfs
WriteFile
---------
Function: Writes Count bytes to the file referenced by the file handle.
DOS Function: 40h
DOS Versions: 2, 3
Input
Handle - DOS file handle of file to write to
Count - # of bytes to write
StringSeg - Segment address of buffer storing data
StringOfs - offset within StringSeg of storage buffer
Output
If function successful:
Carry flag - clear
ax - # of bytes read(0 if disk full)
If function failed
Carry flag - set
ax - error code:
5 - Access denied
6 - Invalid handle or file not open
Registers modified: ax, bx, cx, ds, Flags
Syntax: WriteFile Handle, Count, StringSeg, StringOfs
DeleteFile
----------
Function: Deletes the file pointed to by StringSeg:StringOfs.
DOS Function: 41h
DOS Versions: 2, 3
Input
StringSeg - segment address of the filename
StringOfs - offset from StringSeg of the filename
Output
If function successful:
Carry flag - clear
If function failed
Carry flag - set
ax - error code:
2 - File not found
5 - Access denied
Registers modified: ax, dx, ds, Flags
Syntax: DeleteFile StringSeg, StringOfs
MoveFilePtr
-----------
Function: Positions the file pointer in the file referenced by Handle.
DOS Function: 42h
DOS Versions: 2, 3
Input
Mode - Offset method as defined below
MODE FUNCTION
---- -----------------------------------------------------------
0 absolute byte offset from beginning of file(always unsigned
long integer)
1 byte offset from current location(signed long integer)
2 byte offset from end of file(signed long integer)
-------------------------------------------------------------------
Handle - File handle
OffsetHigh - Most significant word of offset
OffsetLow - Least significant word of offset
Output
If function successful:
Carry flag - clear
dx - most significant word of new pointer
ax - least significant word of new pointer
If function failed
Carry flag - set
ax - error code:
1 - Function number invalid
6 - Handle invalid or not open
Registers modified: ax, bx, cx, dx, Flags
Syntax: MoveFilePtr Mode, Handle, OffsetHigh, OffsetLow
GetSetAttributes
----------------
Function: Gets or sets the file attributes.
DOS Function: 43h
DOS Versions: 2, 3
Input
Mode
0 - Get file attributes
1 - Set file attributes
Attributes - New attributes or location to store file's current
attributes.
StringSeg - Segment address of the filename to check/modify
StringOfs - Offset within StringSeg of the filename
Output
If function successful:
Carry flag - clear
If al = 0 on call
cx - attribute
If function failed:
Carry flag - set
ax - error code:
1 - Function code invalid
2 - File not found
3 - Path not found or file doesn't exist
5 - Attribute can't be changed
Registers modified: ax, cx, dx, ds, Flags
Syntax: GetSetAttributes Mode, Attributes, StringSeg, StringOfs
IOCTL
-----
Function: Passes control information to a device driver. Note that you must
provide either the buffer address parameters or the device
information parameter but not both.
DOS Function: 44h
DOS Versions: 2, 3
Input
Function - What to do as defined below:
FUNCTION RESULT
-----------------------------------------------------------------------
00h Get device information
01h Set device information
02h Read from character device control channel to a buffer
03h Write to a character device control channel from a buffer
04h Read from block device control channel to a buffer
05h Write to a block device control channel from a buffer
06h Get the input status
07h Get output status
08h Check whether a block device is changable(DOS 3.0)
09h Check whether a drive is local or remote(DOS 3.1 &
Microsoft Networks)
0Ah Check whether a handle is local or remote(DOS 3.1 &
Microsoft Networks)
0Bh Change the sharing retry count
-----------------------------------------------------------------------
HandleDrive - Handle(functions 0, 1, 2, 3, 6, 7, 0Ah)
- Drive(0 = default, 1 = A, etc.)
Count - # of bytes to read/write
BufSegDevInfo - Represents Segment address of the input/output
buffer(functions 2-5)
- Represents device information(function 1).
BufferOfs - offset of the storage buffer(functions 2-5)
Output
Carry flag = clear - operation successful
ax - # of bytes read/written(functions 2-5)
al - 0 = not ready(functions 6-7)
- 1 = ready
ax - 0 = removable(function 8)
- 1 = fixed
dx - Device information(function 0)
Carry flag = set
ax - error code
1 = Invalid function number
4 = No handle available
5 = Access denied
6 = Invalid handle or device not open
0Dh = Invalid data
0Fh = Invalid drive number
Registers modified: ax, bx, cx, dx, ds, flags
Syntax: IOCTL Function, HandleDrive, Count, BufSegDevInfo, BufferOfs
DuplicateHandle
---------------
Function: Duplicates a file handle that is associated with an open file or
device.
DOS Function: 45h
DOS Versions: 2, 3
Input
Handle - the handle to duplicate
Output
carry flag = clear
ax - new file handle
carry flag = set
ax - error code
4 = No more file handles available
6 = Invalid handle or file not open
Registers modified: ax, bx, flags
Syntax: DuplicateHandle Handle
ForceDupHandle
--------------
Function: Takes two file handles and makes the second one equal to the first.
DOS Function: 46h
DOS Versions: 2, 3
Input
Original - Original file handle
Copy - Copy of the file handle
Output
carry flag = clear - operation successful
carry flag = set
ax - error code
4 = No more file handles available
6 = Invalid handle or file not open
Registers modified: ax, bx, cx, flags
Syntax: ForceDupHandle OriginalHandle, HandleCopy
GetCurrentDir
-------------
Function: Returns the current DOS directory on the indicated disk drive.
DOS Function: 47h
DOS Versions: 2, 3
Input
Drive - Disk drive(0 = default, 1 = A, etc.)
StringSeg - Segment address of 64-byte buffer to store directory
name in
StringOfs - Offset within StringSeg of the 64-byte buffer
Output
If function successful:
Carry flag - clear
The buffer is filled with the full path
If function failed
Carry flag - set
ax - error code:
0Fh - Invalid drive specification
Registers modified: ax, dl, si, ds, Flags
Syntax: GetCurrentDir Drive, StringSeg, StringOfs
AllocateMemory
--------------
Function: Allocates Paragraphs paragraphs of memory.
DOS Function: 48h
DOS Versions: 2, 3
Input
Paragraphs - # of paragraphs to allocate
Output
If function successful:
Carry flag - clear
ax - initial segment of allocated block
If function failed:
Carry flag - set
ax - error code:
7 - If memory control blocks destroyed
8 - If insufficient memory
bx - size of largest block available
Registers modified: ax, bx, Flags
Syntax: AllocateMemory Paragraphs
FreeMemory
----------
Function: Frees a DOS memory block.
DOS Function: 49h
DOS Versions: 2, 3
Input
BlockAddress - segment address of the memory block
Output
If function successful:
Carry flag - clear
If function failed:
Carry flag - set
ax - error code:
7 - If memory control blocks destroyed
8 - If insufficient memory
bx - size of largest block available
Registers modified: ax, es, Flags
Syntax: FreeMemory BlockAddress
ModifyMemory
------------
Function: Modifies A DOS memory blocks size.
DOS Function: 4Ah
DOS Versions: 2, 3
Input
Size - New block size in paragraphs
MemoryBlock - Segment address of current DOS memory block
Output
If function successful:
Carry flag - clear
If function failed
Carry flag - set
ax - error code:
7 - Memory control blocks destroyed
8 - Insufficient memory
9 - Incorrect segment in es
bx - maximum block size available
Registers modified: ax, bx, es, Flags
Syntax: ModifyMemory Size, MemoryBlock
Exec
----
Function: Runs another program or loads an overlay into memory.
DOS Function: 4Bh
DOS Versions: 2, 3
InputSyntax
Type - Indicates if the macro is running an application or loading an
overlay
ParmSeg - Segment address of parameter block
ParmOfs - Offset of parameter block
ProgramSeg - Segment address of program specification
ProgramOfs - Offset of program specification
Output
carry flag = clear - operation successful
all registers except cs and ip are destroyed
carry flag = set - operation not successful
ax - error code
1 = Invalid function
2 = Program not found
5 = Access denied
8 = Insufficient memory to run the program
0Ah = Invalid environment
0Bh = Invalid format
Registers modified: ax, bx, cx, dx, si, di, bp, sp, es, ds, ss, flags
Syntax: Exec Type, ParmSeg, ParmOfs, ProgramSeg, ProgramOfs
TerminateProgram
----------------
Function: Terminates the program. If running on DOS 1.0 or 1.1, use
Terminate10Program.
DOS Function: 4Ch
DOS Versions: 2, 3
Input
ErrorLevel - ErrorLevel to return to DOS
Output
None
Register modified
NA
Syntax
TerminateProgram ErrorLevel
GetReturnCode
-------------
Function: Gets the return code after an Exec.
DOS Function: 4Dh
DOS Versions: 2, 3
Input
none
Output
ah - exit type
0 = normal program termination
1 = program was terminated by a CTRL-C
2 = A critical device error terminated the program
3 = Function 31h terminated the program
al - return code of child process
Registers modified: ax, flags
Syntax: GetReturnCode
FindFirst
---------
Function: Finds the first entry in a directory that matches the given file
specification. The information about the file is then stored in the
current DTA.
DOS Function: 4Eh
DOS Services: 2, 3
Input
Attributes - Attributes to use in search for file
StringSeg - segment address of the filename
StringOfs - offset from StringSeg of the filename
Output
If function successful:
Carry flag - clear
DTA is initialized with file information
If function failed
Carry flag - set
ax - error code:
2 - Invalid path
12h - No matching entry found
Registers modified: ax, cx, dx, ds, Flags
Syntax: FindFirst Attributes, StringSeg, StringOfs
FindNext
-------
Function: Finds the next entry in a directory that matches the file
specification last given to FindNext. The information about the file
is then stored in the current DTA.
DOS Function: 4Fh
DOS Services: 2, 3
Input
none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -