-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode
723 lines (545 loc) · 10.5 KB
/
code
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
------------------------------------------------------------
;made by 3 members
;
;to save the records in the file, ensure you select option 4 (Show Record).
;as the file operates in append mode in record procedure, this action ensures proper recording of the data
INCLUDE Irvine32.inc
include macros.inc
.data
;---------------- For Filing -----------------------
BUFFER_SIZE = 250
buffer BYTE BUFFER_SIZE DUP(?)
filename BYTE "myFile.txt",0
fileHandle HANDLE ?
fileMode DWORD GENERIC_WRITE; or GENERIC_READ, 0, 0, 2 ; Append mode
linechange byte 0Dh,0Ah,0
;---------------- Printing Statements -----------------------
menu BYTE "****** MENU ********",0ah,0ah
menu0 BYTE ' Press ( 0 / Enter ) to Clear Screen ',0ah,0ah
menu1 BYTE ' Press 1 for Rikshaw ',0ah
menu2 BYTE ' Press 2 for Cars ',0ah
menu3 BYTE ' Press 3 for Bus ',0ah
menu4 BYTE ' Press 4 to Show the Record ',0ah
menu5 BYTE ' Press 5 to Clear the Records ',0ah
m3 BYTE ' Press 6 to Remove Vehicle ',0ah
menu6 BYTE ' Press 7 to Exit ',0
my0 BYTE " (1) Remove a Rikshaw",0ah
my1 BYTE " (2) Remove a Car ",0ah
my2 BYTE " (3) Remove a Bus ",0ah
ml BYTE " (4) Return to Menu ",0
str1 BYTE " ERROR in File ",0
str2 BYTE " --- Enter User Data --- ",0ah,0ah
str3 BYTE " --> Your Name : ",0
str4 BYTE " Welcome , ",0
msg0 BYTE ' --> Parking Is Full',0
msg1 BYTE ' --> Wrong input',0
m1 BYTE "* Clear Screen *",0
m2 BYTE "Press OK to Clear Screen ",0
my3 BYTE "--> Vehicle Removed Successfully ",0
my4 BYTE "--> Vehicle isn't Parked ",0
msg2 BYTE ' Rikshaw ',0
msg3 BYTE ' Car ',0
msg4 BYTE ' Bus ',0
msg5 BYTE ' --- Record --- ',0
p1 BYTE 'Parking Fee : ',0
p2 BYTE 'Vehicle : ',0
p3 BYTE 'COUNT : ',0
p4 BYTE ' ---> Total Capacity : 10 Vehicles ',0ah,0
msg6 BYTE ' The Total Amount is : $',0
msg7 BYTE ' The Total Numbers of Vehicles Parked : ',0
msg8 BYTE ' The Total Number of Rikshws Parked : ',0
msg9 BYTE ' The Total Number of Cars Parked : ',0
msg10 BYTE ' The Total Number of Buses Parked : ',0
Choose BYTE "Enter Choice : ",0
msg12 BYTE ' * Records Deleted Successfully * ',0
final BYTE " --> Thanks For Using My Application ",0
;---------------- Variables -----------------------
amount WORD 0
count WORD 0
strL DWORD ?
rikshawcount WORD 0 ; rikshaw
carcount WORD 0 ; car
buscount WORD 0 ; bus
;-------------------- MAIN Function ------------------------
.code
main PROC
;--------------SETTING TEXT COLOUR-------------------------------
mov eax,red+(black*16)
call settextcolor
call filing
call ShowMenu
call crlf
mov edx,OFFSET final
call WriteString
call crlf
exit
main ENDP
;------------------------------------------------------------
filing PROC
; OPEN FILE IN APPEND MODE
mov edx, OFFSET filename
invoke CreateFile, ADDR filename, FILE_APPEND_DATA, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
mov fileHandle, eax
; Check for errors in opening the file
cmp eax, INVALID_HANDLE_VALUE
je fileError
; Set file pointer to the end of the file
invoke SetFilePointer, fileHandle, 0, NULL, FILE_END
mov edx, OFFSET str2
call WriteString
; Read input from buffer and write to file
mov eax, fileHandle
mov edx, OFFSET buffer
mov ecx, BUFFER_SIZE
call ReadString
mov strL, eax
; WRITE TO FILE
mov eax, fileHandle
mov edx, OFFSET buffer
mov ecx, strL
call WriteToFile
mov eax, fileHandle
mov edx,offset linechange
mov ecx,1
call WriteToFile
; Close file
invoke CloseHandle, fileHandle
ret
fileError:
mov edx, OFFSET str1
call WriteString
ret
filing ENDP
ShowMenu PROC
call crlf
mov edx,offset p4
call writestring
call crlf
mov edx,OFFSET menu ; Display Menu
call WriteString
call crlf
call crlf
mov edx,offset Choose
call writestring ; CHOICE :
call ReadInt
call select
ret
ShowMenu endp
;-----------------------------------------------------------------------
select proc
cmp eax,0
je clear
jmp start
clear:
mov ebx,offset m1
mov edx,offset m2
call MsgBox
call crlf
call clrscr
call ShowMenu
start:
cmp eax,1
jne L1
call crlf
call rikshaw
L1:
cmp eax,2
jne L2
call crlf
call car
L2:
cmp eax,3
jne L3
call crlf
call bus
L3:
cmp eax,4
jne L4
call crlf
call rec
L4:
cmp eax,5
jne L5
call crlf
call del
L5:
cmp eax,6
jne L6
call crlf
call rem
L6:
cmp eax,7
jne quit
call crlf
jmp end_
quit:
call crlf
mov edx,offset msg1
call writestring
call crlf
call crlf
call WaitMsg
call clrscr
call ShowMenu
end_:
ret
select endp
;-----------------------------------------------------------------------
rikshaw PROC
mov edx,offset p2
call writeString
mov edx,OFFSET msg2
call WriteString
cmp count,9
ja L1
mov ax,1
call crlf
mov edx,offset p1
call writeString
call writeDec
add amount,ax
mov dx,0
mov bx,10
mov cx,0
inc count
inc rikshawcount
call crlf
mov edx,offset p3
call writeString
mov ax,count
call writeDec
call crlf
call waitmsg
call crlf
call clrscr
call ShowMenu
jmp end_
L1:
call crlf
call crlf
mov edx,offset msg0
call writeString
call crlf
call crlf
call WaitMsg
call clrscr
call ShowMenu
end_:
ret
rikshaw endp
;-----------------------------------------------------------------------
car proc
mov edx,offset p2
call writeString
mov edx,OFFSET msg3
call WriteString
cmp count,9
ja L1
mov ax,2
call crlf
mov edx,offset p1
call writeString
call writeDec
add amount,ax
mov dx,0
mov bx,10
mov cx,0
inc count
inc carcount
call crlf
mov edx,offset p3
call writeString
mov ax,count
call writeDec
call crlf
call crlf
call waitmsg
call crlf
call clrscr
call ShowMenu
jmp end_
L1:
call crlf
call crlf
mov edx,offset msg0
call writeString
call crlf
call crlf
call WaitMsg
call clrscr
call ShowMenu
end_:
ret
car endp
;-----------------------------------------------------------------------
bus proc
mov edx,offset p2
call writeString
mov edx,OFFSET msg4
call WriteString
cmp count,9
ja L1
mov ax,3
call crlf
mov edx,offset p1
call writeString
call writeDec
add amount,ax
mov dx,0
mov bx,10
mov cx,0
inc count
inc buscount
call crlf
mov edx,offset p3
call writeString
mov ax,count
call writeDec
call crlf
call waitmsg
call crlf
call clrscr
call ShowMenu
jmp end_
L1:
call crlf
call crlf
mov edx,offset msg0
call writeString
call crlf
call crlf
call WaitMsg
call clrscr
call ShowMenu
end_:
ret
bus endp
;-----------------------------------------------------------------------
rec proc
mov edx,OFFSET msg5
call WriteString
call crlf
call crlf
mov edx,offset msg6
call writeString
mov ax,amount
call writeDec
call crlf
mov edx,offset msg7
call writeString
mov ax,count
call writeDec
call crlf
mov edx,offset msg8
call writeString
mov ax,rikshawcount
call writeDec
call crlf
mov edx,offset msg9
call writeString
mov ax,carcount
call writeDec
call crlf
mov edx,offset msg10
call writeString
mov ax,buscount
call writeDec
;;;;;;;;;;;;;;;;;;;;;; ; OPEN FILE IN APPEND MODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov edx, OFFSET filename
invoke CreateFile, ADDR filename, FILE_APPEND_DATA, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
mov fileHandle, eax
; WRITE TO FILE
;---------------moving amount
mov eax,filehandle
mov edx,offset msg6
mov ecx,sizeof msg6
call Writetofile
mov eax, fileHandle
mov edx,offset amount
mov ecx,2 ;sizeof amount
call WriteToFile
mov eax, fileHandle
mov edx,offset linechange
mov ecx,1
call WriteToFile
sub amount,48
;---- count of total vehical
mov eax,filehandle
mov edx,offset msg7
mov ecx,sizeof msg7
call Writetofile
;mov ebx,DWORD PTR count
;add ebx,48
add count,48
;mov amount,word ptr ebx
mov eax, fileHandle
mov edx,offset count
mov ecx,2 ;sizeof count
call WriteToFile
mov eax, fileHandle
mov edx,offset linechange
mov ecx,1
call WriteToFile
sub count,48
;---- count of rikshaw
mov eax,filehandle
mov edx,offset msg8
mov ecx,sizeof msg8
call Writetofile
;mov ebx,DWORD PTR rikshawcount
;add ebx,48
add rikshawcount,48
;mov rikshawcount,word ptr ebx
mov eax, fileHandle
mov edx,offset rikshawcount
mov ecx,2 ;sizeof rikshawcount
call WriteToFile
mov eax, fileHandle
mov edx,offset linechange
mov ecx,1
call WriteToFile
sub rikshawcount,48
;---- count of car
mov eax,filehandle
mov edx,offset msg9
mov ecx,sizeof msg9
call Writetofile
;mov ebx,DWORD PTR carcount
;add ebx,48
add carcount,48
;mov carcount,word ptr ebx
mov eax, fileHandle
mov edx,offset carcount
mov ecx,2 ;sizeof carcount
call WriteToFile
mov eax, fileHandle
mov edx,offset linechange
mov ecx,1
call WriteToFile
sub carcount,48
;---- count of bus
mov eax,filehandle
mov edx,offset msg10
mov ecx,sizeof msg10
call Writetofile
;mov ebx,DWORD PTR buscount
;add ebx,48
add buscount,48
;mov buscount,word ptr ebx
mov eax, fileHandle
mov edx,offset buscount
mov ecx,2 ;sizeof buscount
call WriteToFile
mov eax, fileHandle
mov edx,offset linechange
mov ecx,1
call WriteToFile
sub buscount,48
; Close file
invoke CloseHandle, fileHandle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call crlf
call crlf
call WaitMsg
call clrscr
call ShowMenu
ret
rec endp
;-----------------------------------------------------------------------
del proc
mov eax,0
mov ebx,0
clc
mov edx,0
mov count,0
mov amount,0
mov rikshawcount,0
mov carcount,0
mov buscount,0
call crlf
mov edx,offset msg12
call writeString
call crlf
call crlf
call waitmsg
call clrscr
call crlf
call ShowMenu
ret
del endp
;-----------------------------------------------------------------------
rem PROC
call clrscr
call crlf
mov edx,offset my0
call WriteString
mov edx,offset Choose
call crlf
call crlf
call WriteString
call readint
cmp eax,1
jne L1
cmp rikshawcount,0
je err
dec count
dec rikshawcount
sub amount,1
jmp quit
L1:
cmp eax,2
jne L2
cmp carcount,0
je err
dec count
dec carcount
sub amount,2
jmp quit
L2:
cmp eax,3
jne L3
cmp buscount,0
je err
dec count
dec buscount
sub amount,3
jmp quit
L3:
cmp eax,4
je last
jmp uff
uff:
call crlf
mov edx,offset msg1
call writeString
jmp now
err:
call crlf
mov edx,offset my4 ; Vehicle isn't Parked
call writeString
call crlf
call crlf
call waitmsg
call rem
quit:
call crlf
call crlf
mov edx,offset my3 ; REMOVED Vehicle
call WriteString
now:
call crlf
call crlf
call waitmsg
call rem
last:
call crlf
call crlf
call waitmsg
call crlf
call crlf
call clrscr
call ShowMenu
ret
rem ENDP
;-----------------------------------------------------------------------
end main