START:
LXI B,FF00H **load immediate BC
LXI D,0102H **load immediate DE
MOV A,B **move content of B to A
OUT 10H **output content of accumulator to port “10”
INPUT:
IN 00H **gets input from port “00”
RESET:
CMP C **input compared to content of C
JZ INPUT **if INPUT=C, get another input
JNZ COMPARE **if INPUT is not = C, go to COMPARE
COMPARE:
CMP D **compare input to D
JZ CMPINR **if INPUT=D, go to CMPINR
JNZ CMPDCR **if INPUT is not = D, go to CMPDCR
CMPINR:
MOV A,B **move content of B to A
CPI FFH **compare if content of accumulator is FF
JZ FFSTATE **if A=FF, go to FFSTATE
JNZ INR **if A is not =FF, go to INR
INR:
INR B **increment B by 1
MOV A,B **move contents of B to A
OUT 10H **output content of accumulator to port 10
JMP INPUT **get another input
CMPDCR:
MOV A,B **move content of B to A
CPI 00H **compare if content of accumulator is 00
JZ 00STATE **if A=00, go to 00STATE
JNZ DCR **if A is not = to 00, go to DCR
DCR:
DCR B **decrements B by 1
MOV A,B **move contents of B to A
OUT 10H **output content of accumulator to port 10
JMP INPUT **get another input
FFSTATE:
MVI A,FFH ** content of A becomes FF
OUT 10H **output content of the accumulator to port 10
JMP INPUT **get another input
00STATE:
MVI A,00H **content of A becomes 00
OUT 10H **output content of accumulator to port 10
JMP INPUT **get another input