-
Notifications
You must be signed in to change notification settings - Fork 0
/
Polling System 18.0.asm
732 lines (684 loc) · 19.1 KB
/
Polling System 18.0.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
include emu8086.inc
org 100h
jmp header
;data segement
v dw 1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,?,?,?,?,?,?,?,?
n db 0
c1 db 0 ;Candidate ONE votes
c2 db 0 ;Candidate Two Votes
c3 db 0 ;Candidate Three Votes
i dw 0
v_id dw ?
av_size= 35h
av dw av_size dup(?)
v1_id dw ?
vc dw 0
count dw 0
;data ends
;code segement
header:
; Author : Vignesh Ganesan
mov bx,1
start:
mov ah,00
mov al,03
int 10h
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print ' POLLING SYSTEM'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '1.Election Comissioner'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '2.Voters'
mov dl,10 ;new line
mov ah,02h
int 21h
print 'Enter Your Choice:::'
mov ah,01h ;input
int 21h
mov ah,0
mov n,al ;moving input from al to n.
cmp n,31h ;compare n and 31h(1)
je admin ;jump to admin module if input is 1
jb wrong1 ;jump to wrong if input is less than 1
cmp n,32h ;compare n and 32h(2)
je voters ;jump to voters module if input is 2
ja wrong1 ;jump to wrong if input is greater than 2
wrong1:
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'You HAve Entered A wrong Option'
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Try Again.....'
mov ah,00
mov al,03
int 10h
jmp start
voters:
mov vc,bx
mov dl,10
mov ah,02h
int 21h
print 'Enter Voter ID::'
mov cx,04
mov bl,10
mov dx,00
ip: ;loop to get 4 digit input
mov ax,dx
mul bl
mov dx,ax
mov ax,0
mov ah,1
int 21h
sub al,30h
mov ah,0
add dx,ax
loop ip
mov v_id,dx
mov cx,30
lea si,v ; load efficitive address of v onto si
lea di,av ; load efficitive address of av onto di
check: ;loop to check if the entered voter id is registered
mov ax,[si]
cmp ax,dx
je check2
inc si
inc si
mov ax,00
loop check
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Does not Exist'
jmp start
check2:
mov cx,vc ; loop to check if the voter has already voted or not
check1:
mov ax,[di]
cmp dx,ax
je already
inc di
inc di
loop check1
;mov cx,vc
;l:
; mov dx,[di]
; mov ah,02
; int 21h
; inc di
; inc di
; loop l
jmp start_voting
already:
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Already vote is registered '
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Thank You....'
mov ah,00
mov al,03
int 10h
jmp start
admin:
mov dl,10
mov ah,02h
int 21h
print 'Enter Master password:::'
mov cx,04
mov bl,10
mov dx,00 ;loop to get master password
ip1:
mov ax,dx
mul bl
mov dx,ax
mov ax,0
mov ah,1
int 21h
sub al,30h
mov ah,0
add dx,ax
loop ip1
cmp dx,0205h ;compare the correct password with the entered password
jz X1
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Please Enter correct password'
jmp start
X1:
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '1.Add Voter'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '2.View Result'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '3.List all Voters'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '4.List of already Voted'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print '5.Exit'
mov dl,10 ;new line
mov ah,02h
int 21h
mov dl,13 ;carrage return
mov ah,02h
int 21h
print 'Enter Your Choice:::'
mov ah,01h ;input
int 21h
mov ah,0
mov n,al ;moving input from al to n.
cmp n,31h ;compare n and 31h(1)
je Y1 ;jump to admin module if input is 1
jb wrong4 ;jump to wrong if input is less than 1
cmp n,32h ;compare n and 32h(2)
je Y ;jump to voters module if input is 2
cmp n,33h ;compare n and 33h(3)
je Z
cmp n,34h
je Z1
cmp n,35h
je start ;jump to voters module if input is 3
ja wrong4 ;jump to wrong if input is greater than 3
wrong4:
print 'You HAve Entered A wrong Option'
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Try Again.....'
mov ah,00
mov al,03
int 10h
jmp X1
Z:
lea si,v
mov cx,30
printarray:
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
;load the value stored
; in variable d1
mov ax,[si]
;print the value
jmp PRINT
step2:inc si
inc si
cmp cx,0
je X1
loop printarray
jmp X1
Z1:
lea si,av
mov cx,i
printarray1:
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
;load the value stored
; Author : Vignesh Ganesan
; in variable d1
mov ax,[si]
;print the value
jmp PRINTX
stepv:inc si
inc si
cmp cx,0
je X1
loop printarray1
jmp X1
PRINT:
mov count,0
mov dx,0
label1:
; if ax is zero
cmp ax,0
je print1
;initilize bx to 10
mov bx,10
; extract the last digit
div bx
;push it in the stack
push dx
;increment the count
inc count
;set dx to 0
xor dx,dx
jmp label1
print1:
;check if count
;is greater than zero
cmp count,0
je step2
;pop the top of stack
pop dx
;add 48 so that it
;represents the ASCII
;value of digits
add dx,48
;interuppt to print a
;character
mov ah,02h
int 21h
;decrease the count
dec count
jmp print1
PRINTX:
mov count,0
mov dx,0
label1X:
; if ax is zero
cmp ax,0
je print1X
;initilize bx to 10
mov bx,10
; extract the last digit
div bx
;push it in the stack
push dx
;increment the count
inc count
;set dx to 0
xor dx,dx
jmp label1X
print1X:
;check if count
;is greater than zero
cmp count,0
je stepv
; Author : Vignesh Ganesan
;pop the top of stack
pop dx
;add 48 so that it
;represents the ASCII
;value of digits
add dx,48
;interuppt to print a
;character
mov ah,02h
int 21h
;decrease the count
dec count
jmp print1X
Y1:
mov dl,10
mov ah,02h
int 21h
print 'Enter Voter ID::'
mov cx,04
mov bl,10
mov dx,00
ip2: ;loop to get 4 digit input
mov ax,dx
mul bl
mov dx,ax
mov ax,0
mov ah,1
int 21h
sub al,30h
mov ah,0
add dx,ax
loop ip2
mov v1_id,dx
mov cx,30
lea si,v ; load efficitive address of v onto si
checki: ;loop to check if the entered voter id is registered
mov ax,[si]
cmp ax,dx
je printexists
inc si
inc si
mov ax,00
loop checki
lea si,v
mov cx,30
arrloop:
mov ax,[si]
cmp ax,0h
je insert
inc si
inc si
mov ax,00
loop arrloop
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'array full '
insert:
mov ax,v1_id
mov [si],ax
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'successfully inserted'
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Press Any Key to exit..'
mov ah,01
int 21h
mov ah,00
mov al,03
int 10h
jmp start
printexists:
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Exist'
jmp X1
Y: ;display the final votes
mov ah,00h
mov al,03h
int 10h
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'The final Votes are'
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print '1.Doraemon'
mov dl,9
mov ah,02
int 21h
mov dl,9
mov ah,02
int 21h
mov ax,0
mov al,c1
div bl
mov bh,ah
mov dl,al
add dl,30h
mov ah,02
INT 21h
mov dl,bh
add dl,30h
mov ah,02
INT 21h
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02
int 21h
print '2.Shin Chan'
mov dl,9
mov ah,02
int 21h
mov dl,9
mov ah,02
int 21h
mov ax,0
mov al,c2
div bl
mov bh,ah
mov dl,al
add dl,30h
mov ah,02
INT 21h
mov dl,bh
add dl,30h
mov ah,02
INT 21h
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02
int 21h
print '3.Ninja Hattori'
mov dl,9
mov ah,02
int 21h
mov dl,9
mov ah,02
int 21h
mov ax,0
mov al,c3
div bl
mov bh,ah
mov dl,al
add dl,30h
mov ah,02
INT 21h
mov dl,bh
add dl,30h
mov ah,02
INT 21h
mov dl,10
mov ah,02h
int 21h
jmp winner
; Author : Vignesh Ganesan
start_voting:
add vc,1 ;inc the no. of voters voted
inc i
inc i
mov bx,vc
mov [di],dx
mov dx,[di]
; mov ah,02
;int 21h
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02h
int 21h
C:print 'The Candidates are :::'
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02h
int 21h
print '1)Doraemon'
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02
int 21h
print '2)Shin Chan'
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02
int 21h
print '3)Ninja Hattori'
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02
int 21h
print 'Enter your Choice::'
mov ah,1
int 21h
cmp al,31h ;compare input and 31h(1)
je one ;jmp if al and 31h are equal
jb wrong ;jmp if input is less than 1
cmp al,32h ;compare inpit and 32h(2)
je two ;jmp if al and 32h are equal
cmp al,33h ;compare inpit and 33h(3)
je three ;jmp if al and 33h are equal
ja wrong ;jmp if input is greated than 3
one:
inc c1 ; increment vote for candidate 1
jmp X
two:
inc c2 ; increment vote for candidate 2
jmp X
three:
inc c3 ; increment vote for candidate 3
jmp X
wrong:
print 'Enter a correct Value'
jmp C
X:
mov dl,10
mov ah,02h
int 21h
mov dl,13
mov ah,02
int 21h
print 'Your Vote Is Registered Successfully'
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Thank You For Voting...'
mov dl,10
mov ah,02
int 21h
mov dl,13
mov ah,02
int 21h
print 'Press Any Key to exit..'
mov ah,01
int 21h
mov ah,00
mov al,03
int 10h
jmp start
; Author : Vignesh Ganesan
winner:
mov al,c1
mov bl,c2
mov dl,c3
cmp al,bl ;compare al and bl
jg cc ;jump if al is greater than bl
jl cc1 ;jump if al is less than bl
je cc2 ;jump if al is equal to bl
cc:
cmp al,dl
jg msg ;jump if al is greater than dl
jl msg2 ;jump if al is less than dl
je msg5 ;jump if al is equal to dl
cc1:
cmp bl,dl
jg msg1 ;jump if bl is greater than dl
jl msg2 ;jump if bl is less than dl
je msg4 ;jump if bl is equal than dl
cc2:
cmp al,dl
jg msg3 ;jump if al is greater than dl
jl msg2 ;jump if al is less than dl
je msg6 ;jump if al is equal to dl
msg:
print 'Doraemon is the Winner'
ret
msg1:
print 'ShinChan Nohara is the Winner'
ret
msg2:
print 'Ninja Hattori is the Winner'
ret
msg3:
print 'Doraemon and ShinChan Are Winners'
ret
msg4:
print 'ShinChan Nohara and NInja Hattori are the Winner'
ret
msg5:
print 'Doraemon and Ninja Hattori are the Winner'
ret
msg6:
print 'Doraemon,Ninja Hattori and ShinChan Nohara are the Winner'
ret
ret
end