PORT1 EQU P0 PORT2 EQU P2 ORG 0H JMP MAIN ORG 30H MAIN: MOV SP,#5FH MOV PORT2,#0FFH LOOP: MOV R0,#4 MOV R1,#11101111B MOV R2,#0FFH NLINE: MOV A,R1 MOV PORT1,A MOV A,PORT0 ORL A,#0F0H CJNE A,#OFFH,KEYIN MOV A, R1 RL A MOV R1,A DJNZ R0,NLINE JMP LOOP KEYIN: MOV R2,A CALL DELAY1 NOPEN: MOV A,PORTO0 ORL #0F0H CJNE A,#OFFH,NOPEN CALL DELAY1 CALL TRANF CALL . CHANG MOV PORT2, A JMP LOOP DELAY1: MOV R7,#30 MOV R6,#0 T1: DJNZ R6,$ DJNZ R7,T1 RET TRANF: MOV B,#0 MOV A, R1 LOOP1: RRC A JNC LOOP2 INC B INC B INC B INC B JMP LOOP1 LOOP2: MOV A, R2 RR A RR A RR A RR A LOOP3: RRC A JNC LOOP4 INC B JMP LOOP3 LOOP4: MOV A, B RET CHANG: INC A MOVC A,@A+PC RET DB 0C0H,0F9H,0A4H,0B0H DB 99H,92H,82H,0F8H DB 80H,90H,88H,83H DB 0C6H,0A1H,86H,8EH END