求助:写了一个stc89c52rc驱动四位数码管的汇编程序debug也没问题了,输出来就不好使
时间:10-02
整理:3721RD
点击:
ORG 0000H;
SJMP START;
ORG 0030H;
START:
MOV SP,#60H;
MOV P1,#0FFH;
MOV R2,#0C0H;
MOV R3,#0C0H;
MOV R4,#0A1H;
MOV R5,#83H;
MOV P0,#0FFH;
MOV P2,#0FFH;
MAIN:
LCALL DISP;
LCALL KEY;
LJMP MAIN;
KEY:
JNB P1.0,K1;
JNB P1.1,K2;
JNB P1.2,K3;
JNB P1.3,K4;
JNB P1.4,K5;
JNB P1.5,K6;
JNB P1.6,K7;
JNB P1.7,K8;
I:RET
K1:LCALL DELAY1;
JB P1.1,I;
MOV R2,#0F9H;
MOV R3,#0A4H;
RET
K2:LCALL DELAY1;
JB P1.1,I;
MOV R3,#82H;
RET
K3:LCALL DELAY1;
JB P1.1,I;
MOV R2,#0A4H;
MOV R3,#0C0H;
RET
K4:LCALL DELAY1;
JB P1.1,I;
MOV R3,#99H;
RET
K5:LCALL DELAY1;
JB P1.1,I;
MOV R3,#80H;
RET
K6:LCALL DELAY1;
JB P1.1,I;
MOV R2,#0B0H;
MOV R3,#0A4H;
RET
K7:LCALL DELAY1;
JB P1.1,I;
MOV R3,#82H;
RET
K8:LCALL DELAY1;
JB P1.1,I;
MOV R2,#99H;
MOV R3,#0B0H;
RET
DISP:
MOV A,R2;
MOV P0,A ;
CLR P2.7 ;
LCALL DELAY;
SETB P2.7 ;
MOV A,R3;
MOV P0,A ;
CLR P2.6 ;
LCALL DELAY;
SETB P2.6 ;
MOV A,R4;
MOV P0,A ;
CLR P2.5 ;
LCALL DELAY;
SETB P2.5 ;
MOV A,R5;
MOV P0,A ;
CLR P2.4 ;
LCALL DELAY;
SETB P2.4 ;
RET
DELAY1:
MOV R0,#50;
D3:
MOV R1,#100;
D4:
DJNZ R1,D4;
DJNZ R0,D3;
RET
DELAY:
MOV R6,#09H;
D1:
MOV R7,#0F0H;
DJNZ R7,$ ;
DJNZ R6,D1 ;
RET
END
SJMP START;
ORG 0030H;
START:
MOV SP,#60H;
MOV P1,#0FFH;
MOV R2,#0C0H;
MOV R3,#0C0H;
MOV R4,#0A1H;
MOV R5,#83H;
MOV P0,#0FFH;
MOV P2,#0FFH;
MAIN:
LCALL DISP;
LCALL KEY;
LJMP MAIN;
KEY:
JNB P1.0,K1;
JNB P1.1,K2;
JNB P1.2,K3;
JNB P1.3,K4;
JNB P1.4,K5;
JNB P1.5,K6;
JNB P1.6,K7;
JNB P1.7,K8;
I:RET
K1:LCALL DELAY1;
JB P1.1,I;
MOV R2,#0F9H;
MOV R3,#0A4H;
RET
K2:LCALL DELAY1;
JB P1.1,I;
MOV R3,#82H;
RET
K3:LCALL DELAY1;
JB P1.1,I;
MOV R2,#0A4H;
MOV R3,#0C0H;
RET
K4:LCALL DELAY1;
JB P1.1,I;
MOV R3,#99H;
RET
K5:LCALL DELAY1;
JB P1.1,I;
MOV R3,#80H;
RET
K6:LCALL DELAY1;
JB P1.1,I;
MOV R2,#0B0H;
MOV R3,#0A4H;
RET
K7:LCALL DELAY1;
JB P1.1,I;
MOV R3,#82H;
RET
K8:LCALL DELAY1;
JB P1.1,I;
MOV R2,#99H;
MOV R3,#0B0H;
RET
DISP:
MOV A,R2;
MOV P0,A ;
CLR P2.7 ;
LCALL DELAY;
SETB P2.7 ;
MOV A,R3;
MOV P0,A ;
CLR P2.6 ;
LCALL DELAY;
SETB P2.6 ;
MOV A,R4;
MOV P0,A ;
CLR P2.5 ;
LCALL DELAY;
SETB P2.5 ;
MOV A,R5;
MOV P0,A ;
CLR P2.4 ;
LCALL DELAY;
SETB P2.4 ;
RET
DELAY1:
MOV R0,#50;
D3:
MOV R1,#100;
D4:
DJNZ R1,D4;
DJNZ R0,D3;
RET
DELAY:
MOV R6,#09H;
D1:
MOV R7,#0F0H;
DJNZ R7,$ ;
DJNZ R6,D1 ;
RET
END
为什么不用C语言了