设计一个秒表,需要考虑以下因素:
1、因为视觉暂留的因素,一般而言到0.1秒的精度就可以了。
2、需要有按键控制启动、停止、清零这些功能。
KEYVAL EQU 30H
DAT EQU 33H
SCANLED EQU 39H
CLK EQU 77H
SEC EQU 78H
SEC1 EQU 79H
SEC2 EQU 7AH
DOT BIT 00H
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP EXTINT0
ORG 000BH
LJMP T0ISR 50ms定时
ORG 001BH
LJMP T1ISR 扫描显示
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#11H
MOV TH0,#03CH
MOV TL0,#0B0H
MOV TH1,#0ECH
MOV TL1,#078H
MOV KEYVAL,#2
MOV 33H,#10H
MOV 34H,#10H
MOV 35H,#10H
MOV 36H,#10H
MOV CLK,#0
SETB IT0
SETB EX0
CLR TR0
CLR ET0
MOV R2,#0
SETB TR1
SETB ET1
SETB EA
LOOP:
MOV A,KEYVAL
LOOP1:
JNZ LOOP2 启动
SETB TR0
SETB ET0
SJMP LOOP
LOOP2:
DEC A
JNZ LOOP3 暂停
CLR TR0
CLR ET0
SJMP LOOP
LOOP3:
DEC A
JNZ LOOP 清零
MOV 36H,#0
MOV 35H,#0
MOV 34H,#0
MOV 33H,#0
SJMP LOOP
EXTINT0:
PUSH ACC
INC KEYVAL
MOV A,KEYVAL
CJNE A,#3,EXT00
EXT00:
JC EXT01
MOV KEYVAL,#0
EXT01:
POP ACC
RETI
T0ISR:
PUSH ACC
CLR TR0
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0
INC CLK
MOV A,CLK
CJNE A,#2,T0ISRE
MOV CLK,#0
INC 36H
MOV A,36H
CJNE A,#10,T0ISRE
MOV 36H,#0
INC 35H
MOV A,35H
CJNE A,#10,T0ISRE
MOV 35H,#0
INC 34H
MOV A,34H
CJNE A,#6,T0ISRE
MOV 34H,#0
INC 33H
MOV A,33H
CJNE A,#10,T0ISRE
MOV 33H,#0
T0ISRE:
POP ACC
RETI
T1ISR:
PUSH ACC
CLR TR1
MOV TH1,#0ECH
MOV TL1,#78H
SETB TR1
MOV DPTR,#LEDTAB
T100:
MOV R0,#DAT
MOV A,SCANLED
ADD A,R0
MOV R0,A
MOV A,SCANLED
JNZ T101
MOV P2,#01H
SETB DOT
SJMP T1DIS
T101:
DEC A
JNZ T102
MOV P2,#02H
CLR DOT
SJMP T1DIS
T102:
DEC A
JNZ T103
MOV P2,#04H
SETB DOT
SJMP T1DIS
T103:
MOV P2,#08H
CLR DOT
T1DIS:
MOV A,@R0
MOVC A,@A+DPTR
JNB DOT,T1DIS1
ORL A,#01H
T1DIS1:
CPL A
MOV P0,A
INC SCANLED
MOV A,SCANLED
CJNE A,#4,T1END
MOV SCANLED,#0
T1END:
POP ACC
RETI
LEDTAB: DB 0FCH "0" 00H
DB 60H "1" 01H
DB 0DAH "2" 02H
DB 0F2H "3" 03H
DB 66H "4" 04H
DB 0B6H "5" 05H
DB 0BEH "6" 06H
DB 0E0H "7" 07H
DB 0FEH "8" 08H
DB 0F6H "9" 09H
DB 0EEH "A" 0AH
DB 3EH "B" 0BH
DB 9CH "C" 0CH
DB 7AH "D" 0DH
DB 9EH "E" 0EH
DB 8EH "F" 0FH
DB 00H " " 10H
END
将表jsb1的所有工号以“E”开头的记录追加到表JSB2中:use jsb2
append from jsb1 for 工号='E' &&如果“工号”的字段名真的是“工号”的话
筛选显示出姓为“王”的命令:
use jsb2&&具体要打开什么表,视乎你要筛选哪个表
browse for 姓名='王' &&这里的“姓名”要看你存放姓名或姓的字段名而定