Hello, I have a problem in making that when the light is green it would light for 5seconds and when the lights are red-yellow or yellow it will only light up for 3seconds. Could anyone help me how to get the result?

; controlling external device with 8086 microprocessor.
; realistic test for c:\emu8086\devices\Traffic_Lights.exe

#start=Traffic_Lights.exe#

name "traffic"


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

Recommended Answers

All 3 Replies

Assembly code needs comments. At least it stated in line 1 it's for the 8086 but why is the value 4 used in line 10?
Right now, only God knows!

That's the example that emu8086 emulator have on default

Coders I know have a saying:

When I wrote the code, God and I knew how it worked, now only God knows.

Even if this was an example, we need to know stuff like why the value 4 is used on line 10. Along with the rest.

Now if we forget about code, we write what we need to do in the specification, then make some psuedo code and in the case of assembly language try to convert each step into code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.