仿真电路图:
汇编程序代码:
- ;====================================================================
- ; Main.asm file generated by New Project wizard
- ;
- ; Created: 周三 1月 29 2020
- ; Processor: AT89C51
- ; Compiler: ASEM-51 (Proteus)
- ;====================================================================
- ORG 0000H
- AJMP MAIN
- ORG 0003H
- AJMP INT_0
- ORG 0013H
- AJMP INT_1
- ORG 0030H
- MAIN:
- MOV IE,#85H;
- MOV SP,#30H;
- SETB PX1;
- MOV TCON,#5H;
- RENEW:
- MOV R0,#10;
- MOV A,#0;
- LOOP:
- MOV P0,#0FFH;
- MOV P2,#0FFH;
- MOV P1,A;
- LCALL DELAY;
- LCALL DELAY;
- LCALL DELAY;
- INC A;
- DJNZ R0,LOOP;
- LJMP RENEW;
- ;================================================
- INT_0:
- PUSH PSW;
- PUSH ACC;
- SETB RS0;
- CLR RS1;
- MOV R1,#2;
- RENEW0:
- MOV R2,#10;
- MOV A,#0;
- LOOP0:
- MOV P0,A;
- LCALL DELAY;
- LCALL DELAY;
- LCALL DELAY;
- INC A;
- DJNZ R2,LOOP0;
- DJNZ R1,RENEW0;
- POP ACC;
- POP PSW;
- RETI;
- ;===============================================
- INT_1:
- PUSH PSW;
- PUSH ACC;
- CLR RS0;
- SETB RS1;
- MOV R3,#2;
- RENEW1:
- MOV R4,#10;
- MOV A,#9;
- LOOP1:
- MOV P2,A;
- LCALL DELAY;
- LCALL DELAY;
- LCALL DELAY;
- DEC A;
- DJNZ R4,LOOP1;
- DJNZ R3,RENEW1;
- POP ACC;
- POP PSW;
- RETI;
- ;==============================================
- DELAY:
- MOV R7,#11111111B;延时一段时间?
- D1:
- MOV R6,#11111111B;
- DJNZ R6,$;
- DJNZ R7,D1;?
- RET;子程序返回
- END;
复制代码
|