- 再也不做稀饭了
-
从键盘输入时间初始值后,用固定时间产生0.1s定时中断,触发时钟记数器记数,并将数值实时送显示器显示。
ORG 0030H
CHK00: MOV SP,#60H
LCALL LEDP
MOV DPTR,#CLOCK
MOV R0,DPL
MOV R1,DPH
MOV DPTR,#000BH
MOV A,#02H
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
INC DPTR
MOV A,R0
MOVX @DPTR,A
LCK0: LCALL LCK0
LCALL PTDS0
MOV TMOD,#01H
ORL IE,#82H
MOV TL0,#0B7H
MOV TH0,#3CH
MOV 23H,#00H
SETB TR0
L005: LCALL DIS
LCALL PTDS0
SJMP L005
PTDS0: MOV R0,#79H
MOV A,22H
ACALL PTDS
MOV A,21H
ACALL PTDS
MOV A,20H
ACALL PTDS
RET
PTDS: MOV R1,A
ACALL PTDS1
MOV A,R1
SWAP A
PTDS1: ANL A,#0FH
MOV @R0,A
INC R0
RET
LOCK: MOV TL0,#0B7H
MOV TH0,#3CH
PUSH PSW
PUSH ACC
SETB 0D3H
INC 23H
MOV A,23H
CJNE A,#0AH,DONE
MOV 23H,#00H
MOV A,22H
INC A
DA A
MOV 22H,A
CJNE A,#60H,DONE
MOV 22H,#00H
MOV A,21H
INC A
DA A
MOV 21H,A
CJNE A,#60H,DONE
MOV 21H,#00H
MOV A,20H
INC A
DA A
MOV 20H,A
CJNE A,#24H,DONE
MOV 20H,#00H
DONE: POP ACC
POP PSW
RETI
ORG 0D59H
SSEE: SETB RS1
MOV R5,#05H
SSE2: MOV 30H,#20H
MOV 31H,#7EH
MOV R7,#06H
SSE1: MOV R1,#0DDH
MOV A,30H
MOVX @R1,A
MOV R0,31H
MOV A,@R0
MOV DPTR,#0DDFFH
MOVC A,@A+DPTR
MOV R1,#0DCH
MOVX @R1,A
MOV A,30H
RR A
MOV 30H,A
DEC 31H
MOV A,#0FFH
MOVX @R1,A
DJNZ R7,SSE1
DJNZ R5,SSE2
CLR RS1
RET
DDFF: DB 0C0H,0F9H,0A4H,0B0H,99H,92H
DB 82H,0F8H,80H,90H,0F8H,80H,90H
DB 88H,83H,bC6H,0A1H,86H,8EH
DB 0FFH,0CH,89H,0DEH
ORG 038EH
X3: MOV R4,A
MOV R0,#50H
MOV A,@R0
MOV R1,A
MOV A,R4
MOV @R1,A
CLR A
POP DPH
POP DPL
MOVC A,@A+DPTR
INC DPTR
CJNE A,01H,X30
DEC R1
CLR A
MOVC A,@A+DPTR
X31: MOV @R0,A
INC DPTR
PUSH DPL
PUSH DPH
RET
X30: DEC R1
MOV A,R1
SJMP X31
X2: MOV R6,#50H
X0: ACALL XLE
JNB ACC,5,XX0
DJNZ R6,X0
MOV R6,#20H
MOV R0,#50H
MOV A,@R0
MOV R0,A
MOV A,@R0
MOV R7,A
MOV A,#10H
MOV @R0,A
X1: ACALL XLE
JNB ACC,5,XX1
DJNZ R6,X1
MOV A,R7
MOV @R0,A
SJMP X2
XX1: MOV R6,A
MOV A,R7
MOV @R0,A
MOV A,R6
XX0: RET
XLE: ACALL DIS
ACALL KEY
MOV R4,A
MOV R1,#48H
MOV A,@R1
MOV R2,A
INC R1
MOV A,@R1
MOV R3,A
MOV A,R4
XRL A,R3
MOV R3,04H
MOV R4,02H
JZ X10
MOV R2,#88H
MOV R4,#88H
X10: DEC R4
MOV A,R4
XRL A,#82H
JZ X11
MOV A,R4
XRL A,#0EH
JZ X11
MOV A,R4
JZ X12
MOV R4,#20H
DEC R2
SJMP X13
X12: MOV R4,#0FH
X11: MOV R2,04H
MOV R4,03H
X13: MOV R1,#48H
MOV A,R2
MOV @R1,A
INC R1
MOV A,R3
MOV @R1,A
MOV A,R4
JB ACC,5,X113
JB ACC,4,X113
MOV DPTR,#LS3
MOVC A,@A十DPTR
X113: RET
LS3: DB 07H,04H,08H,05H,09H,06H,0AH
DB 0BH,01H,00H,02H,0FH,03H,0EH
DB 0CH,0DH
DIS: PUSH DPH
PUSH DPL
SETB RS1
MOV R0,#7EH
MOV R2,#20H
MOV R3,#00H
MOV DPTR,#LS0 ,
LS2: MOVA,@R0
MOVC A,@A+DPTR
MOV R1,#0DCH
MOVX @R1,A
MOV A,R2
INC R1
MOVX @R1,A
LS1: DJNZ R3,LS1
CLR C
RRC A
MOV R2,A
DEC R0
JNZ LS2
MOVX @R0,A
DEC R0
CPL A
MOVX @R0,A
CLR RS1
POP DPL
POP DPH
RET
LS0: DB 0C0H,0F9H,0A4H,0B0H,99H,92H
DB 82H,0F8H,80H,90H,88H,83H,0C6H
DB 0A1H,86H,8EH,0FFH,0CH,89H
DB 7FH,0BFH
KEY: SETB RS1
MOV R2,#0FEH
MOV R3,#08H
MOV R0,#00H
LP1: MOV R1,#0DDH
MOV A,R2
MOVX @R1,A
RL A
MOV R2,A
INC R1
MOVX A,@R1
CPL A
ANL A,#0FH
JNZ LP0
INC R0
DJNZ R3,LP1
XP33: MOV A,#20H
XP3: MOV R2,A
CLR A
MOV R1,#0DDH
MOVX @R1,A
MOV A,R2
CLR RS1
RET
LP0: CPL A
JB ACC.0,XP0
MOV A,#00H
SJMP LPP
XP0: JB ACC.1,XP1
MOV A,#08H
SJMP LPP
XP1: JB ACC,2,XP2
MOV A,#10H
SJMP LPP
XP2: JB ACC.3,XP33
MOV A,#18H
LPP: ADD A,R0
SMP XP3
LEDP: MOV 50H,#7EH
MOV A,#10H
MOV R0,#79H
1EDS: MOV @R0,A
INC R0
CJNE R0,#7EH,1EDS
INC A
MOV @R0,A
MOV A,#20H
MOV 48H,A
MOV 49H,A
RET
END
- 牛云
-
assume cs:codesg
data segment
db "1975","1976","1977","1978","1979","1980","1981","1982","1983"
db "1984","1985","1986","1987","1988","1989","1990","1991","1992"
db "1993","1994","1995"
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
dw 11542,14430,15257,17800
data ends //原公司数据
table segment
db 16 dup(0)
table ends //定义16字节数据空间用于暂存对公司数据的相关转换
codesg segment
start:mov ax,data
mov es,ax //设原数据在es段
mov ax,table
mov ds,ax //设转换为要显示在屏幕上的数据的空间为数据段
mov dh,3
mov dl,10 //初始化在3行10列显示第一个数据
mov di,0 //读取双字单元数据的变址
mov si,0 //要显示的数据偏移地址的首地址
mov bp,0 //读取字单元数据的变址
call clear //调用清屏子程序,先清空屏幕
mov cx,21 //程序下面将循环21次,每次显示公司一条记录
main:push cx
mov cl, //显示在屏幕上字符的颜色
mov ax,es:[di]
mov ds:[0],ax
mov ax,es:2[di]
mov ds:[2],ax
call show_str //以上实现年份的字段的显示
add dl,15 //列数增加15,拉开距离,以便显示下一字段
push dx
mov ax,es:84[di]
mov dx,es:86[di]
call dtoc
pop dx
call show_str //以上实现总收入字段的显示
add dl,15 //同上,改变列的显示位置
push dx
mov ax,es:168[bp]
mov dx,0
call dtoc
pop dx
call show_str //以上实现雇员数字段的显示
add dl,15 //同上,改变列的显示位置
push dx
mov ax,es:84[di]
mov dx,es:86[di]
mov bx,es:168[bp]
div bx
mov dx,0
call dtoc
pop dx
call show_str //以上实现人平收入字段的显示
add bp,2
add di,4
inc dh //行数加1,实现换行准备显示下一条记录
mov dl,10 //重设列数为10,准备显示下一条记录,并对齐上一条
pop cx
loop main //返回main,去显示下一条记录
mov ax,4c00h
int 21h
dtoc:push ax //以下是双字型转十进制字符串的子程序
push bx
push cx
push dx
push si
push di
mov bx,0
push bx
mov di,1
s:mov cx,10
call divdw
mov bx,cx
mov cx,ax
add bl,30h
push bx
inc di
jcxz oka
jmp short s
oka:mov cx,dx
jcxz ok
jmp short s
ok:mov cx,di
oo:pop [si]
inc si
loop oo
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
show_str:push ax //以下是字符串显示的子程序
push bx
push cx
push dx
push es
push si
mov ax,0b800h
mov es,ax
mov al,160
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
mov ch,0
s1:push cx
mov cl,[si]
jcxz ok1
mov es:[bx],cl
pop cx
mov es:[bx+1],cl
inc si
add bx,2
jmp short s1
ok1:pop cx
pop si
pop es
pop dx
pop cx
pop bx
pop ax
ret
divdw:push bx //以下是防除法溢出子程序
mov bx,ax
mov ax,dx
mov dx,0
div cx
push ax
mov ax,bx
div cx
mov cx,dx
pop dx
pop bx
ret
clear:push ax //以下是清空屏幕的子程序
push es
push bx
push cx
mov ax,0b800h
mov es,ax
mov bx,0
mov cx,2000
cls:mov word ptr es:[bx],0720h
add bx,2
loop cls
pop cx
pop bx
pop es
pop ax
ret
codesg ends //代码结束
end start //OK!大功告成...
- 慧慧
-
键盘加led显示的程序
dis_data data 40h ;显示数据首地址
key_hold bit 20h.0
ORG 0000H
JMP START
ORG 0100H
START:
MOV SP,#60H
MOV dis_data,#00H
MOV dis_data+1,#01H
MOV dis_data+2,#02H
MOV dis_data+3,#03H ;显示数据初始化
;主程序
MAIN:
CALL DISPLAY
CALL KEY_WORK
JMP MAIN
;-------------------------显示子程序---------------------------
DISPLAY:
MOV R2,#0FEH
MOV R1,#dis_data
DIS0:
MOV A,@R1
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P1,A
INC R1
MOV P0,R2
MOV A,R2
RL A
MOV R2,A
CALL DELAY ;调延时子程序
CJNE R1,#44H,DIS0
RET
;-------------------------延时子程序---------------------------
DELAY: MOV R7,#02H
DL: MOV R6,#0FFH
DL6: DJNZ R6,DL6
DJNZ R7,DL
RET
;-----------------------------------------------------------
KEY_WORK:
PUSH ACC
PUSH PSW
KEY_SCAN:
MOV P2,#0FFH
MOV A,P2
CJNE A,#0FFH,KEYHIT0
CLR key_hold ;键释放
JMP RETT
KEYHIT0:
CALL DL10MS ;防抖动
MOV P2,#0FFH
MOV A,P2
CJNE A,#0FFH,KEYHIT1
CLR key_hold ;键释放
JMP RETT
KEYHIT1:
JB key_hold,RETT ;键未释放,返回
SETB key_hold ;新键按下
JNB ACC.0,KEY0HIT
JNB ACC.1,KEY1HIT
JNB ACC.2,KEY2HIT
JNB ACC.3,KEY3HIT
JNB ACC.4,KEY4HIT
JNB ACC.5,KEY5HIT
JNB ACC.6,KEY6HIT
JNB ACC.7,KEY7HIT
JMP RETT
KEY0HIT: ;键1按下
INC dis_data
MOV A,#0AH
CJNE A,dis_data,RETT
MOV dis_data,#00H
JMP RETT
KEY1HIT: ;键2按下
INC dis_data+1
MOV A,#0AH
CJNE A,dis_data+1,RETT
MOV dis_data+1,#00H
JMP RETT
KEY2HIT: ;键3按下
INC dis_data+2
MOV A,#0AH
CJNE A,dis_data+2,RETT
MOV dis_data+2,#00H
JMP RETT
KEY3HIT: ;键4按下
INC dis_data+3
MOV A,#0AH
CJNE A,dis_data+3,RETT
MOV dis_data+3,#00H
KEY4HIT:
DEC dis_data ;键5按下
MOV A,#0ffh
CJNE A,dis_data,RETT
MOV dis_data,#09H
JMP RETT
KEY5HIT:
DEC dis_data+1 ;键6按下
MOV A,#0ffh
CJNE A,dis_data+1,RETT
MOV dis_data+1,#09H
JMP RETT
KEY6HIT:
DEC dis_data+2 ;键7按下
MOV A,#0ffh
CJNE A,dis_data+2,RETT
MOV dis_data+2,#09H
JMP RETT
KEY7HIT:
DEC dis_data+3 ;键8按下
MOV A,#0ffh
CJNE A,dis_data+3,RETT
MOV dis_data+3,#09H
RETT:
POP ACC
POP PSW
RET
;*********************
;键盘仿抖延时延时
;*********************
DL10MS:
MOV R4,#20
DELMS:
CALL DISPLAY
DJNZ R4,DELMS
RET
;将延时程序换成下面的程序看看会有什么样的变化,为什么?
DL10MS11:
MOV R4,#100
DEL11:
MOV R5,#250
NOP
NOP
DJNZ R5,$
DJNZ R4,DEL11
RET
;-------------------------LED显示码表--------------------------
TAB: DB 0c0H, 0f9H, 0a4H, 0b0H, 99H, 92H
; 0 1 2 3 4 5
; 00H 01H 02H 03H 04H 05H
;
DB 82H, 0f8H, 80H, 90H, 88H, 83H
; 6 7 8 9 A b
; 7DH 07H 08H 09H 0AH 0BH
;
DB 0c6H, 0a1H, 86H, 8eH, 8cH, 0c1H
; C D E F P U
; 0CH 0DH 0EH 0FH 10H 11H
;
DB 89H, 0c7H,0bfH, 91H,00H,0ffH
; H L - y ON OFF
; 12H 13H 14H 15H 16H 17H
;
DB 92H, 77H, 8bH, 0afH, 0a3H, 0a1H
; S t h r o d
; 18H 19H 1AH 1BH 1CH 1DH
;
DB 0f0H, 0FH, 8bH, 0afH, 0a3H, 0a1H
; S t h r o d
; 1EH 1FH 20H 21H 22H 23H
END
- ardim
-
已发送。
- wpBeta
-
发到你的邮箱了,,看看合适不合适……
- snjk
-
已发