Controlling traffic lights

558fe5180e0e8fc922d31c23ef84d240

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

How to restrict input?

558fe5180e0e8fc922d31c23ef84d240

Hello, could anyone help me how can I make so the user could only enter numbers between 0...9 and letters a...f (A...F) on input? I have a code like this already

#MAKE_EXE#

DSEG SEGMENT 'DATA'

MSG DB 'Enter double digit hex number: $'

DSEG ENDS

SSEG SEGMENT STACK 'STACK'
DW 100h DUP(?)
SSEG ENDS

CSEG SEGMENT 'CODE'

;*******************************************

START PROC FAR

PUSH DS
MOV AX, 0
PUSH AX

; set segment registers:
MOV AX, DSEG
MOV DS, AX
MOV AH,09h
MOV DX, OFFSET MSG
INT 21h
XOR AX,AX
MOV AH,1H
INT 21H
MOV DL,AL
SUB DL,30H
CMP DL,9H
JLE M1
SUB DL,7H
M1:
MOV CL,4H
SHL DL,CL
INT 21H
SUB AL,30H
CMP AL,9H
JLE M2
SUB AL,7H
M2:
ADD DL,AL
RET
START ENDP

CSEG ENDS

END START