我的尝试:
.386
.model flat, stdcall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;includem biblioteci, si declaram ce functii vrem sa importam
includelib msvcrt.lib
extern exit: proc
extern fgets:proc
extern fopen:proc
extern fclose:proc
extern printf:proc
extern getc:proc
extern ftell:proc
extern fseek:proc
extern fputs:proc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;declaram simbolul start ca public - de acolo incepe executia
public start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;sectiunile programului, date, respectiv cod
.data
;aici declaram date
s db 0
char dd 0
read db "r",0
write db "w",0
nume db "test2.txt",0
nume2 db "test3.txt",0
seek_end dd 2
i dd -1
.code
start:
push offset read
push offset nume
call fopen
add esp,8
mov esi,eax
push offset write
push offset nume2
call fopen
add esp,8
mov edi,eax
push seek_end
push 0
push esi
call fseek;
add esp,12
push esi
call ftell
add esp,4
mov ebx,eax
et:
push esi
call getc
add esp,4
;mov eax,getc
cmp eax,0ah
jne et2
et2:
push 1
push -1
push esi
call fseek
add esp,12
jmp cont
et3:
push esi
push 99
push offset s
call fgets
add esp,12
push edi
push offset s
call fputs
add esp,8
jmp et2
cont:
dec ebx
cmp ebx,0
jne et
push 0
call exit
end start