turbo-pascal-assembly

03FA I/O Function Dispatcher

This is the I/O Function Dispatcher for a File. It is called from within the system library with BX containing the offset to the function we are calling.

Possible values for BX

BX Function Description
0010 OpenFunc Pointer to I/O routine that opens this file
0014 InOutFunc Pointer to I/O routine that performs read/write on this file
0018 FlushFunc Pointer to I/O routine that flushes the buffer
001C CloseFunc Pointer to I/O routine that closes this file

These offsets are the are actually offsets to File record.

SYS03FA: PUSH ES
SYS03FB: PUSH DI

Save ES:DI on the stack.

SYS03FC: PUSH ES
SYS03FD: PUSH DI

Pass pointer to File in ES:DI to the function.

SYS03FE: ES:
SYS03FF: CALL FAR [BX+DI]

Make a far pointer to the function determined by ES:[DI+BX] (see table above).

SYS0401: OR AX,AX

Check if the I/O functions generated an error code in AX.

SYS0403: JZ 0408

Return to caller immediately if there were no errors.

SYS0405: MOV [InOutRes],AX

Record the error code in InOutRes.

SYS0408: POP DI
SYS0409: POP ES

Upon returning from the I/O functions, the parameters passed to it, i.e. ES:DI were popped-off from the stack. At this point, after restoring ES:DI, the stack is already balanced.

SYS040A: RET

Return to caller. Because it returns with a NEAR RET, it can only be called from within the system library.

See also: SYS:0499 Open Function, SYS:0480 Close Function, SYS:040B Read Function, SYS:0460 Write Function, SYS:043B Write to File Function or go back