nowadays,i think i am the first man of trying to develop an ai program.
the basic workflow is read two files,one input file(this file is

generated computer peripheral OCR equipment) and another(this file is

generated by customs expected result,it's made-to-order by

miscellaneous software,in future,this kind of results or problems can

be find by machine-self)
please tell me,how do i use DOS function 42h to control file pointer

read/write contextual two files.after prepare for many algorithm
for example:


+++++++++++++++++++++++++++++
INCLUDE Irvine16.inc

.data
BufSize = 5000
infile    BYTE "input.txt",0
outfile  BYTE "my_output_file.txt",0
inHandle  WORD ?
outHandle WORD ?
buffer    BYTE BufSize DUP(?)
bytesRead WORD ?
address dw ?


.code
main PROC
    mov  ax,@data
    mov  ds,ax

; Open the input file
mov ax,716Ch  ; extended create or open
mov bx,0      ; mode = read-only
mov cx,0 ; normal attribute
mov dx,1 ; action: open
mov si,OFFSET infile
int 21h      ; call MS-DOS
jc  quit ; quit if error
mov inHandle,ax

; Read the input file
mov ah,3Fh ; read file or device
mov bx,inHandle ; file handle
mov cx,BufSize ; max bytes to read
mov dx,OFFSET buffer ; buffer pointer
int 21h
jc  quit ; quit if error
mov bytesRead,ax

; Display the buffer
mov ah,40h ; write file or device
mov bx,1 ; console output handle
mov cx,BufSize ; number of bytes
mov dx,OFFSET buffer ; buffer pointer
int 21h
jc  quit ; quit if error

; Close the file
mov  ah,3Eh    ; function: close file
mov  bx,inHandle ; input file handle
int  21h      ; call MS-DOS
jc  quit ; quit if error

; Create the output file
mov ah,3dh  ; extended create or open
mov bx,1      ; mode = write-only
mov cx,0
mov al,0; normal attribute
; mov dx,13h ; action: create/truncate
mov si,OFFSET outfile
int 21h      ; call MS-DOS
jc  quit ; quit if error
mov outHandle,ax ; save handle
;pointer
;mov ax,42h
;mov bx,outhandle
;mov cx,10
;mov al,0
;int 21h
;mov address,dx

; Write buffer to new file

mov ah,40h ; write file or device
mov bx,outHandle ; output file handle
mov cx,bytesRead ; number of bytes
mov dx,OFFSET buffer; buffer pointer

int 21h

jc  quit ; quit if error
;loop next
; Close the file
mov  ah,3Eh    ; function: close file
mov  bx,outHandle ; output file handle
int  21h      ; call MS-DOS

quit:
call Crlf
    exit
main ENDP
END main

+++++++++++++++++++++++++++++
the goal is accomplish segmental reading,after computing,finally step

outcome the procedure of dynamic demonstration.
Posted on 2009-06-09 11:07:08 by waphon