-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbank.asm
826 lines (679 loc) · 19.7 KB
/
bank.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
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
.model small
.stack 1000h
.data
subject db 10,13,'MICROPORCESSOR AND INTERFACING $'
course db 10,13,'CSE2006 $'
heading db 10,13, 'BANK MANAGEMENT SYSTEM: USER INTERFACE $'
exitmsg db 10,13, 'SYSTEM CLOSED! $'
createmsg db 10,13, 'CREATE NEW ACCOUNT $'
detailmsg db 10,13,'YOUR ACCOUNT DETAILS $'
withdrawmsg db 10,13, 'WITHDRAW $'
DEPOSITMSG db 10,13, 'DEPOSIT $'
resetmsg db 10,13,'CAUTION! YOU WILL RESET YOUR ACCOUNT $'
modmsg db 10, 13, 'CAUTION! YOU WILL PROCEED TO MODIFY YOUR ACCOUNT $'
mainmsg0 db 10,13,'0. Exit$'
mainmsg1 db 10,13,'1. Create New Account$'
mainmsg2 db 10,13,'2. Retrieve Account Details$'
mainmsg3 db 10,13,'3. Withdraw Money$'
mainmsg4 db 10,13,'4. Deposit Money$'
mainmsg5 db 10,13,'5. Reset Account$'
mainmsg6 db 10,13,'6. Update Account$'
mainmsg7 db 10,13,'Press Enter to return to main menu $'
detailmsg1 db 10,13, 'Account Name : $'
detailmsg2 db 10, 13, 'Your City : $'
detailmsg3 db 10, 13, 'No Accounts Currently Saved!!$'
detailmsg4 db 10, 13, 'Total Money Left : $'
detailmsg5 db 10, 13, 'Account Balance is Zero $'
detailmsg6 db 10, 13, 'Your State : $'
detailmsg7 db 10, 13, 'Your Phone No. : $'
moneymsg1 db 10,13,'1. Rs. 1000$'
moneymsg2 db 10,13,'2. Rs 2000$'
moneymsg3 db 10,13,'3. Rs. 5000$'
moneymsg4 db 10,13,'4. Rs. 10000$'
moneymsg5 db 10,13,'Enter Code >> $'
moneymsg6 db 10,13,'Withdraw Limit Exceeded. Process Terminated. $'
moneymsg7 db 10,13,'Money Withdrawn Successfully. $'
moneymsg8 db 10,13,'Money Deposited Successfully. $'
inputmsg db 'Choose an option >> $'
inputCode db ?
accountName db 20 dup('$')
accountPIN db 20 dup('$')
accountPhone db 20 dup('$')
accountCity db 20 dup('$')
accountState db 20 dup('$')
accountPinCode db 20 dup('$')
accountPINcount dw 0 ;This keeps track how many digit a pin is
totalAmount dw 0
inputAmountOption db ?
resetDone db 10,13,'Account has been reset. $'
create1 db 10,13,'1. Enter Account Name : $'
create2 db 10,13,'2. Enter Account Pin : $'
create5 db 10,13,'3. Enter Phone No. : $'
create6 db 10,13,'4. Enter Your City : $'
create7 db 10,13,'5. Enter Your State : $'
create8 db 10,13,'6. Enter Address Pincode : $'
create3 db 10,13,'Account Created. $'
create4 db 10,13,'Press Enter to Confirm. $'
pinMsg db 10,13,'Enter Pin >> $'
blank db 10,13,'>> $' ;for input blinker
blank2 db 10,13, ' $' ;For Newline
modAccMsg1 db 10,13,'1. New Account Name ( Old: $'
modAccMsg2 db ' ) : >> $'
modPinMsg1 db 10,13,'2. New Account Pin ( Old: $'
modPinMsg2 db ' ) : >>$'
modSuccess db 10,13,'Account Details Updated. $'
filename db "..\..\Users\S K Nayak\Documents\CSE2006 Project\admin\users.txt", 0
handle dw ?
usermsg db 10, "hello world$"
buffer db 10 dup(?)
msg_open db 10, 13, "Error opening file!$"
msg_seek db 10, 13, "Error seeking file!$"
msg_write db 10, 13, "Error writing file!$"
msg_close db 10, 13, "Error closing file!$"
new_line db 10,13
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; U T I L I T Y ;
; F U N C T I O N S ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
insert proc
mov ah, 3dh
mov al, 2
lea dx, filename
int 21h
jc err_open
mov handle, ax
mov bx, ax
mov ah, 42h ; "lseek"
mov al, 2 ; position relative to end of file
mov cx, 0 ; offset MSW
mov dx, 0 ; offset LSW
int 21h
jc err_seek
mov bx, handle
lea dx, new_line
mov cx, 2
mov ah, 40h
int 21h
lea dx, accountName
mov cx, 20
mov ah, 40h
int 21h ; write to file...
lea dx, accountPin
mov cx, 20
mov ah, 40h
int 21h ; write to file...
lea dx, accountPhone
mov cx, 20
mov ah, 40h
int 21h ; write to file...
lea dx, accountCity
mov cx, 20
mov ah, 40h
int 21h ; write to file...
lea dx, accountState
mov cx, 20
mov ah, 40h
int 21h ; write to file...
lea dx, accountPinCode
mov cx, 20
mov ah, 40h
int 21h ; write to file...
jc err_write
mov bx, handle
mov ah, 3eh
int 21h ; close file...
jc err_close
err_open:
lea dx, msg_open
jmp error
err_seek:
lea dx, msg_seek
jmp error
err_write:
lea dx, msg_write
jmp error
err_close:
lea dx, msg_close
jmp error
error:
;mov ah, 09h
;int 21h
ret
endp insert
macro printString str
lea dx, str
mov ah, 09h
; mov dx, offset str
int 21h
endm
displaySub proc near
printString subject
printString blank2
printString course
printString blank2
ret
displaySub endp
displayHeading proc near
printString heading
printString blank2
ret
displayHeading endp
displayinputMenu proc near
printString mainmsg0
printString mainmsg1
printString mainmsg2
printString mainmsg3
printString mainmsg4
printString mainmsg5
printString mainmsg6
printString mainmsg7
printString blank2
ret
displayinputMenu endp
inputMenu proc near
printString inputmsg
printString blank
mov ah, 1
int 21h
mov inputCode, al
ret
inputMenu endp
displayBye proc near
printString exitmsg
printString blank2
ret
displayBye endp
waiting proc near
mov cx, 0fh
mov dx, 4240h
mov ah, 86h
int 15h
waiting endp
clearScreen proc near
printString blank2
printString blank2
ret
clearScreen endp
; ##############################################################################################################################
; ##############################################################################################################################
; CREATE NEW ACCOUNT
; ##############################################################################################################################
; ##############################################################################################################################
macro account_name str
mov si, offset str
input:
mov ah, 1
int 21h
cmp al, 13
je create_pin
mov [si], al
inc si
jmp input
exitMac:
ret
endm
macro account_pin str
mov si, offset str
input2:
mov ah, 1
int 21h
cmp al, 13
je create_phone
inc accountPINcount
mov [si], al
inc si
jmp input2
exitMac2:
ret
endm
macro account_phone str
mov si, offset str
input3:
mov ah, 1
int 21h
cmp al, 13
je create_city
mov [si], al
inc si
jmp input3
exitMac3:
ret
endm
macro account_city str
mov si, offset str
input4:
mov ah, 1
int 21h
cmp al, 13
je create_state
mov [si], al
inc si
jmp input4
exitMac4:
ret
endm
macro account_state str
mov si, offset str
input5:
mov ah, 1
int 21h
cmp al, 13
je create_pincode
mov [si], al
inc si
jmp input5
exitMac5:
ret
endm
macro account_pincode str
mov si, offset str
input6:
mov ah, 1
int 21h
cmp al, 13
je account_created
mov [si], al
inc si
jmp input6
exitMac6:
ret
endm
; Enter to continue
proc etc
etcin:
mov ah,1
int 21h
cmp al,13
je mainloop
jmp etcin
ret
etc endp
create_account proc
call clearScreen
printString createmsg
printString blank2
printString create1
printString blank
account_name accountName
create_pin:
printString create2
printString blank
account_pin accountPIN
create_phone:
printString create5
printString blank
account_phone accountPhone
create_city:
printString create6
printString blank
account_city accountCity
create_state:
printString create7
printString blank
account_state accountState
create_pincode:
printString create8
printString blank
account_pincode accountPinCode
account_created:
printString create4
printString create3
call insert
call etc
ret
create_account endp
; ##############################################################################################################################
; ##############################################################################################################################
; RETRIEVE ACCOUNT DETAILS
; ##############################################################################################################################
; ##############################################################################################################################
checkAccountCreated proc
cmp accountPINCount, 0
je accountNotCreated
ret
accountNotCreated:
call clearScreen
printString detailmsg3
printString mainmsg7
printString blank2
call etc
checkAccountCreated endp
clearkeyboardbuffer proc near
clearin:
mov ah, 1 ; peek
int 16h
jz NoKey
mov ah, 0 ; get
int 16h
jmp clearin:
NoKey:
ret
clearkeyboardbuffer endp
getPinInput proc
call clearScreen
printString pinMsg
printString blank
mov si, offset accountPIN
mov cx, accountPINCount
getInput:
mov ah, 7
int 21h
cmp al, [si]
mov dl, '*'
mov ah, 2
int 21h
jne mainLoop
inc si
loop getInput
ret
getPinInput endp
printNumber proc
mov cx, 0
mov dx, 0
label1:
cmp ax, 0
je print1
mov bx, 10
div bx
push dx
inc cx
xor dx, dx
jmp label1
print1:
cmp cx, 0
je exitprint
pop dx
add dx, 48
mov ah, 02h
int 21h
dec cx
jmp print1
exitprint:
ret
printNumber endp
print_details proc
call checkAccountCreated
call getPinInput
call clearScreen
printString detailmsg
printString blank2
printString blank2
printString detailmsg1
printString accountName
printString blank2
printString detailmsg7
printString accountPhone
printString blank2
printString detailmsg2
printString accountCity
printString blank2
printString detailmsg6
printString accountState
printString blank2
printString detailmsg4
mov ax, totalAmount
cmp ax, 0
je noMoneyError
call printNumber
printString mainmsg7
printString blank2
call etc
noMoneyError:
printString blank2
printString detailmsg5
printString mainmsg7
printString blank2
call etc
ret
print_details endp
; ##############################################################################################################################
; ##############################################################################################################################
; WITHDRAW MONEY
; ##############################################################################################################################
; ##############################################################################################################################
proc inputAmountCode
printString blank2
printString moneymsg5
printString blank
mov ah, 1
int 21h
mov inputAmountOption, al
ret
inputAmountCode endp
withdraw proc
call checkAccountCreated
call getPinInput
call clearScreen
printString withdrawmsg
printString blank2
printString moneymsg1
printString moneymsg2
printString moneymsg3
printString moneymsg4
call inputAmountCode
cmp inputAmountOption, '1'
je withdraw_1000
cmp inputAmountOption, '2'
je withdraw_2000
cmp inputAmountOption, '3'
je withdraw_5000
cmp inputAmountOption, '4'
je withdraw_10000
withdraw_1000:
mov bx, totalAmount
cmp bx, 1000
jl lessMoney
sub totalAmount, 1000
printString moneymsg7
printString blank2
jmp mainLoop
withdraw_2000:
mov bx, totalAmount
cmp bx, 2000
jl lessMoney
sub totalAmount, 2000
printString moneymsg7
printString blank2
jmp mainLoop
withdraw_5000:
mov bx, totalAmount
cmp bx, 5000
jl lessMoney
sub totalAmount, 5000
printString moneymsg7
printString blank2
jmp mainLoop
withdraw_10000:
mov bx, totalAmount
cmp bx, 10000
jl lessMoney
sub totalAmount, 10000
printString moneymsg7
printString blank2
jmp mainLoop
lessMoney:
printString blank2
printString moneymsg6
printString mainmsg7
printString blank2
call etc
ret
withdraw endp
; ##############################################################################################################################
; ##############################################################################################################################
; DEPOSIT MONEY
; ##############################################################################################################################
; ##############################################################################################################################
deposit proc
call checkAccountCreated
call getPinInput
call clearScreen
printString DEPOSITMSG;
printString blank2
printString moneymsg1
printString moneymsg2
printString moneymsg3
printString moneymsg4
call inputAmountCode
cmp inputAmountOption, '1'
je deposit_1000
cmp inputAmountOption, '2'
je deposit_2000
cmp inputAmountOption, '3'
je deposit_5000
cmp inputAmountOption, '4'
je deposit_10000
deposit_1000:
add totalAmount, 1000
printString moneymsg8
printString blank2
jmp mainLoop
deposit_2000:
add totalAmount, 2000
printString moneymsg8
printString blank2
jmp mainLoop
deposit_5000:
add totalAmount, 5000
printString moneymsg8
printString blank2
jmp mainLoop
deposit_10000:
add totalAmount, 10000
printString moneymsg8
printString blank2
jmp mainLoop
ret
deposit endp
; ##############################################################################################################################
; ##############################################################################################################################
; RESET ACCOUNT
; ##############################################################################################################################
; ##############################################################################################################################
reset proc
call checkAccountCreated
call getPinInput
call clearScreen
printString resetmsg;
mov si, offset accountName
mov cx, 30
l1:
mov [si],' '
inc si
loop l1
mov cx, 30
mov si, offset accountPIN
l2:
mov [si],' '
inc si
loop l2
mov totalAmount, 0
mov accountPINcount, 0
printString blank2
printString resetDone
printString mainmsg7
printString blank2
call etc
ret
reset endp
; ##############################################################################################################################
; ##############################################################################################################################
; UPDATE
; ##############################################################################################################################
; ##############################################################################################################################
macro modify_account str
mov si, offset str
modify_account_in:
mov ah, 1
int 21h
cmp al, 13
je mod_pin
mov [si], al
inc si
jmp modify_account_in
endm
macro modify_pin str
mov si, offset str
mov accountPINcount, 0
modify_pin_in:
mov ah, 1
int 21h
cmp al, 13
je modify_success
inc accountPINcount
mov [si], al
inc si
jmp modify_pin_in
endm
modify proc
call checkAccountCreated
call getPinInput
call clearScreen
printString modmsg
; Account name modify
printString modAccMsg1
printString accountName
printString modAccMsg2
printString blank
modify_account accountName
mod_pin:
printString blank2
printString modPinMsg1
printString accountPIN
printString modPinMsg2
printString blank
modify_pin accountPIN
modify_success:
call clearScreen
printString create4
printString modSuccess
call etc
modify endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; E N T R Y P O I N T ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Main proc
mov ax, @data
mov ds, ax
call clearScreen
call displaySub
printString blank2
mainLoop:
call clearkeyboardbuffer
call clearScreen
call displayHeading
printString blank2
call displayinputMenu
call clearkeyboardbuffer
printString blank2
call inputMenu
cmp inputCode, '0'
je exit
cmp inputCode, '1'
je create_account
cmp inputCode, '2'
je print_details
cmp inputCode, '3'
je withdraw
cmp inputCode, '4'
je deposit
cmp inputCode, '5'
je reset
cmp inputCode, '6'
je modify
jmp mainLoop
exit:
printString blank2
printString blank2
call displayBye
printString blank2
printString blank2
mov ah,4ch
int 21h
main endp
end main