dos_seek.asm

来自「[随书类]Dos6.0源代码」· 汇编 代码 · 共 69 行

ASM
69
字号
;========================================================
COMMENT #

	DOS_SEEK.ASM

	Copyright (c) 1991 - Microsoft Corp.
	All rights reserved.
	Microsoft Confidential

	=================================================
	Seeks to the specified offset in an open disk
	disk file.

	long	_dos_seek( int Handle, long lOffset, int Mode )

	ARGUMENTS:	Handle	- Open DOS file handle
			lOffset - Offset to seek to in bytes
			Mode	- Seek mode as described below
				  0 = Beginning of file + offset
				  1 = Current file position + offset
				  2 = End of file + offset
	RETURNS:	long	- New offset in file is success
				  or -1L if error
	=================================================

	johnhe - 06/06/89

END COMMENT #
; =======================================================

INCLUDE	disk_io.inc
INCLUDE	model.inc

; =======================================================

.CODE

; =======================================================

_dos_seek PROC USES ES, Handle:WORD, lOffset:DWORD, Mode:BYTE

	mov	AH,42h
	mov	AL,Mode
	mov	BX,Handle

LoadOffset:
	les	DX,lOffset
	mov	CX,ES

Int21Call:
	int	21h
	jc	SeekError
	jmp	SHORT SeekReturn

SeekError:
	mov	AX,-1		; Error code
	cwd			; Extend sign to make a LONG (dword)

SeekReturn:
	ret

_dos_seek ENDP

; =======================================================

	END

; =======================================================

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?