📄 ex13_1.in
字号:
lesi MyFileVar ;Ptr to file variable.
ldxi MyFileName ;Ptr to file name.
fcreate
jc Error
Description:
fcreate opens a new file for reading. If the file already exists, fcreate
will delete it and create a new one. Other than this, the behavior is
quite similar to fopen.
Include: stdlib.a or file.a
Routine: FCLOSE
----------------
Category: File I/O
Registers on Entry:
ES:DI points at a file variable.
Registers on return: Carry is set/clear for error/no error.
AX contains (DOS) error code if carry is set.
Flags affected:
Carry denotes error.
Example of Usage:
MyFileVar FileVar <>
.
.
.
lesi MyFileVar ;Ptr to file variable.
fclose
jc Error
Description:
fclose closes a file opened by fcreate or fopen. Note that you *must* use
this call to close the file (rather than using DOS' close call). There may
be "hot" data present in internal buffers. This call flushes such data to
the file.
Note that you must make this call before quitting your application. DOS will
automatically close all files upon quitting, but DOS will not automatically
flush any hot data to disk upon program termination.
Include: stdlib.a or file.a
Routine: FFLUSH
----------------
Category: File I/O
Registers on Entry:
ES:DI points at a file variable.
Registers on return: Carry is set/clear for error/no error.
AX contains (DOS) error code if carry is set.
Flags affected:
Carry denotes error.
Example of Usage:
Ptr2FileVar dd MyFileVar
.
.
.
les di, Ptr2FileVar ;Ptr to file variable.
fflush
jc Error
Description:
fflush will write any "hot" data (data written to the file by an application
which is currently sitting in internal buffers) to the file. It is a good
idea to occassionally flush files to disk if you do not write the data to
the file all at once. This helps prevents loss of data in the event of an
abnormal termination.
Include: stdlib.a or file.a
Routine: FGETC
---------------
Category: File I/O
Registers on Entry:
ES:DI points at a file variable.
Registers on return: AL contains byte read (if no error, C=0).
AX contains (DOS) error code if carry is set.
Flags affected:
Carry denotes error.
Example of Usage:
Ptr2FileVar dd MyFileVar
.
.
.
les di, Ptr2FileVar ;Ptr to file variable.
fgetc
jc Error
<AL contains byte read at this point>
Description:
fgetc reads a single byte from a file opened for reading. On EOF the carry
flag will be set and AX will contain zero.
Include: stdlib.a or file.a
Routine: FREAD
---------------
Category: File I/O
Registers on Entry:
ES:DI points at a file variable.
DX:SI points at the destination block.
CX contains the number of bytes to read.
Registers on return: AX contains actual # of bytes read (if no error, C=0).
AX contains (DOS) error code if carry is set (AX=0
denotes EOF).
Flags affected:
Carry denotes error.
Example of Usage:
MyFileVar FileVar <>
MyBlock db 256 dup (?)
.
.
.
lesi MyFileVar ;Ptr to file variable.
ldxi MyBlock ;Place to put data.
mov cx, 256 ;# of bytes to read.
fread
jc Error
Description:
fread lets you read a block of bytes from a file opened for reading. This
call is generally *much* faster than reading a string of single bytes if you
want to read a large number of bytes at one time.
Include: stdlib.a or file.a
Routine: FPUTC
---------------
Category: File I/O
Registers on Entry:
ES:DI points at a file variable.
AL contains the character to write to the file.
Registers on return:
AX contains (DOS) error code if carry is set.
Flags affected:
Carry denotes error.
Example of Usage:
Ptr2FileVar dd MyFileVar
.
.
.
les di, Ptr2FileVar ;Ptr to file variable.
mov al, Char2Write
fputc
jc Error
Description:
fputs writes a single byte to a file opened for writing (or opened via the
fcreate call). It writes the byte in AL to the output file. Note that data
written via this call may not be written directly to the file. For performance
reasons the fputc routine buffers up the data in memory and writes large blocks
of data to the file. If you need to ensure that the data is properly written
to the file you will need to make a call to fclose or fflush.
Include: stdlib.a or file.a
Routine: FWRITE
----------------
Category: File I/O
Registers on Entry:
ES:DI points at a file variable.
DX:SI points at the source block.
CX contains the number of bytes to write.
Registers on return: AX contains actual # of bytes written (if no error).
AX contains (DOS) error code if carry is set (AX=0
denotes EOF).
Flags affected:
Carry denotes error.
Example of Usage:
MyFileVar FileVar <>
MyBlock db 256 dup (?)
.
.
.
lesi MyFileVar ;Ptr to file variable.
ldxi MyBlock ;Place to put data.
mov cx, 256 ;# of bytes to read.
fwrite
jc Error
Description:
fwrite lets you write a block of bytes to a file opened for writing. This
call is generally *much* faster than writing a string of single bytes if you
want to read a large number of bytes at one time. Note that fwrite, like
fputc, buffers up data before writing it to disk. If you need to commit
data to the disk surface at some point, you must call the fflush or fclose
routines.
Include: stdlib.a or file.a
Floating Point Routines
-----------------------
The floating point routines provide a basic floating point package for
80x86 assembly language users. The floating point package deals with
four different floating point formats: IEEE 32-bit, 64-bit, and 80-bit
formats, and an internal 81-bit format. The external formats mostly
support the IEEE standard except for certain esoteric values such as
denormalized numbers, NaNs, infinities, and other such cases.
The package provides two "pseudo-registers", a floating point accumulator
and a floating point operand. It provides routines to load and store these
pseudo-registers from memory operands (using the various formats) and then
all other operations apply to these two operands. All computations use the
internal 81-bit floating point format. The package automatically converts
between the internal format and the external format when loading and storing
values.
Do not write code which assumes the internal format is 81 bits. This format
will change in the near future when I get a chance to add guard bits to
all the computations. If your code assumes 81 bits, it will break at that
point. Besides, there is no reason your code should count on the size of
the internal operations anyway. Stick with the IEEE formats and you'll
be much better off (since your code can be easily upgraded to deal with
numeric coprocessors).
WARNING: These routines have not been sufficiently tested as of 10/10/91.
Use them with care. Report any problems with these routines to Randy Hyde
via the electronic addresses provided in this document or by sending a
written report to UC Riverside. As I get more time, I will further test
these routines and add additional functions to the package.
*** Randy Hyde
Routine: lsfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a single precision (32-bit) value to load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
lsfpa
Description: LSFPA loads a single precision floating point value into the
internal floating point accumulator. It also converts the
32-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: ssfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a single precision (32-bit) value where
this routine should store the floating point acc.
Registers on return: None
Flags affected: Carry set if conversion error.
Example of Usage:
les di, FPValue
ssfpa
Description: SSFPA stores the floating point accumulator into a single
precision variable in memory (pointed at by ES:DI). It
converts the value from the 81-bit format to the 32-bit
value before storing the result. The 64-bit mantissa used
by the FP package is rounded to 24 bits during the store.
The exponent could be out of range. If this occurs, SSFPA
returns with the carry flag set.
Include: stdlib.a or fp.a
Routine: ldfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a double precision (64-bit) value to load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
ldfpa
Description: LDFPA loads a double precision floating point value into the
internal floating point accumulator. It also converts the
64-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: sdfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a double precision (64-bit) value where
this routine should store the floating point acc.
Registers on return: None
Flags affected: Carry set if conversion error.
Example of Usage:
les di, FPValue
sdfpa
Description: SDFPA stores the floating point accumulator into a double
precision variable in memory (pointed at by ES:DI). It
converts the value from the 81-bit format to the 64-bit
value before storing the result. The 64-bit mantissa used
by the FP package is rounded to 51 bits during the store.
The exponent could be out of range. If this occurs, SDFPA
returns with the carry flag set.
Include: stdlib.a or fp.a
Routine: lefpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at an extended precision (80-bit) value to
load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
lefpa
Description: LEFPA loads an extended precision floating point value into
the internal floating point accumulator. It also converts the
80-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: lefpal
----------------
Category: Floating po
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -