单片机实验源汇编程序Word文档格式.docx
《单片机实验源汇编程序Word文档格式.docx》由会员分享,可在线阅读,更多相关《单片机实验源汇编程序Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
MOVDPTR,#OUT_PORT
MOVX@DPTR,A
JMPSTART
END
T2
NAMET2
SETBP1.0
SETBP1.1
ANLA,#03H
MOVDPTR,#TAB
MOVCA,@A+DPTR
JMP@A+DPTR
TAB:
DBPRG0-TAB
DBPRG1-TAB
DBPRG2-TAB
DBPRG3-TAB
PRG0:
PRG1:
MOVP1,#0F2H
ACALLDELAY
PRG2:
MOVP1,#0CDH
PRG3:
MOVP1,#00H
MOVR1,#5
MOVR3,#126
DEL3:
DJNZR3,DEL3
END
T3
NAMET3
PORTEQU0CFA0H
MOVA,#11H
ACALLDISP
ACALLDE3S
LLL:
MOVA,#12H
ACALLDE10S
MOVA,#10H
MOVR2,#05H
TTT:
MOVA,#14H
ACALLDE02S
DJNZR2,TTT
MOVA,#11H
MOVA,#21H
MOVA,#01H
GGG:
MOVA,#41H
DJNZR2,GGG
MOVA,#03H
JMPLLL
DE10S:
MOVR5,#100
JMPDE1
DE3S:
MOVR5,#30
DE02S:
MOVR5,#02
DE1:
MOVR6,#200
DE2:
MOVR7,#126
DE3:
DJNZR7,DE3
DJNZR6,DE2
DJNZR5,DE1
DISP:
MOVDPTR,#PORT
CPLA
T4
NAMET4
INPORTEQU0CFA8H
OUTPORTEQU0CFB0H
MOVDPTR,#INPORT
MOVXA,@DPTR
MOVDPTR,#OUTPORT
MOVR7,#10H
DEL0:
MOVR6,#0FFH
DJNZR6,DEL1
DJNZR7,DEL0
T5
NAMET5
SAVEEQU55H
CSEGAT4003H
LJMPINT
SETBIT0
SETBEX0
SETBEA
MOVSAVE,A
INT:
CLREA
PUSHACC
PUSHPSW
MOVA,R5
DEL10S:
MOVR3,#100
MOVR4,#200
MOVR5,#126
DJNZR5,DEL3
DJNZR4,DEL2
DJNZR3,DEL1
MOVA,SAVE
POPACC
MOVR5,A
POPPSW
RETI
T6
NAMET6
CSEGAT401BH
MOVR1,#03H
MOVR0,#5H
MOVTMOD,#10H
MOVTL1,#0AFH
MOVTH1,#03CH
ORLIE,#88H
SETBTR1
LOOP1:
CJNER0,#00,DISP
INCR1
CJNER1,#31H,LOOP2
LOOP2:
MOVA,R1
MOVCA,@A+PC
JMPDISP
DB01H,03H,07H,0FH,1FH,3FH,7FH,0FFH,0FEH,0FCH
DB0F8H,0F0H,0E0H,0C0H,80H,00H,0FFH,00H,0FEH
DB0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH,0BFH,0DFH
DB0EFH,0F7H,0FBH,0FDH,0FEH,00H,0FFH,00H
JMPLOOP1
CLRTR1
DECR0
T7
NAMET7
PAEQU0CFA0H
PBEQU0CFA1H
PCTLEQU0CFA3H
MOVDPTR,#PCTL
MOVA,#82H
MOVDPTR,#PB
MOVDPTR,#PA
T8
NAMEt8;
8255键盘实验
PAEQU0CFA0H
PBEQUPA+1
PC0EQUPB+1
PCTLEQUPC0+1
CSEGAT4000H
CSEGAT4100H
START:
MOV42H,#0FFH;
42H中放显示的字符码,初值为0FFH
STA1:
MOVDPTR,#PCTL;
设置控制字,ABC口工作于方式0
;
AC口输出而B口用于输入
LINE:
MOVDPTR,#PC0;
将字符码从C口输出显示
MOVA,42H
MOVDPTR,#PA;
从A口输出全零到键盘的列线
MOVDPTR,#PB;
从B口读入键盘行线值
MOV40H,A;
行线值存于40H中
CPLA;
取反后如为全零
表示没有键闭合,继续扫描
JZLINE
MOVR7,#10H;
有键按下,延时10MS去抖动
DL0:
DL1:
DJNZR6,DL1
DJNZR7,DL0
重置控制字,让A为输入,BC为输出
MOVA,#90H
MOVA,40H
刚才读入的行线值取出从B口送出
从A口读入列线值
MOV41H,A;
列线值存于41H中
JZSTA1;
表示没有键按下
MOVDPTR,#TABLE;
TABLE表首地址送DPTR
MOVR7,#18H;
R7中置计数值16
MOVR6,#00H;
R6中放偏移量初值
TT:
MOVXA,@DPTR;
从表中取键码前半段字节,行线值与实
CJNEA,40H,NN1;
际输入的行线值相等吗?
不等转NN1
INCDPTR;
相等,指针指向后半字节,即列线值
列线值与实际输入的列线值
CJNEA,41H,NN2;
相等吗?
不等转NN2
MOVDPTR,#CHAR;
相等,CHAR表基址和R6中的偏移量
MOVA,R6;
取出相应的字符码
MOV42H,A;
字符码存于42H
BBB:
重置控制字,让AC为输出,B为输入
AAA:
MOVA,42H;
将字符码从C口送到二极管显示
MOVDPTR,#PC0
判断按下的键是否释放
CLRA
JNZAAA;
没释放转AAA
MOVR5,#2;
已释放则延时0.2秒,减少总线负担
DEL1:
DEL2:
DEL3:
DJNZR5,DEL1
JMPSTART;
转START
NN1:
指针指向后半字节即列线值
NN2:
指针指向下一键码前半字节即行线值
INCR6;
CHAR表偏移量加一
DJNZR7,TT;
计数值减一,不为零则转TT继续查找
JMPBBB
TABLE:
DW0FE06H,0FD06H,0FB06H,0F706H;
TABLE为键值表,每个键位占
DW0BF06H,07F06H,0FE05H,0FD05H;
两个字节,第一个字节为行
DW0EF05H,0DF05H,0BF05H,07F05H;
线值,第二个为列线值
DW0FB03H,0F703H,0EF03H,0DF03H;
CHAR:
DB00H,01H,02H,03H,04H,05H,06H,07H,08H,09H;
字符码表
DB0AH,0BH,0CH,0DH,0EH,0FH,10H,11H,12H,13H
DB14H,15H,16H,17H