-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_file.asm
67 lines (50 loc) · 858 Bytes
/
copy_file.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
global _start
section .bss
desk_f1 resb 1
desk_f2 resb 1
file_bf resb 1024
file_ln equ $-file_bf
section .text
file1 db '/home/nodir/nasm_file/file/filepath1.txt', 0
file2 db '/home/nodir/nasm_file/file/filepath2.txt', 0
_start:
;open first file
mov eax, 5
mov ebx, file1
mov ecx, 0 ; open only for read
int 0x80
cmp eax, 0
jle quit
mov edi, eax
;open second file
mov eax, 5
mov ebx, file2
mov ecx, 241h ; created how clean
mov edx, 0666q
int 0x80
cmp eax, 0
jle quit
mov esi, eax
again:
mov eax, 3
mov ebx, edi
mov ecx, file_bf
mov edx, file_ln
int 0x80
cmp eax, 1
jle close_files
mov edx, eax
mov eax, 4
mov ebx, esi
mov ecx, file_bf
int 0x80
jmp again
close_files:
mov eax, 6
mov ebx, edi
mov eax, 6
mov ebx, esi
quit:
mov eax, 1
mov ebx, 0
int 0x80