-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBParkingManagement
74 lines (70 loc) · 1.1 KB
/
BParkingManagement
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
LXI H,00000H;
MVI M,01EH;
MVI E, 01EH;Initializing Number of Parking Slots
MVI D, 000H;Initializing Counter
MVI C, 000H;Initializing Zero Variable
USER: IN 001H;Read User Input From Port Zero
MVI H, 00H;
MOV L, A;Indexing Input Value in L Register
CMP C;
JZ START;
MOV B, M
MVI M ,00H;
DCR B;
MOV A,B;
CMP C
JNZ Loop5;
MVI A,00H;To Set Accumulator to Zero
OUT 001H;To Rewrite Input Port Value to Zero
hlt;
Loop5: INX H;
INR D;
MVI M, 00H;
MVI A, 00H;
OUT 001H;
hlt;
START: IN 002H;
CMP C
JNZ Loop3;
MOV A,M;
CMP C;Check Whether Parking Slot is empty
JZ Loop1;
INX H;Move to next memory
INR D;Increase Counter
MOV A,E
SUB D;
JM Loop2;Jump to Loop2 if Counter exceeds number of Parking Slots
JP START;
Loop1: MVI M,01H;
MOV A,L;
OUT 00H;
MVI B,0FFH;
ADD B;To Reset Flags
hlt;
Loop2: MVI A,00H;
OUT 02H;
MVI L, 00H;
MVI M, 00H;
hlt;
Loop3: MOV A,M
INX H;
INR D;
ADD M;
CMP C;
JZ Loop4;
INX H;Move to next memory
INR D;Increase Counter
MOV A,E
SUB D;
MVI B,01H
SUB B
JM Loop2;Jump to Loop2 if Counter exceeds number of Parking Slots
JP START;
Loop4: MVI M, 02H;
DCX H;
MVI M,02H;
MVI A,00H;
OUT 02H;
MVI B,0FFH;
ADD B;
hlt;