This is Turbo Pascal’s Read(File) function. It takes one parameter:
This reads bytes from File, if available.
SYS040B: MOV BX,SP
Use BX to address items on the stack.
Index | Contents |
---|---|
BX | Return Address (OFFSET) |
BX+02 | Return Address (SEGMENT) |
BX+04 | Pointer to File/Text Record Data (OFFSET) |
BX+06 | Pointer to File/Text Record Data (SEGMENT) |
SYS040D: PUSH DS
Save DS to the stack.
SYS040E: SS:
SYS040F: LES DI,[BX+04]
Loads the pointer to the File into ES:DI.
SYS0412: ES:
SYS0413: LDS DX,[DI:BufPtr]
Loads the pointer to buffer (BufPtr) in File into DS:DX.
SYS0416: ES:
SYS0417: MOV CX,[DI:BufSize]
Get size of the buffer (BufSize) in File into CX.
SYS041A: ES:
SYS041B: MOV BX,[DI:Handle]
SYS041D: MOV AH,3F
SYS041F: INT 21
Read from file or device using DOS INT 21h AH = 3Fh service with parameters:
SYS0421: JB 0433
Exit on error.
SYS0423: ES:
SYS0424: MOV [DI:BufEnd],AX
Set the actual number of bytes read on BufEnd in File.
SYS0427: XOR AX,AX
SYS0429: ES:
SYS042A: MOV WORD PTR [DI:BufPos],0000
Reset index (BufPos) of next character in buffer to 0 (beginning).
SYS042F: POP DS
Restore DS from the stack.
SYS0430: RETF 0004
Return to caller and pop-off parameters from the stack.
SYS0433: ES:
SYS0434: MOV WORD PTR [DI:BufEnd],0000
SYS0439: JMP 0429
On error, set the number of characters read (BufEnd) to 0.
See also: Text File Type or go back