Academia.eduAcademia.edu

Den giao thong

mov ax, all_red out 4, ax mov si, offset situation next: mov ax, [si] out 4, ax ; wait 5 seconds (5 million microseconds) mov cx, 4Ch ; 004C4B40h = 5,000,000 mov dx, 4B40h mov ah, 86h int 15h add si, 2 ; next situation cmp si, sit_end jb next mov si, offset situation jmp next ; FEDC_BA98_7654_3210 situation dw 0000_0011_0000_1100b s1 dw 0000_0110_1001_1010b s2 dw 0000_1000_0110_0001b s3 dw 0000_1000_0110_0001b s4 dw 0000_0100_1101_0011b sit_end = $ all_red equ 0000_0010_0100_1001b .Model small .Stack 100H .Data ; GYR GYR GYR GYR R1 DW 0000_0011_0000_1100b R2 DW 0000_0010_1000_1010b R3 DW 0000_1000_0110_0001b R4 DW 0000_0100_0101_0001b ; FEDC_BA9 876 543 210 all_red equ 0000_0010_0100_1001b PORT EQU 4 ; output port ; time constants (in secs) WAIT_3_SEC_CX EQU 2Dh WAIT_3_SEC_DX EQU 0C6C0h WAIT_10_SEC_CX EQU 98h WAIT_10_SEC_DX EQU 9680h .code ; define a macro waitMacro macro t1, t2 mov cx, t1 mov dx, t2 mov ah, 86h int 15h waitMacro endm main proc ; initilize the ds and es registers mov ax, @Data mov ds,ax ; set lights to Red for all direction mov ax, all_red out PORT, ax waitMacro WAIT_3_SEC_CX, WAIT_3_SEC_DX Start: lea si, R1 mov ax, [si] out PORT, ax waitMacro WAIT_10_SEC_CX, WAIT_10_SEC_DX lea si, R2 mov ax, [si] out PORT, ax waitMacro WAIT_3_SEC_CX, WAIT_3_SEC_DX lea si, R3 mov ax, [si] out PORT, ax waitMacro WAIT_10_SEC_CX, WAIT_10_SEC_DX lea si, R4 mov ax, [si] out PORT, ax waitMacro WAIT_3_SEC_CX, WAIT_3_SEC_DX jmp Start ; end program mov ah, 4CH int 21H main endp end main