-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha8.asm
110 lines (87 loc) · 1.01 KB
/
a8.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
%macro write 2
mov ecx, %1
mov edx, %2
mov eax, 4
mov ebx, 1
int 80h
%endmacro
section .data
blen db 100
;msg db '0 arguments'
;len equ $ - msg
section .bss
fname resb 16
fd resb 8
fd2 resb 8
buffer resb 15
res resw 1
y resb 1
section .text
global _start
_start:
pop rbx
pop rbx
pop rdi
cmp byte[rdi],'T'
je type
cmp byte[rdi],'C'
je copy
cmp byte[rdi],'D'
je delete
jmp exit
type:
pop rdi
mov rsi,2
mov rax,2
mov rdx,0777
syscall
mov [fd],rax
mov rdi, [fd]
mov rsi,buffer
mov rax,0
mov rdx,100
syscall
write buffer,100
mov rax,3
mov rdi,[fd]
syscall
jmp exit
delete:
mov rax,87
pop rdi
syscall
jmp exit
copy:
pop rdi
mov rsi,2
mov rax,2
mov rdx,0777
syscall
mov [fd],rax
pop rdi
mov rsi,2
mov rax,2
mov rdx,0777
syscall
mov [fd2],rax
mov rdi, [fd]
mov rsi,buffer
mov rax,0
mov rdx,100
syscall
mov [blen],rax
mov rdi, [fd2]
mov rsi,buffer
mov rax,1
mov rdx,[blen]
syscall
mov rax,3
mov rdi,[fd]
syscall
mov rax,3
mov rdi,[fd2]
syscall
jmp exit
exit:
mov eax,1
int 80h