-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitoperation.asm
104 lines (82 loc) · 1.27 KB
/
bitoperation.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
global _start
extern function_read
extern function_write
section .text
_start: call function_read ; getnuber fist
mov ebx, eax
call function_read ; getnuber second
mov ecx, eax
push ecx
push ebx
call function_or ; write or
add esp, 8
push ecx
push ebx
call function_and ; write and
add esp, 8
push ecx
push ebx
call function_xor ; write xor
add esp, 8
shl ebx, 1
push ebx
call function_write
add esp, 4
mov eax, 1
mov ebx, 0
int 0x80
;-----------------------------
function_or:
push ebp
mov ebp, esp
push ebx
push ecx
push edx
mov ebx, [ebp + 8]
mov ecx, [ebp + 12]
or ebx, ecx
push ebx
call function_write
add esp, 4
pop edx
pop ecx
pop ebx
mov esp, ebp
pop ebp
ret
;---------------------------------
function_and:
push ebp
mov ebp, esp
push ebx
push ecx
push edx
mov ebx, [ebp + 8]
mov ecx, [ebp + 12]
and ebx, ecx
push ebx
call function_write
add esp, 4
pop edx
pop ecx
pop ebx
mov esp, ebp
pop ebp
ret
;---------------------------------
function_xor:
push ebp
mov ebp, esp
push ebx
push edx
mov ebx, [ebp + 8]
mov ecx, [ebp + 12]
xor ebx, ecx
push ebx
call function_write
add esp, 4
pop edx
pop ebx
mov esp, ebp
pop ebp
ret