📄 system.inc
字号:
.386
.model small
option oldstructs
option proc:private
include equmac.inc
include c.inc
;******************************************************************************
;Run specified program with command line. Passes statement to command.com.
;
;Usage: Run(statement);
;
;statement - ASCII statement to pass to command.com
;
;Returns:
;
;AL - DOS exec error code.
;AH - errorlevel if AL == 0.
;
;******************************************************************************
externdef run:near
;*******************************************************************************
;Allocate some locked memory.
;
;Usage: MallocL(bytes);
;
;bytes - Bytes required.
;
;Returns:
;
;EAX - Address of allocated memory, zero on error.
;
;All other registers preserved.
;
;*******************************************************************************
externdef mallocl:near
;*******************************************************************************
;Free some locked memory.
;
;Usage: FreeL(void *memory);
;
;memory - Address to release.
;
;On Exit:
;
;EAX - Address released if ok, zero on error.
;
;All other registers preserved.
;
;*******************************************************************************
externdef freel:near
;*******************************************************************************
;Lock a memory region.
;
;Usage: MemLock(void *memory, int bytes);
;
;memory - address to lock
;bytes - bytes to lock.
;
;Returns:
;
;EAX - bytes locked. (basicly bytes or zero)
;
;*******************************************************************************
externdef memlock:near
;*******************************************************************************
;Unlock a memory region.
;
;Usage: MemUnLock(void *memory, int bytes);
;
;memory - address to unlock.
;bytes - bytes to unlock.
;
;Returns:
;
;EAX - bytes un-locked.
;
;*******************************************************************************
externdef memunlock:near
;*******************************************************************************
;
;Allocate some conventional memory.
;
;Usage: mallocdos(bytes);
;
;bytes - bytes to allocate.
;
;On Exit:
;
;EAX - memory allocated, zero if failed.
;
;All other registers preserved.
;
;*******************************************************************************
externdef mallocdos:near
;*******************************************************************************
;
;Re-allocate some memory allocated with "MallocDOS".
;
;Usage: reallocdos(old_mem, bytes);
;
;old_mem - existing memory address.
;bytes - new size in bytes.
;
;Returns:
;
;EAX - memory allocated, zero if failed.
;
;All other registers preserved.
;
;*******************************************************************************
externdef reallocdos:near
;*******************************************************************************
;
;Free some memory allocated with "MallocDOS".
;
;Usage: freedos(memory);
;
;memory - address of allocated memory.
;
;Returns:
;
;All registers preserved.
;
;*******************************************************************************
externdef freedos:near
;******************************************************************************
;Allocate memory for, and load, a file.
;
;Usage: LoadAlloc(filename);
;
;filename - name of file to load.
;
;Returns:
;
;EAX - error code if < 4 else load address.
; 0 - file not found
; 1 - file read error.
; 2 - not enough memory.
;
;All other registers preseved.
;
;******************************************************************************
externdef LoadAlloc:near
;******************************************************************************
;Allocate locked memory for, and load, a file. Copes with CWC compresion.
;
;Usage: LoadAllocL(filename);
;
;filename - name of file to load.
;
;Returns:
;
;EAX - error code if < 4 else load address.
; 0 - file not found
; 1 - file read error.
; 2 - not enough memory.
;
;All other registers preseved.
;
;******************************************************************************
externdef LoadAllocL:near
;*******************************************************************************
;
;Open a file and setup buffering for it.
;
;Usage: OpenFile(filename,flags);
;
;filename - pointer to zero terminated ASCII file name.
;flags - flags.
;
;Returns:
;
;EAX - file access handle.
;
;If EAX=0 then the open failed and FIOError has the error code.
;
;All other registers preserved.
;
;*******************************************************************************
externdef OpenFile:near
externdef REDOpenFile:dword
;*******************************************************************************
;
;Create a file and setup buffering for it.
;
;Usage: CreateFile(filename,flags);
;
;filename - pointer to zero terminated ASCII file name.
;flags - flags.
;
;Returns:
;
;EAX - file access handle.
;
;If EAX=0 then the create failed and FIOError has the error code.
;
;All other registers preserved.
;
;*******************************************************************************
externdef CreateFile:near
;*******************************************************************************
;
;Close a file opened with "OpenFile" or "CreateFile". Any dirty data in the
;buffer will be flushed first.
;
;Usage: CloseFile(handle);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;
;Returns:
;
;EAX - error code, zero for none. FIOError is also updated.
;
;All other registers preserved.
;
;*******************************************************************************
externdef CloseFile:near
;*******************************************************************************
;
;Set file pointer within a file opened with "OpenFile" or "CreateFile".
;
;Usage: SeekFile(handle,offset,mode);
;
;mode - mode (same as DOS)
;handle - file handle returned by "OpenFile" or "CreateFile"
;offset - new pointer value to set.
;
;Returns:
;
;EAX - absolute offset or error detected if -1.
;
;All other registers preserved.
;
;*******************************************************************************
externdef SeekFile:near
;*******************************************************************************
;
;Read data from a file opened with "OpenFile" or "CreateFile".
;
;Usage: ReadFile(handle,buffer,bytes);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;buffer - address to transfer data to.
;bytes - number of bytes to read.
;
;Returns:
;
;EAX - bytes transfered, -1 for error & FIOError has error code.
;
;*******************************************************************************
externdef ReadFile:near
;*******************************************************************************
;
;Read an ASCII line of data from a file.
;
;Usage: ReadLineFile(handle,buffer,maxlen);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;buffer - buffer to put the line in.
;maxlen - maximum line length to allow.
;
;Returns:
;
;EAX - status.
; 0=line is in buffer.
; 1=EOF, nothing in the buffer.
; 2=line length overun.
; 3=read error.
; 4=CR/LF pair mismatch.
;
;A zero terminated string with CR, LF and soft EOF's removed is read into the
;buffer specified. The removal of CR & LF and soft EOF's are the only
;modifications applied to the data read.
;
;Notes:
;
;EOF is never returned with data in the buffer. Even if EOF is encountered at
;the end of a line with no CR/LF that line will be returned as normal. The next
;use of this function will return EOF.
;
;Line length overrun returns a valid buffer (zero terminated) and the file
;pointer is moved to the next line ready for the next line read. It's upto the
;caller what to do about this error but this function will continue to work
;correctly after this error has been returned.
;
;A read error may be returned with some data in the buffer but generaly that
;data should be regarded as unreliable. Further use of this function should be
;avoided after a read error is reported.
;
;A CR/LF pair mismatch is reported when a CR is read and the next byte isn't an
;LF. The consequences are the same as for a read error.
;
;*******************************************************************************
externdef ReadLineFile:near
;*******************************************************************************
;
;Read a byte from a file opened with "OpenFile" or "CreateFile".
;
;Usage: ReadByteFile(handle);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;
;Returns:
;
;EAX - byte read or -1 for error, FIOError is error code.
;
;All other registers preserved.
;
;*******************************************************************************
externdef ReadByteFile:near
;*******************************************************************************
;
;Write data to a file opened with "OpenFile" or "CreateFile".
;
;Usage: WriteFile(handle,buffer,bytes);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;buffer - address to transfer data from.
;bytes - number of bytes to write.
;
;Returns:
;
;EAX - bytes written or -1 on error, FIOError has error code.
;
;All other registers preserved.
;
;*******************************************************************************
externdef WriteFile:near
;*******************************************************************************
;
;Write a byte to a file opened with "OpenFile" or "CreateFile".
;
;Usage: WriteByteFile(handle,byte);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;byte - byte to write.
;
;Returns:
;
;EAX - byte written, -1 for error & FIOError has error code.
;
;All other registers preserved.
;
;*******************************************************************************
externdef WriteByteFile:near
;*******************************************************************************
;
;Flush any dirty buffered data for a file opened with "OpenFile" or "CreateFile"
;to disk.
;
;Usage: FlushFile(handle);
;
;handle - file handle returned by "OpenFile" or "CreateFile"
;
;Returns:
;
;EAX - error code, zero for no error.
;
;All other registers preserved.
;
;*******************************************************************************
externdef FlushFile:near
;*******************************************************************************
;
;Buffer size and error code storage to use with above functions.
;
;*******************************************************************************
externdef FIOBufferSize:dword
externdef FIOError:dword
FIO_struc struc
FIO_Flags dd ? ;Control flags.
FIO_Flags_DOS equ 1 ;Buffer is in conventional memory.
FIO_Flags_Dirty equ 2 ;Buffer is dirty.
FIO_Handle dd ? ;File's DOS handle.
FIO_Pointer dd ? ;Current file pointer position.
FIO_BPointer dd ? ;Buffer file pointer position.
FIO_Buffered dd ? ;Number of bytes in the buffer.
FIO_Length dd ? ;Length of the buffer.
FIO_Spare dd 2 dup (?) ;reserved.
FIO_struc ends
;*******************************************************************************
;Copy a file to specified destination.
;
;Usage: CopyFile(source,dest);
;
;source - source file name.
;dest - destination file name.
;
;Returns:
;
;EAX - bytes copied, -1 on error.
;
;*******************************************************************************
externdef CopyFile:near
;*******************************************************************************
;Build a list of all valid drives on the system.
;
;Usage: GetDrives(char *buffer);
;
;buffer - Address to build list of drives.
;
;On Exit:
;
;EAX - number of drives.
;
;ALL other registers preserved.
;
;The drive list uses real drive codes (not ASCII). Each entry uses 1 byte
;and the list is terminated with -1.
;
;*******************************************************************************
externdef GetDrives:near
;******************************************************************************
;
;Get the current drive.
;
;Usage: GetDrive();
;
;Returns:
;
;EAX - Drive code.
;
;******************************************************************************
externdef GetDrive:near
;*******************************************************************************
;Get current drive and path.
;
;Usage: GetPath(char *buffer);
;
;buffer - pointer to buffer.
;
;On Exit:
;
;ALL registers preserved.
;
;*******************************************************************************
externdef GetPath:near
;******************************************************************************
;
;Set the current drive.
;
;Usage: SetDrive(drive);
;
;drive - drive code to set.
;
;Returns:
;
;ALL registers preserved.
;
;******************************************************************************
externdef SetDrive:near
;*******************************************************************************
;Set current drive and path.
;
;Usage: SetPath(char *buffer);
;
;buffer - pointer to path string.
;
;On Exit:
;
;EAX - error code.
;0 - no error.
;
;ALL other registers preserved.
;
;*******************************************************************************
externdef SetPath:near
;*******************************************************************************
;Get key press info.
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -