-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodification.asm
221 lines (179 loc) · 2.78 KB
/
modification.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
section .data
string1: db "enter number 1 : ",0Ah
length1: equ $-string1
string2: db "enter number 2 : ",0Ah
length2: equ $-string2
string3: db "enter number 3 : ",0Ah
length3: equ $-string3
string4: db "Middle value : ",0Ah
length4: equ $-string4
section .bss
digit1: resb 1
digit2: resb 1
digit3: resb 1
digit4: resb 1
digit5: resb 1
digit6: resb 1
num1: resb 1
num2: resb 1
num3: resb 1
section .text
global _start:
_start:
;reading first number
mov eax, 4
mov ebx, 1
mov ecx, string1
mov edx, length1
int 80h
mov eax, 3
mov ebx, 0
mov ecx, digit1
mov edx, 1
int 80h
mov eax, 3
mov ebx, 0
mov ecx, digit2
mov edx, 2
int 80h
sub byte[digit1],30h
sub byte[digit2],30h
mov al,byte[digit1]
mov bl, 10
mul bl
movzx bx,byte[digit2]
add ax, bx
mov byte[num1], al
;reading second number
mov eax, 4
mov ebx, 1
mov ecx, string2
mov edx, length2
int 80h
mov eax, 3
mov ebx, 0
mov ecx, digit3
mov edx, 1
int 80h
mov eax, 3
mov ebx, 0
mov ecx, digit4
mov edx, 2
int 80h
sub byte[digit3],30h
sub byte[digit4],30h
mov al,byte[digit3]
mov bl, 10
mul bl
movzx bx,byte[digit4]
add ax, bx
mov byte[num2], al
;reading third number
mov eax, 4
mov ebx, 1
mov ecx, string3
mov edx, length3
int 80h
mov eax, 3
mov ebx, 0
mov ecx, digit5
mov edx, 1
int 80h
mov eax, 3
mov ebx, 0
mov ecx, digit6
mov edx, 2
int 80h
sub byte[digit5],30h
sub byte[digit6],30h
mov al,byte[digit5]
mov bl, 10
mul bl
movzx bx,byte[digit6]
add ax, bx
mov byte[num3], al
;starting comparison
mov eax, 4
mov ebx, 1
mov ecx, string4
mov edx, length4
int 80h
mov al, byte[num2]
cmp byte[num1],al
ja l1
jmp l2
l1:
mov al,byte[num3]
cmp byte[num1],al
jb print1
cmp byte[num2],al
jna print2
jmp print3
l2:
mov al,byte[num3]
cmp byte[num2],al
jna print2
cmp byte[num1],al
ja print1
jmp print3
print1:
movzx ax,byte[num1]
mov bl,10
div bl
mov byte[digit1],al
mov byte[digit2],ah
add byte[digit1],48
add byte[digit2],48
mov eax, 4
mov ebx, 1
mov ecx, digit1
mov edx, 1
int 80h
mov eax, 4
mov ebx, 1
mov ecx, digit2
mov edx, 1
int 80h
jmp exit
print2:
movzx ax,byte[num2]
mov bl,10
div bl
mov byte[digit1],al
mov byte[digit2],ah
add byte[digit1],48
add byte[digit2],48
mov eax, 4
mov ebx, 1
mov ecx, digit1
mov edx, 1
int 80h
mov eax, 4
mov ebx, 1
mov ecx, digit2
mov edx, 1
int 80h
jmp exit
print3:
movzx ax,byte[num3]
mov bl,10
div bl
mov byte[digit1],al
mov byte[digit2],ah
add byte[digit1],48
add byte[digit2],48
mov eax, 4
mov ebx, 1
mov ecx, digit1
mov edx, 1
int 80h
mov eax, 4
mov ebx, 1
mov ecx, digit2
mov edx, 1
int 80h
jmp exit
exit:
mov eax, 1
mov ebx, 0
int 80h