@@ -6,14 +6,25 @@ include Irvine32.inc
6
6
msg2 db "Podany PESEL ma nieprawidlowa dlugosc" , 0
7
7
msg3 db "PESEL musi skladac sie z samych cyfr" , 0
8
8
msg4 db "Suma kontrolna PESEL' u jest nieprawidlowa" , 0
9
- msg5 db "PESEL jest prawidlowy" , 0
10
- msg6 db "Kliknij enter aby zakonczyc program " , 0
11
-
9
+ msg5 db "PESEL jest prawidlowy" , 10 , 0
10
+ msg7 db "Plec: " , 0
11
+ msg8 db "Kobieta" , 10 , 0
12
+ msg9 db "Mezczyzna" , 10 , 0
13
+ msg10 db "Data urodzenia: " , 0
14
+ msg11 db 10 , "-----DANE-----" , 10 , 0
15
+ msg12 db 10 , "--------------" , 10 , 0
12
16
pesel byte 13 dup ( 0 ) ; ustawione na 13 aby pesel MÓGŁ być za długi i wyskoczył błąd (normalnie długość powinna wynosić 12, 11 + 0)
13
17
pesel_instruction_weight byte 1 , 3 , 7 , 9 , 1 , 3 , 7 , 9 , 1 , 3
18
+ sex byte 0 ; 0-k, 1-m
19
+ br_day db 2 dup( 0 ) , 0 ;
20
+ br_month_type byte 0
21
+ br_month byte 0
22
+ br_year_1 byte 0 ; pierwsza polowa
23
+ br_year_2 db 2 dup( 0 ) , 0 ; druga polowa
14
24
sum_weight dword 0
15
25
last_pesel_nr dword 0
16
26
27
+
17
28
.code
18
29
19
30
main proc
@@ -43,27 +54,49 @@ include Irvine32.inc
43
54
jl number_check_2
44
55
45
56
number_check_back:
57
+ cmp ecx , 11
58
+ je nr_1
59
+
60
+ cmp ecx , 10
61
+ je nr_2
62
+
63
+ cmp ecx , 7
64
+ je nr_5
65
+
66
+ cmp ecx , 6
67
+ je nr_6
68
+
69
+ nr1_2_5_6back:
70
+
46
71
sub al , '0'
47
72
48
- cmp ecx , 1
73
+ cmp ecx , 9
74
+ je nr_3
75
+
76
+ cmp ecx , 8
77
+ je nr_4
49
78
79
+ cmp ecx , 2
50
80
je nr_10
51
81
82
+ nr_back:
83
+
84
+ cmp ecx , 1
85
+ je nr_11
86
+
52
87
movzx edx , byte ptr [ ebx ]
53
88
movzx eax , al
54
89
55
90
imul edx , eax
56
91
57
92
add sum_weight , edx
58
93
59
- nr_10_back :
94
+ nr_11_back :
60
95
inc esi
61
96
inc ebx
62
97
63
98
loop iteration
64
99
65
-
66
-
67
100
mov eax , sum_weight
68
101
mov edx , 0
69
102
mov ebx , 10
@@ -97,11 +130,110 @@ include Irvine32.inc
97
130
mov edx , offset msg3
98
131
call WriteString
99
132
jmp end_message
100
-
133
+ nr_1:
134
+ mov br_year_2 [ 0 ], al
135
+ jmp nr1_2_5_6back
136
+ nr_2:
137
+ mov br_year_2 [ 1 ], al
138
+ jmp nr1_2_5_6back
139
+ nr_3:
140
+ ;switch
141
+ ; 8|9 - 18
142
+ ; 0|1 - 19
143
+ ; 2|3 - 20
144
+ ; 4|5 - 21
145
+ ; 6|7 - 22
146
+ ; jezeli drugi wariant październik/listopad/grudzień 10/11/12
147
+
148
+ cmp al , 8
149
+ je year18XX
150
+ cmp al , 9
151
+ je year18XXs
152
+
153
+ cmp al , 0
154
+ je year19XX
155
+ cmp al , 1
156
+ je year19XXs
157
+
158
+ cmp al , 2
159
+ je year20XX
160
+ cmp al , 3
161
+ je year20XXs
162
+
163
+ cmp al , 4
164
+ je year21XX
165
+ cmp al , 5
166
+ je year21XXs
167
+
168
+ cmp al , 6
169
+ je year22XX
170
+ cmp al , 7
171
+ je year22XXs
172
+
173
+ jmp nr_back
174
+
175
+ year18XX:
176
+ mov br_year_1 , 18
177
+ mov br_month_type , 0
178
+ jmp nr_back
179
+ year18XXs:
180
+ mov br_year_1 , 18
181
+ mov br_month_type , 1
182
+ jmp nr_back
183
+
184
+ year19XX:
185
+ mov br_year_1 , 19
186
+ mov br_month_type , 0
187
+ jmp nr_back
188
+ year19XXs:
189
+ mov br_year_1 , 19
190
+ mov br_month_type , 1
191
+ jmp nr_back
192
+
193
+ year20XX:
194
+ mov br_year_1 , 20
195
+ mov br_month_type , 0
196
+ jmp nr_back
197
+ year20XXs:
198
+ mov br_year_1 , 20
199
+ mov br_month_type , 1
200
+ jmp nr_back
201
+
202
+ year21XX:
203
+ mov br_year_1 , 21
204
+ mov br_month_type , 0
205
+ jmp nr_back
206
+ year21XXs:
207
+ mov br_year_1 , 21
208
+ mov br_month_type , 1
209
+ jmp nr_back
210
+
211
+ year22XX:
212
+ mov br_year_1 , 22
213
+ mov br_month_type , 0
214
+ jmp nr_back
215
+ year22XXs:
216
+ mov br_year_1 , 22
217
+ mov br_month_type , 1
218
+ jmp nr_back
219
+ nr_4:
220
+ mov br_month , al
221
+ jmp nr_back
222
+ nr_5:
223
+ mov br_day [ 0 ], al
224
+ jmp nr1_2_5_6back
225
+ nr_6:
226
+ mov br_day [ 1 ], al
227
+ jmp nr1_2_5_6back
101
228
nr_10:
229
+ mov sex , al
230
+ and sex , 01
231
+ jmp nr_back
232
+
233
+ nr_11:
102
234
movzx eax , al
103
235
mov last_pesel_nr , eax
104
- jmp nr_10_back
236
+ jmp nr_11_back
105
237
106
238
validate_10:
107
239
cmp last_pesel_nr , 0
@@ -114,10 +246,91 @@ include Irvine32.inc
114
246
jmp error_message
115
247
116
248
success_message:
249
+ jmp calculate_month
250
+ calculate_month_back:
251
+
117
252
mov edx , offset msg5
118
253
call WriteString
254
+
255
+ mov edx , offset msg11
256
+ call WriteString
257
+
258
+ mov edx , offset msg7
259
+ call WriteString
260
+
261
+ cmp sex , 1
262
+ je sex_man
263
+ jne sex_woman
264
+
265
+ sex_back:
266
+
267
+ mov edx , offset msg10
268
+ call WriteString
269
+
270
+ mov eax , 0
271
+ mov al , br_year_1
272
+ call WriteDec
273
+
274
+ mov edx , offset br_year_2
275
+ call WriteString
276
+
277
+ mov al , '-'
278
+ call WriteChar
279
+
280
+ mov al , '0'
281
+ call WriteChar
282
+
283
+ mov al , br_month
284
+ call WriteDec
285
+
286
+ mov al , '-'
287
+ call WriteChar
288
+
289
+
290
+ mov edx , offset br_day
291
+ call WriteString
292
+
293
+ mov edx , offset msg12
294
+ call WriteString
295
+
119
296
jmp end_message
120
297
298
+
299
+ sex_man:
300
+ mov edx , offset msg9
301
+ call WriteString
302
+ jmp sex_back
303
+ sex_woman:
304
+ mov edx , offset msg8
305
+ call WriteString
306
+ jmp sex_back
307
+ calculate_month:
308
+ cmp br_month_type , 0
309
+ je calculate_month_type_2
310
+ jmp calculate_month_back
311
+
312
+ calculate_month_type_2:
313
+ cmp br_month , 0
314
+ je october
315
+
316
+ cmp br_month , 1
317
+ je november
318
+
319
+ cmp br_month , 2
320
+ je december
321
+
322
+ jmp calculate_month_back
323
+
324
+ october:
325
+ mov br_month , 10
326
+ jmp calculate_month_back
327
+ november:
328
+ mov br_month , 11
329
+ jmp calculate_month_back
330
+ december:
331
+ mov br_month , 11
332
+ jmp calculate_month_back
333
+
121
334
error_message:
122
335
mov edx , offset msg4
123
336
call WriteString
@@ -126,11 +339,9 @@ include Irvine32.inc
126
339
end_message:
127
340
mov eax , 10
128
341
call WriteChar
129
- mov edx , offset msg6
130
- mov ecx , 1
131
- call WriteString
132
- call ReadString
342
+
343
+ call WaitMsg
133
344
exit
345
+
134
346
main endp
135
347
end main
136
-
0 commit comments