📄 second.src
字号:
; second.SRC generated from: second.c
$NOMOD51
NAME SECOND
P0 DATA 080H
P1 DATA 090H
P2 DATA 0A0H
P3 DATA 0B0H
T0 BIT 0B0H.4
AC BIT 0D0H.6
T1 BIT 0B0H.5
EA BIT 0A8H.7
IE DATA 0A8H
P0_0 BIT 080H.0
P1_0 BIT 090H.0
P0_1 BIT 080H.1
P2_0 BIT 0A0H.0
P1_1 BIT 090H.1
P0_2 BIT 080H.2
P2_1 BIT 0A0H.1
P1_2 BIT 090H.2
P0_3 BIT 080H.3
P2_2 BIT 0A0H.2
P1_3 BIT 090H.3
P0_4 BIT 080H.4
P2_3 BIT 0A0H.3
P1_4 BIT 090H.4
P0_5 BIT 080H.5
P2_4 BIT 0A0H.4
P1_5 BIT 090H.5
P0_6 BIT 080H.6
RD BIT 0B0H.7
P2_5 BIT 0A0H.5
P1_6 BIT 090H.6
P0_7 BIT 080H.7
P2_6 BIT 0A0H.6
P1_7 BIT 090H.7
ES BIT 0A8H.4
P2_7 BIT 0A0H.7
IP DATA 0B8H
RI BIT 098H.0
INT0 BIT 0B0H.2
CY BIT 0D0H.7
TI BIT 098H.1
INT1 BIT 0B0H.3
PS BIT 0B8H.4
SP DATA 081H
OV BIT 0D0H.2
WR BIT 0B0H.6
SBUF DATA 099H
PCON DATA 087H
SCON DATA 098H
TMOD DATA 089H
TCON DATA 088H
IE0 BIT 088H.1
IE1 BIT 088H.3
B DATA 0F0H
ACC DATA 0E0H
ET0 BIT 0A8H.1
ET1 BIT 0A8H.3
TF0 BIT 088H.5
TF1 BIT 088H.7
RB8 BIT 098H.2
TH0 DATA 08CH
EX0 BIT 0A8H.0
IT0 BIT 088H.0
TH1 DATA 08DH
TB8 BIT 098H.3
EX1 BIT 0A8H.2
IT1 BIT 088H.2
P BIT 0D0H.0
SM0 BIT 098H.7
TL0 DATA 08AH
SM1 BIT 098H.6
TL1 DATA 08BH
SM2 BIT 098H.5
PT0 BIT 0B8H.1
PT1 BIT 0B8H.3
RS0 BIT 0D0H.3
TR0 BIT 088H.4
RS1 BIT 0D0H.4
TR1 BIT 088H.6
PX0 BIT 0B8H.0
PX1 BIT 0B8H.2
DPH DATA 083H
DPL DATA 082H
REN BIT 098H.4
RXD BIT 0B0H.0
TXD BIT 0B0H.1
F0 BIT 0D0H.5
PSW DATA 0D0H
?PR?main?SECOND SEGMENT CODE
?DT?main?SECOND SEGMENT DATA OVERLAYABLE
?PR?initial?SECOND SEGMENT CODE
?PR?_delay?SECOND SEGMENT CODE
?DT?_delay?SECOND SEGMENT DATA OVERLAYABLE
?PR?_display?SECOND SEGMENT CODE
?PR?keyscan?SECOND SEGMENT CODE
?PR?updatee?SECOND SEGMENT CODE
?C_INITSEG SEGMENT CODE
?DT?SECOND SEGMENT DATA
EXTRN CODE (?C_STARTUP)
PUBLIC s01
PUBLIC s00
PUBLIC s1
PUBLIC s0
PUBLIC m1
PUBLIC m0
PUBLIC updatee
PUBLIC keyscan
PUBLIC _display
PUBLIC _delay
PUBLIC initial
PUBLIC main
RSEG ?DT?main?SECOND
?main?BYTE:
status?040: DS 1
keyword?041: DS 1
RSEG ?DT?_delay?SECOND
?_delay?BYTE:
ii?243: DS 2
RSEG ?DT?SECOND
m0: DS 1
m1: DS 1
s0: DS 1
s1: DS 1
s00: DS 1
s01: DS 1
RSEG ?C_INITSEG
DB 001H
DB m1
DB 000H
DB 001H
DB m0
DB 000H
DB 001H
DB s1
DB 000H
DB 001H
DB s0
DB 000H
DB 001H
DB s01
DB 000H
DB 001H
DB s00
DB 000H
; #pragma SRC
; #include <stdio.h>
; #include <reg51.h>
;
;
; #define TRUE 1
; #define FALSE 0
;
; #define DELAY_VALUE 3
; #define DELAY_VALUE_EXTRA 12
;
;
;
; #define PinDrvKey1 P1_0
; #define PinDrvKey2 P1_1
; #define PinDrvKey3 P1_2
; #define PinDrvKey4 P1_3
; //键盘扫描的驱动线
;
;
; #define PinScanKey1 P1_4
; #define PinScanKey2 P1_5
; #define PinScanKey3 P1_6
; #define PinScanKey4 P1_7
; //键盘扫描的信号获取线
;
; #define PinSegA P2_0
; #define PinSegB P2_1
; #define PinSegC P2_2
; #define PinSegD P2_3
; //七段码的数据线
;
; #define PinSelectA P2_4
; #define PinSelectB P2_5
; #define PinSelectC P2_6
; //选择器的数据位
;
; #define PinSelectCS P2_4
; //选择器的片选位
;
; #define LedSelect0 0x80
; #define LedSelect1 0x90
; #define LedSelect2 0xa0
; #define LedSelect3 0xb0
; #define LedSelect4 0xc0
; #define LedSelect5 0xd0
;
; #define PinLamp P0_0
; //指示灯驱动管脚
; #define PinSpeaker P0_1
; //蜂鸣器驱动管脚
;
; sbit P0_0=P0^0;
; sbit P0_1=P0^1;
; sbit P0_2=P0^2;
; sbit P0_3=P0^3;
; sbit P0_4=P0^4;
; sbit P0_5=P0^5;
; sbit P0_6=P0^6;
; sbit P0_7=P0^7;
;
; sbit P1_0=P1^0;
; sbit P1_1=P1^1;
; sbit P1_2=P1^2;
; sbit P1_3=P1^3;
; sbit P1_4=P1^4;
; sbit P1_5=P1^5;
; sbit P1_6=P1^6;
; sbit P1_7=P1^7;
;
; sbit P2_0=P2^0;
; sbit P2_1=P2^1;
; sbit P2_2=P2^2;
; sbit P2_3=P2^3;
; sbit P2_4=P2^4;
; sbit P2_5=P2^5;
; sbit P2_6=P2^6;
; sbit P2_7=P2^7;
;
;
; void initial(void);
; //初始化子程序
; void delay(short i);
; //延时子程序
; void display(unsigned char i,unsigned char num);
; //显示子程序,其中变量i,num含义为在第i个数码管显示数字num.
; unsigned char keyscan(void);
; //键盘扫描子程序
; void updatee(void);
;
; unsigned char m1=0;
; unsigned char m0=0;
; unsigned char s1=0;
; unsigned char s0=0;
; unsigned char s01=0;
; unsigned char s00=0;
;
; void main(void)
RSEG ?PR?main?SECOND
main:
USING 0
; SOURCE LINE # 98
; {
; SOURCE LINE # 99
; unsigned char status;
; unsigned char keyword;
; initial();
; SOURCE LINE # 102
LCALL initial
; //键盘驱动信号,发光二极管,以及蜂鸣器都设在无效状态
; for(;;)
; SOURCE LINE # 104
?C0001:
; {
; SOURCE LINE # 105
; switch(status)
; SOURCE LINE # 106
MOV A,status?040
DEC A
JZ ?C0009
DEC A
JZ ?C0016
ADD A,#02H
JNZ ?C0001
; {
; SOURCE LINE # 107
; case 0:
; SOURCE LINE # 108
?C0004:
; keyword=keyscan();
; SOURCE LINE # 109
LCALL keyscan
MOV keyword?041,R7
; if(keyword==16)
; SOURCE LINE # 110
MOV A,keyword?041
CJNE A,#010H,?C0005
; {
; SOURCE LINE # 111
; delay(DELAY_VALUE_EXTRA);
; SOURCE LINE # 112
MOV R7,#0CH
MOV R6,#00H
LCALL _delay
; updatee();
; SOURCE LINE # 113
; }
; SOURCE LINE # 114
LJMP ?C0066
?C0005:
; else
; if(keyword==11)status=1; //0状态为计时状态,1状态为停止状态
; SOURCE LINE # 116
MOV A,keyword?041
CJNE A,#0BH,?C0007
SJMP ?C0067
?C0007:
; else
; {
; SOURCE LINE # 118
; PinSpeaker=FALSE;
; SOURCE LINE # 119
; delay(DELAY_VALUE);
; SOURCE LINE # 120
; PinSpeaker=TRUE; //输入有错,蜂鸣器响
; SOURCE LINE # 121
; }
; SOURCE LINE # 122
; break;
; SOURCE LINE # 123
SJMP ?C0068
; case 1:
; SOURCE LINE # 124
?C0009:
; keyword=keyscan();
; SOURCE LINE # 125
LCALL keyscan
MOV keyword?041,R7
; if(keyword==10)status=0; //开始计时,转到0状态;
; SOURCE LINE # 126
MOV A,keyword?041
CJNE A,#0AH,?C0010
SJMP ?C0069
?C0010:
; else if(keyword==12)status=2;//2状态为设置初值状态;
; SOURCE LINE # 127
MOV A,keyword?041
CJNE A,#0CH,?C0012
MOV status?040,#02H
SJMP ?C0001
?C0012:
; else if(keyword==13){s0=0;
; SOURCE LINE # 128
MOV A,keyword?041
CJNE A,#0DH,?C0014
CLR A
MOV s0,A
; s1=0;
; SOURCE LINE # 129
MOV s1,A
; m0=0;
; SOURCE LINE # 130
MOV m0,A
; m1=0;
; SOURCE LINE # 131
MOV m1,A
; s01=0;
; SOURCE LINE # 132
MOV s01,A
; s00=0;}//清零
; SOURCE LINE # 133
MOV s00,A
SJMP ?C0001
?C0014:
; else
; {
; SOURCE LINE # 135
; PinSpeaker=FALSE;
; SOURCE LINE # 136
?C0068:
; delay(DELAY_VALUE);
; SOURCE LINE # 137
LCALL L?0070
; PinSpeaker=TRUE; //输入有错,蜂鸣器响
; SOURCE LINE # 138
SETB P0_1
; }
; SOURCE LINE # 139
; break;
; SOURCE LINE # 140
SJMP ?C0001
; case 2:
; SOURCE LINE # 141
?C0016:
; keyword=keyscan();
; SOURCE LINE # 142
LCALL keyscan
MOV keyword?041,R7
; if(keyword==10&&s1<=5&&m1<=5) //秒表设置正确,则开始计时
; SOURCE LINE # 143
MOV A,keyword?041
CJNE A,#0AH,?C0017
MOV A,s1
SETB C
SUBB A,#05H
JNC ?C0017
MOV A,m1
SUBB A,#05H
JNC ?C0017
; status=0;
; SOURCE LINE # 144
?C0069:
CLR A
MOV status?040,A
SJMP ?C0001
?C0017:
; else if(keyword==11&&s1<=5&&m1<=5)//状态1与2的切换
; SOURCE LINE # 145
MOV A,keyword?041
CJNE A,#0BH,?C0019
MOV A,s1
SETB C
SUBB A,#05H
JNC ?C0019
MOV A,m1
SUBB A,#05H
JNC ?C0019
; status=1;
; SOURCE LINE # 146
?C0067:
MOV status?040,#01H
LJMP ?C0001
?C0019:
; else if(keyword<10&&keyword>=0) //输入的是数字键
; SOURCE LINE # 147
MOV A,keyword?041
CLR C
SUBB A,#0AH
JNC ?C0021
MOV A,keyword?041
CLR C
SUBB A,#00H
JC ?C0021
; {
; SOURCE LINE # 148
; m1=m0;
; SOURCE LINE # 149
MOV m1,m0
; m0=s1;
; SOURCE LINE # 150
MOV m0,s1
; s1=s0;
; SOURCE LINE # 151
MOV s1,s0
; s0=s01;
; SOURCE LINE # 152
MOV s0,s01
; s01=s00;
; SOURCE LINE # 153
MOV s01,s00
; s00=keyword;
; SOURCE LINE # 154
MOV s00,keyword?041
; updatee(); //输入的数字键从低位起往左移
; SOURCE LINE # 155
?C0066:
LCALL updatee
; }
; SOURCE LINE # 156
LJMP ?C0001
?C0021:
; else
; {
; SOURCE LINE # 158
; PinSpeaker=FALSE;
; SOURCE LINE # 159
; delay(DELAY_VALUE);
; SOURCE LINE # 160
LCALL L?0070
; PinSpeaker=TRUE; //输入有错,蜂鸣器响
; SOURCE LINE # 161
SETB P0_1
; }
; SOURCE LINE # 162
; }
; SOURCE LINE # 163
; }
; SOURCE LINE # 164
LJMP ?C0001
; END OF main
;
; }
;
; void initial(void)
RSEG ?PR?initial?SECOND
initial:
; SOURCE LINE # 168
; {
; SOURCE LINE # 169
; P1_0=FALSE;
; SOURCE LINE # 170
CLR P1_0
; P1_1=FALSE;
; SOURCE LINE # 171
CLR P1_1
; P1_2=FALSE;
; SOURCE LINE # 172
CLR P1_2
; P1_3=FALSE; //键盘驱动信号都设为低,避免干扰。
; SOURCE LINE # 173
CLR P1_3
; P0_0=TRUE; //发光二极管设为不亮
; SOURCE LINE # 174
SETB P0_0
; P0_1=TRUE; //蜂鸣器不响
; SOURCE LINE # 175
SETB P0_1
; }
; SOURCE LINE # 176
RET
; END OF initial
;
;
; void delay(short i) //延迟子程序,为精确计时,需要用汇编语言来做。R7刚好存的是i的值
RSEG ?PR?_delay?SECOND
L?0070:
USING 0
L?0071:
CLR P0_1
L?0072:
MOV R7,#03H
MOV R6,#00H
_delay:
; SOURCE LINE # 179
;---- Variable 'i?242' assigned to Register 'R6/R7' ----
; {
; SOURCE LINE # 180
; short ii;
; ii=i;
; SOURCE LINE # 182
MOV ii?243,R6
MOV ii?243+01H,R7
; #pragma asm
; X_delay:
X_delay:
; USING 0
USING 0
; CLR A
CLR A
; MOV R4,A
MOV R4,A
; MOV R5,A
MOV R5,A
; XC0025:
XC0025:
; CLR C
CLR C
; MOV A,R5
MOV A,R5
; SUBB A,R7
SUBB A,R7
; MOV A,R6
MOV A,R6
; XRL A,#080H
XRL A,#080H
; MOV R0,A
MOV R0,A
; MOV A,R4
MOV A,R4
; XRL A,#080H
XRL A,#080H
; SUBB A,R0
SUBB A,R0
; JNC XC0028
JNC XC0028
; INC R5
INC R5
; CJNE R5,#00H,XC0069
CJNE R5,#00H,XC0069
; INC R4
INC R4
; XC0069:
XC0069:
; SJMP XC0025
SJMP XC0025
; XC0028:
XC0028:
; #pragma endasm
; }
; SOURCE LINE # 207
RET
; END OF _delay
;
; void display(unsigned char i,unsigned char num)
RSEG ?PR?_display?SECOND
_display:
; SOURCE LINE # 209
;---- Variable 'num?345' assigned to Register 'R5' ----
;---- Variable 'i?344' assigned to Register 'R7' ----
; {
; SOURCE LINE # 210
; if(num >= 0 && num <=9)
; SOURCE LINE # 211
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -