Chapter
1
I
System Calls
Example:
The following program copies
a
file using the Random Block
Read function call.
It
speeds the copy by specifying a record
count
of
1
and a record length equal
to
the file size, and using a
buffer
of
32K
bytes; the file is read as
a
single record. (Compare
this example with the sample program
for
Function
28H,
that
specifies
a
record length
of
1
and
a
record count equal to the file
size.)
current-record
f
I
le-size
fcb
filename
promptl
prompt 2
crlf
file-length
buffer
func-27H:
db
db
db
db
db
dw
db
set -d
t
a
display
get-string
display
parse
open
mov
eou 32
equ 16
37 dup
(7)
17 dup(7)
"File
to
copy:
t"
"Name of copy:
S"
1
3,l
0
,
"0"
7
32767dup(?I
buffer
promptl
15,filename
crlf
filenamel21,fcb
fcb
fcb[current-record
ran-block-read fcb,l,ax
display
prompt2
get-5tring 15,filename
display crlf
parse
f
1
lename[211
create fcb
mov fcb[current_
set-relative record fcb
offset of Current Record
field
offset of FileSizefield
seeFunction E9H
for explanation
of
t
see Function 1AH
5eeFunction E9H
seeFunction
EAH
seeFunction83H
5eeFunction29H
seeFunction 0FH
.0
:set
Current
..
;Record field
set-relative-record fcb
;seeFunction 24H
mov ax,wordptr
;fcb[file-sizel
mov file-lenqth,ax
;save
it
for
;get file size
;ran-block-write
;THIS FUNCTION
;seeFunction09H
;seeFunction EhH
;seeFunction E9H
cb
;seeFunction
29H
;see Function 16H
ecordl
,E
;set
Current Record
;field
-
;see Function24H
mov ax,file-length ;get original file
ran-block-write fcb,l,ax ;seeFunction28H
close fcb ;see Function
1EH
;size
79