-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path220187A_8.ASM
More file actions
45 lines (32 loc) · 1.41 KB
/
220187A_8.ASM
File metadata and controls
45 lines (32 loc) · 1.41 KB
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
; ===== CONTROL THE TRAFFIC LIGHTS =============================
CLO ; Close unwanted windows.
Start:
; Turn off all the traffic lights.
MOV AL,84 ; Copy 10000100 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
; Turn on red light on left and green on right.
MOV AL,A ; A delay of 10 cpu cycles.
CALL 30 ; Call the procedure at address [30]
MOV AL,48 ; Copy 01001000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV AL,1 ; A delay of 1 cpu cycles.
CALL 30 ; Call the procedure at address [30]
MOV AL,30 ; Copy 00110000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV AL,5 ; A delay of 5 cpu cycles.
CALL 30 ; Call the procedure at address [30]
JMP Start ; Jump back to the start.
; ----- Time Delay Procedure Stored At Address [30] -------------
ORG 30 ; Generate machine code from address [30]
PUSH AL ; Save AL on the stack.
PUSHF ; Save the CPU flags on the stack.
Rep:
DEC AL ; Subtract one from AL.
JNZ REP ; Jump back to Rep if AL was not Zero.
POPF ; Restore the CPU flags from the stack.
POP AL ; Restore AL from the stack.
RET ; Return from the procedure.
; ---------------------------------------------------------------
END
; ---------------------------------------------------------------
; ===== Program Ends ==========================================