📄 cwlib.inc
字号:
;-------------------------------------------------------------------------
;Name: RenameFile
;-------------------------------------------------------------------------
;
;Rename a file.
;
;On Entry:
;
;EDX - Source file name.
;EDI - New file name.
;
;On Exit:
;
;Carry set on error.
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef RenameFile:near
;-------------------------------------------------------------------------
;Name: ReadFile
;-------------------------------------------------------------------------
;
;Read some data from a file.
;
;On Entry:
;
;EDX - Address to read to.
;ECX - length to read.
;EBX - file handle.
;
;On Exit:
;
;EAX - bytes read.
;
;-------------------------------------------------------------------------
extdef ReadFile:near
;-------------------------------------------------------------------------
;Name: WriteFile
;-------------------------------------------------------------------------
;
;Write some data to a file.
;
;On Entry:
;
;EDX - Address to write from.
;ECX - Length to write.
;EBX - file handle.
;
;On Exit:
;
;EAX - Bytes written.
;
;-------------------------------------------------------------------------
extdef WriteFile:near
;-------------------------------------------------------------------------
;Name: SetFilePointer
;-------------------------------------------------------------------------
;
;Set the file pointer position for a file.
;
;On Entry:
;
;AL - method.
;EBX - handle.
;ECX - position.
;
;Methods are:
;
;0 - Absolute offset from start.
;1 - signed offset from current position.
;2 - signed offset from end of file.
;
;On Exit:
;
;ECX - absolute offset from start of file.
;
;-------------------------------------------------------------------------
extdef SetFilePointer:near
;-------------------------------------------------------------------------
;Name: InitFileBuffer
;-------------------------------------------------------------------------
;
;Initialise file buffer.
;
;On Entry:
;
;EBX - File handle.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef InitFileBuffer:near
;-------------------------------------------------------------------------
;Name: ReadBufferByte
;-------------------------------------------------------------------------
;
;Read a byte from the file buffer.
;
;On Entry:
;
;None
;
;On Exit:
;
;AH - Bytes read, ie, AH=0 indicates EOF or an error.
;AL - Byte read.
;
;eg, if AX=0 then EOF reached.
;
;Don't mix normal ReadFile call's with this call, they don't take account of
;each other.
;
;-------------------------------------------------------------------------
extdef ReadBufferByte:near
;-------------------------------------------------------------------------
;Name: ReadBufferLine
;-------------------------------------------------------------------------
;
;Read a line of text from input file specified.
;
;On Entry:
;
;EDI - Buffer.
;
;On Exit:
;
;AL - status.
; 0 - OK.
; 1 - EOF.
;
;ECX - Bytes read.
;
;-------------------------------------------------------------------------
extdef ReadBufferLine:near
;-------------------------------------------------------------------------
;Name: MakeFileList
;-------------------------------------------------------------------------------
;
;Generate list of files that match a given file mask. Wild cards permitted.
;
;On Entry:
;
;EDX - File name mask (can include a path).
;CX - search attributes.
;
;On Exit:
;
;EAX - buffer with file names etc, EAX=0 if not enough memory.
;
;Each entry in the buffer will have the following format.
;
;13 bytes zero terminated ASCII file name (may be less)
; 1 byte file attribute (directory,vulume,hidden,system etc.)
;
; If you specify directories in the attribute search mask the names . & .. will
; be removed from the list to avoid making special checks for them. Anything
; that might have found these useful will have to have knowledge of its
; current path anyway.
;
;
;Attributes are as follows:-
;
; 5 4 3 2 1 0
; | | | | | |
; | | | | | \_ Read only. (1)
; | | | | \____ Hidden. (2)
; | | | \_______ System. (4)
; | | \__________ Label. (8)
; | \_____________ Directory. (16)
; \________________ Archive. (32)
;
; Bits 6-15 are reserved and may be used in the search mask, but bits 8-15 won't
; appear in the attributes for listed files.
;
; The first dword in the buffer is the number of entries.
; Next 256 bytes is the path to append the names to.
; Next come the actual file name entries.
;
;-------------------------------------------------------------------------
extdef MakeFileList:near
;-------------------------------------------------------------------------
;Name: ULFileList
;-------------------------------------------------------------------------------
;
;Convert normal names to lower case and directory names to upper case.
;
;On Entry:
;
;ESI - pointer to file list.
;
;On Exit:
;
;ALL registers preserved.
;
;Most routines that need to display a file list want directory names in upper
;case and the remaining names in lower case. This routine formats a file list
;to that specification. Doing things this way means that if the file list is
;then sorted, directory names will appear at the top.
;
;-------------------------------------------------------------------------
extdef ULFileList:near
;-------------------------------------------------------------------------
;Name: SortFileList
;-------------------------------------------------------------------------------
;
;Sort a file list into alpha-numeric order.
;
;On Entry:
;
;ESI - pointer to file list to sort.
;
;On Exit:
;
;ALL registers preserved.
;
;File names are not case converted so upper case names will appear at the top
;of the list.
;
;-------------------------------------------------------------------------
extdef SortFileList:near
;-------------------------------------------------------------------------------
;Name: FileListMakeName
;-------------------------------------------------------------------------
;
;Make a full drive:path\file name from a file list path string and specified
;file name.
;
;On Entry:
;
;ECX - entry number to make name from.
;ESI - pointer to file list.
;EDI - pointer to destination buffer.
;
;On Exit:
;
;ALL registers preserved.
;
;Name in a file list are just the 8.3 portion. A more useful name can be made
;by combineing the path string from the start of the list buffer with the file
;name which is what this routine does.
;
;-------------------------------------------------------------------------
extdef FileListMakeName:near
;-------------------------------------------------------------------------
;Name: GetPath
;-------------------------------------------------------------------------
;
;Get current drive and path.
;
;On Entry:
;
;EDX - pointer to buffer.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef GetPath:near
;-------------------------------------------------------------------------
;Name: SetPath
;-------------------------------------------------------------------------
;
;Set current drive and path.
;
;On Entry:
;
;EDX - pointer to path string.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef SetPath:near
;-------------------------------------------------------------------------
;Name: GetDrive
;-------------------------------------------------------------------------
;
;Get the current drive.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;AL - Drive code.
;
;-------------------------------------------------------------------------
extdef GetDrive:near
;-------------------------------------------------------------------------
;Name: SetDrive
;-------------------------------------------------------------------------
;
;Set the current drive.
;
;On Entry:
;
;AL - drive to set.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef SetDrive:near
;-------------------------------------------------------------------------
;Name: GetDrives
;-------------------------------------------------------------------------
;
;Build a list of all valid drives on the system.
;
;On Entry:
;
;EDX - Address to build list of drives.
;
;On Exit:
;
;ECX - 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.
;
;-------------------------------------------------------------------------
extdef GetDrives:near
;-------------------------------------------------------------------------
;Name: PrintString
;-------------------------------------------------------------------------
;
;Print null terminated string on screen via DOS.
;
;On Entry:
;
;ESI - pointer to string to print.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef PrintString:near
;-------------------------------------------------------------------------
;Name: UpperString
;-------------------------------------------------------------------------
;
;Convert a string into upper case.
;
;On Entry:
;
;ESI - String to convert.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef UpperString:near
;-------------------------------------------------------------------------
;Name: CopyString
;-------------------------------------------------------------------------
;
;Copy a string from one place to another.
;
;On Entry:
;
;ESI - Source string.
;EDI - Destination string.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef CopyString:near
;-------------------------------------------------------------------------
;Name: AppendString
;-------------------------------------------------------------------------
;
;Append a string to another string.
;
;On Entry:
;
;ESI - source string.
;EDI - destination string to append to.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef AppendString:near
;------------------------------------------------------------------------------
;Name: LenString
;------------------------------------------------------------------------------
;
;Work out length of a string.
;
;On Entry:
;
;ESI - pointer to string.
;
;On Exit:
;
;EAX - length of string.
;
;ALL other registers preserved.
;
;------------------------------------------------------------------------------
extdef LenString:near
;-------------------------------------------------------------------------
;Name: UpperChar
;------------------------------------------------------------------------------
;
;Convert character to upper case.
;
;On Entry:
;
;AL - character code.
;
;On Exit:
;
;AL - upper case character code.
;
;ALL other registers preserved.
;
;-------------------------------------------------------------------------
extdef UpperChar:near
;-------------------------------------------------------------------------
;Name: Beep
;-------------------------------------------------------------------------
;
;Beep, useful for simplistic debugging.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef Beep:near
;-------------------------------------------------------------------------
;Name: Bin2Dec
;-------------------------------------------------------------------------
;
;Convert number into decimal ASCII.
;
;On Entry:
;
;EAX - Number to convert.
;EDI - Buffer to put it in.
;
;On Exit:
;
;EDI - Next available byte in buffer.
;
;-------------------------------------------------------------------------
extdef Bin2Dec:near
;-------------------------------------------------------------------------
;Name: Bin2Hex
;-------------------------------------------------------------------------
;
;Convert number into ASCII Hex version.
;
;On Entry:
;
;EAX - Number to convert.
;ECX - Digits to do.
;EDI - Buffer to put string in.
;
;On Exit:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -