PT630 Programming Reference Guide
Page 41 of 59
------------------------------------------------------------------------------------------------------------------
1.5.28.4 Read File with Handle
Entry Parameter: AH = 3FH
BX = Handle of file
CX = number of bytes to read
DS:DX
; pointer to data buffer
Return Value:
if success, AX = number of bytes read and CARRY flag is cleared,
data in buffer
if failed, AX = 6 and CARRY flag is set
Example:
int TS_read_file(int hdl,int cnt,char *str)
{
segregs.ds = FP_SEG(str);
regs.x.dx = FP_OFF(str);
regs.h.ah=0x3f;
regs.x.cx=cnt;
regs.x.bx=hdl;
int86x(0x21,®s,®s,&segregs);
if ((regs.x.cflag & 0x01) == 0) return(regs.x.ax);
else return(-1);
}
1.5.28.5 Write File with Handle
Entry Parameter: AH = 40H
BX
=
Handle
of
file
CX = number of bytes to write
DS:DX
;
pointer
to
data
buffer
Returned Value:
if success, AX = number of written bytes and CARRY flag is
cleared
if failed, AX = 6 and CARRY flag is set
Example:
int TS_write_file(int hdl,int cnt,char *str)
{
segregs.ds = FP_SEG(str);
regs.x.dx = FP_OFF(str);
regs.h.ah=0x40;
regs.x.bx=hdl;
regs.x.cx=cnt;
int86x(0x21,®s,®s,&segregs);
if ((regs.x.cflag & 0x01) == 0) return(regs.x.ax);
else return(-1);
}