Aller au contenu

[ass]lire un fichier et ecrire dans un autre?


googie

Messages recommandés

Posté(e)

:keskidit::francais::D:mdr::D bonjour à tous, j'ai besoin de votre aide!!!!!,

j'ai un petit exercice a faire et voila: je dois aller lire un fichier txt et ecrire dans un autre txt. Lire j'y arrive mais j'arrive pas à ecrire dans l'autre fichier...

moi je procede comme suit:

je lit un caractere , je l'ecrit dans l'autre fichier je lis un caractere, je l'ecrit et ainsi de suite... jusqu'a la fin du texte...

;--------------------------------------------------------
; *******     |
;*******|
;       |
;       |
;--------------------------------------------------------
TITLE EXE5.ASM          ;|
       .MODEL small          ;|
       .STACK 256                ;|
       .386          ;|
;-------------------------------------------------------





;*********************************************************************

       	.DATA



handle dw ?
handle2 dw ?
adr db "source.txt",0
adr2 db "source2.txt",0
nbByte db ?
mode db ?
var db 32
buf db ?
buf2 db ?
temp db ?
temp2 dw ?

;*********************************************************************



;*************
;macro
;*************

;******
;affiche
;******


AffEcran	macro str
 mov dx,offset str
 mov ah,09h
 int 21h

endm

open_file	macro   ad
 mov ah, 3dh
 mov al, 00h; read only
 mov dx,offset ad; adresse
 int 21h
endm

read_file	macro handle,buff
 mov ah,3fh
 mov bx,handle
 mov cx,01h
 mov dx,offset buff
 
 int 21h
endm



write_file	macro handle,buff
 mov ah, 40h
 mov bx,offset handle
 mov cx,0h
 mov dx,offset buff
 int 21h
endm



create_file	macro f
 
 mov dx, offset f
 mov ah,3ch
 mov cx,00h
 
 int 21h
endm
 



close_file  macro	handle
 mov ah,3eh
 mov bx,offset handle
 int 21h
endm

 
;***********************end Macro*************************************



 .CODE

  
MAIN    proc far
mov ax,@data
       mov ds,ax



open_file adr2
mov handle2,ax

open_file adr
mov handle,ax



readwrite:
 
push ax
read_file handle,buf//lit un caractere
mov ax,handle

;mov buf,ah
pop ax
;mov buf2,ah

write_file handle2,buf//ecrit un caractere
jmp readwrite




;create_file adr2	


mov ah,4Ch; RETOUR AU DOS

     	int 21h

endp MAIN 




 END   MAIN

please help me!!!!

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

×
×
  • Créer...