实验室汇编源程序.docx
- 文档编号:29832821
- 上传时间:2023-07-27
- 格式:DOCX
- 页数:118
- 大小:36.85KB
实验室汇编源程序.docx
《实验室汇编源程序.docx》由会员分享,可在线阅读,更多相关《实验室汇编源程序.docx(118页珍藏版)》请在冰豆网上搜索。
实验室汇编源程序
;====================软件实验四数据区传送子程序=====================
ORG07B0H
MOVR2,00H
MOVR3,#00H
MOVR4,#10H
MOVR5,#00H
MOVR6,#00H
MOVR7,#08H
SE22:
MOVDPL,R3
MOVDPH,R2;建立源程序首址
MOVXA,@DPTR;取数
MOVDPL,R5
MOVDPH,R4;目的地首址
MOVX@DPTR,A;传送
CJNER3,#0FFH,LO42
INCR2
LO42:
INCR3;源地址加1
CJNER5,#0FFH,LO43
INCR4
LO43:
INCR5;目地址加1
CJNER7,#00H,LO44
CJNER6,#00H,LO45;字节数减1
SJMP$
NOP
LO44:
DECR7
SJMPSE22
LO45:
DECR7
DECR6
SJMPSE22;未完继续
END
;==================软件实验一清零程序=============
ORG0640H
SE01:
MOVR0,#00H
MOVDPTR,#2000H;(2000H)送DPTR
LOO1:
MOVX@DPTR,A;0送(DPTR)
INCDPTR;DPTR+1
INCR0;字节数加1
CJNER0,#00H,LOO1;不到FF个字节再清
SJMP$
END
;===================软件实验二拆字程序===========================
ORG0660H
SE02:
MOVDPTR,#2000H
MOVXA,@DPTR
MOVB,A;(2000)→A→B
SWAPA;交换
ANLA,#0FH;屏敝高位
INCDPTR
MOVX@DPTR,A;送2001H
INCDPTR
MOVA,B
ANLA,#0FH;(2000)内容屏敝高位
MOVX@DPTR,A;送2002H
SJMP$
END
;===================软件实验三拼字程序==============================
ORG0680H
SE03:
MOVDPTR,#2000H
MOVXA,@DPTR
ANLA,#0FH;(2000H)内容屏敝高位
SWAPA;交换
MOVB,A;保存
INCDPTR
MOVXA,@DPTR;(2001H)内容送A
ANLA,#0FH;屏敝高位
ORLA,B;或
INCDPTR
MOVX@DPTR,A;送2002H
SJMP$
END
;=======================软件实验五数据排序实验=========================
ORG09B0H
QUE:
MOVR3,#50H
QUE1:
MOVA,R3;指针送R0
MOVR0,A
MOVR7,#0AH;长度送R7
CLR00H;标志位为0
MOVA,@R0
QL2:
INCR0
MOVR2,A
CLRC
MOV22H,@R0
CJNEA,22H,QL3;相等吗?
SETBC
QL3:
MOVA,R2
JCQL1;大于交换位置
SETB00H
XCHA,@R0
DECR0
XCHA,@R0
INCR0;大于交换位置
QL1:
MOVA,@R0
DJNZR7,QL2
JB00H,QUE1;一次循环中有交换继续
SJMP$;无交换退出
END
;====================软件实验六查找相同数个数===========================
ORG0AA0H
L5800:
MOVR0,#10H;查找16个字节
MOVR1,#00H
MOVDPTR,#2000H
L5811:
MOVXA,@DPTR
CJNEA,#00H,L5816;取出内容与00H相等吗?
INCR1;取出个数加1
L5816:
INCDPTR
DJNZR0,L5811;未完继续
MOVDPTR,#2100H
MOVA,R1
MOVX@DPTR,A;相同数个数送2100H
L581E:
SJMPL581E
END
;===================软件实验七无符号双字节快速乘法子程序================
ORG0970H
QKUL:
MOVA,R3
MOVB,R7
MULAB;R3*R7
XCHA,R7;R7=(R3*R7)低字节
MOVR5,B;R5=(R3*R7)高字节
MOVB,R2
MULAB;R2*R7
ADDA,R5
MOVR4,A
CLRA
ADDCA,B
MOVR5,A;R5=(R2*R7)高字节
MOVA,R6
MOVB,R3
MULAB;R3*R6
ADDA,R4
XCHA,R6
XCHA,B
ADDCA,R5
MOVR5,A
MOVPSW.5,C;存CY
MOVA,R2
MULAB;R2*R6
ADDA,R5
MOVR5,A
CLRA
MOVACC.0,C
MOVC,PSW.5;加上次加法的进位
ADDCA,B
MOVR4,A
SJMP$
END
;===================软件实验九脉冲计数(定时/计数器实验)===============
ORG06E0H
SE15:
MOVSP,#53H
MOVTMOD,#05H
MOVTH0,#00H
MOVTL0,#00H;定时计数器初始化
SETBTR0;开计数器
LO29:
MOVR2,TH0
MOVR3,TL0;取出TH0.TL0内容
LCALLZOY0;二转十进制
MOVR0,#79H
MOVA,R6
LCALLPTDS
MOVA,R5
LCALLPTDS
MOVA,R4
LCALLPTDS;送显示缓冲区
LCALLSSEE;显示
SJMPLO29;循环计数.显示
ZOY0:
CLRA
MOVR4,A
MOVR5,A
MOVR6,A;0送R4R5R6
MOVR7,#10H
LO30:
CLRC;R2R3左移.移出的
MOVA,R3;最高位送CY
RLCA
MOVR3,A
MOVA,R2
RLCA
MOVR2,A
MOVA,R6
ADDCA,R6;(R4R5R6)*2+CY送R4R5R6
DAA;十进制调整
MOVR6,A
MOVA,R5
ADDCA,R5
DAA
MOVR5,A
MOVA,R4
ADDCA,R4
DAA
MOVR4,A
DJNZR7,LO30;循环16次
RET
;-----------------------------------------------
PTDS:
MOVR1,A;拆送显示缓冲区
ACALLPTDS1
MOVA,R1
SWAPA
PTDS1:
ANLA,#0FH
MOV@R0,A
INCR0
RET
;--------------------------------------------
SSEE:
SETBRS1;换工作区
MOVR5,#05H
SSE2:
MOV30H,#20H
MOV31H,#7EH
MOVR7,#06H
SSE1:
MOVR1,#0DDH
MOVA,30H
MOVX@R1,A;字位送入
MOVR0,31H
MOVA,@R0
MOVDPTR,#DDFF
MOVCA,@A+DPTR;取字形代码
MOVR1,#0DCH
MOVX@R1,A;字形送入
MOVA,30H;右移
RRA
MOV30H,A
DEC31H
MOVA,#0FFH
MOVX@R1,A;关显示
DJNZR7,SSE1;6位显示完了吗?
DJNZR5,SSE2;5次显示完了吗?
CLRRS1
RET
;--------------------------------------------------------
DDFF:
DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,0DEH
;--------------------------------------------------------
END
;========硬件实验二十一8032串行口实验
(二)实验仪发送,PC机接收=======
;
(1)若在联机状态,请先装载此程序代码至实验系统
;
(2)装载完毕后,退出调试软件,并将实验系统的通信选择开关拨至最左边(8251)并按复位
;(3)从0000H地址开始运行程序,在实验系统键盘上输入:
0000,[EXEC]
;(4)运行“PC接收程序.exe”,选择相关串行口,使用默认2400波特率,按“打开端口”按钮
;(5)在实验系统上按0-F相应字符,“PC接收程序”即作相关字符显示
ORG00B0H
JG832:
MOVSP,#60H
MOV7EH,#08H
MOV7DH,#00H
MOV7CH,#03H
MOV7BH,#02H
MOV7AH,#14H
MOV79H,#01H
MOVPCON,#80H;newadd
MOVSCON,#50H
MOVTMOD,#20H
MOVTL1,#0f3h;#0FDH
MOVTH1,#0f3h;#0FDH
SETBTR1
CLRET1
CLRES
JZX0:
CALLXLE
JBACC.5,JZX0
JBACC.4,JZX0
MOVSBUF,A
NOP
JZX1:
JBCTI,JZX0
SJMPJZX1
SJMPJZX0
;----------------------------
XLE:
ACALLDIS
ACALLKEY
MOVR4,A
MOVR1,#48H
MOVA,@R1
MOVR2,A
INCR1
MOVA,@R1
MOVR3,A
MOVA,R4
XRLA,R3
MOVR3,04H
MOVR4,02H
JZX10
MOVR2,#88H
MOVR4,#88H
X10:
DECR4
MOVA,R4
XRLA,#82H
JZX11
MOVA,R4
XRLA,#0EH
JZX11
MOVA,R4
JZX12
MOVR4,#20H
DECR2
SJMPX13
X12:
MOVR4,#0FH
X11:
MOVR2,04H
NOP
NOP
MOVR4,03H
X13:
MOVR1,#48H
MOVA,R2
MOV@R1,A
INCR1
MOVA,R3
MOV@R1,A
MOVA,R4
JBACC.5,X113
JBACC.4,X113
MOVDPTR,#LS3
MOVCA,@A+DPTR
X113:
RET
;------------------------
LS3:
DB07H,04H,08H,05H,09H,06H,0AH
DB0BH,01H,00H,02H,0FH,03H,0EH
DB0CH,0DH
DIS:
PUSHDPH
PUSHDPL
SETBRS1
MOVR0,#7EH
MOVR2,#20H
MOVR3,#00H
MOVDPTR,#LS0
LS2:
MOVA,@R0
MOVCA,@A+DPTR
MOVR1,#0DCH
MOVX@R1,A
MOVA,R2
incR1
MOVX@R1,A
LS1:
DJNZR3,LS1
CLRC
RRCA
MOVR2,A
DECR0
JNZLS2
movx@r0,a
decr0
cpla
movx@r0,a
CLRRS1
POPDPL
POPDPH
RET
LS0:
DB0C0H,0C6H,0A4H,0B0H,99H,92H
DB82H,0F8H,80H,90H,88H,83H,0C6H
DB0A1H,86H,8EH,0FFH,0CH,89H,7FH,8CH
KEY:
SETBRS1
MOVR2,#0FEH
MOVR3,#08H
MOVR0,#00H
LP1:
MOVR1,#0DDH
MOVA,R2
MOVX@R1,A
RLA
MOVR2,A
incr1
MOVXA,@R1
CPLA
ANLA,#0FH
JNZLP0
INCR0
DJNZR3,LP1
XP33:
MOVA,#20H
XP3:
movr2,a
clra
movr1,#0ddh
movx@r1,a
mova,r2
CLRRS1
RET
;-------------------------
LP0:
CPLA
JBACC.0,XP0
MOVA,#00H
SJMPLPP
XP0:
JBACC.1,XP1
MOVA,#08H
SJMPLPP
XP1:
JBACC.2,XP2
MOVA,#10H
SJMPLPP
XP2:
JBACC.3,XP33
MOVA,#18H
LPP:
ADDA,R0
sjmpxp3
;--------------------------------
LEDP:
MOV50H,#7EH
MOVA,#10H
MOVR0,#79H
LEDS:
MOV@R0,A
INCR0
CJNER0,#7EH,LEDS
INCA
MOV@R0,A
RET
;---------------------------------
END
;=====================D/A(调零程序)=========================
;---D/A0V输出(调基准电压)---
;在进行D/A输出方波、小直流电机实验之前,必须先运行本调零程序!
;装载并连续运行本程序,调节基准电压控制电位器W2,使D/A输出端“AOUT”输出电压为0V
ORG0617h
MOVSP,#53H
MOV7EH,#00H
MOV7DH,#08H
MOV7CH,#03H
MOV7BH,#02H;显示缓冲区初值
LO22:
MOVA,#80H
CALLLO21
SJMPLO22
;---------------------------
PTDS:
MOVR1,A;拆送显示缓冲区
ACALLPTDS1
MOVA,R1
SWAPA
PTDS1:
ANLA,#0FH
MOV@R0,A
INCR0
RET
;-----------------------------
DIS:
PUSHDPH
PUSHDPL
SETBRS1
MOVR0,#7EH
MOVR2,#20H
MOVR3,#00H
MOVDPTR,#LS0
LS2:
MOVA,@R0
MOVCA,@A+DPTR
MOVR1,#0DCH
MOVX@R1,A
MOVA,R2
incR1
MOVX@R1,A
LS1:
DJNZR3,LS1
CLRC
RRCA
MOVR2,A
DECR0
JNZLS2
movx@r0,a
decr0
cpla
movx@r0,a
CLRRS1
POPDPL
POPDPH
RET
;---------------------------------
LO21:
MOVDPTR,#0FFE0H
MOVX@DPTR,A;送0832转换
MOVR0,#79H
LCALLPTDS
MOVR2,#00H
L023:
LCALLDIS;显示
DJNZR2,L023
RET
;----------------------------
LS0:
DB0C0H,0F9H,0A4H,0B0H,99H,92H
DB82H,0F8H,80H,90H,88H,83H,0C6H
DB0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFH
;-------------------------------
END
;======================硬件实验一 P1口亮灯实验=========================
ORG0790H
;----------------------------------------------------------
SE18:
MOVP1,#0FFH;送P1口
LO34:
MOVA,#0FEH;L1发光二极管点亮
LO33:
MOVP1,A
LCALLSE19;延时
RLA;左移位
SJMPLO33;循环
;----------------------------------------------------------
SE19:
MOVR6,#0A0H
LO36:
MOVR7,#0FFH
LO35:
DJNZR7,LO35
DJNZR6,LO36;延时
RET
;----------------------------------------------------------
END
;====================硬件实验二P1口转弯灯实验====================
ORG0C30H
PX00:
MOVP1,#0FFH;初始化
PX03:
MOVA,P1
MOVB,A
ANLA,#03H
CJNEA,#01H,PX01;满足只是P1.0为高条件吗?
JB00H,PX04;闪烁标志位
CLRP1.4
CLRP1.5;开右灯
SETBP1.6
SETBP1.7;关左灯
MOVR2,#20H
LCALLDELY;延时
SETB00H;置标志位
LJMPPX03;继续查状态
PX04:
SETBP1.4
SETBP1.5
SETBP1.6;关灯
SETBP1.7
MOVR2,#20H
LCALLDELY;延时
CLR00H;清标志位
AJMPPX03;继续查状态
PX01:
CJNEA,#02H,PX02;满足只是P1.1为高条件吗?
JB01H,PX05;判标志位
SETBP1.4
SETBP1.5;开左灯
CLRP1.6
CLRP1.7;关右灯
MOVR2,#20H;延时
LCALLDELY
SETB01H;置标志位
LJMPPX03;继续查状态
PX05:
SETBP1.4
SETBP1.5
SETBP1.6;关灯
SETBP1.7
MOVR2,#20H
LCALLDELY;延时
CLR01H;清标志位
LJMPPX03;继续查状态
PX02:
SETBP1.4
SETBP1.5
SETBP1.6;关灯
SETBP1.7
LJMPPX03;继续
;---------------------------------------------
DELY:
PUSH02H
DEL2:
PUSH02H
DEL3:
PUSH02H;延时
DEL4:
DJNZR2,DEL4
POP02H
DJNZR2,DEL3
POP02H
DJNZR2,DEL2
POP02H
DJNZR2,DELY
RET
;--------------------------------------------
END
;===================硬件实验三P3.3口输入,P1口输出=====================
ORG0810H
J100:
MOVA,#00H
J101:
JBP3.3,J101
MOVR2,#20H
LCALLDELY
JBP3.3,J101;P3.3电平为低吗?
J102:
JNBP3.3,J102
MOVR2,#20H
LCALLDELY
JNBP3.3,J102;P3.3电平高吗?
INCA;加1
PUSHACC
CPLA;取反
MOVP1,A;驱动发光二极管
POPACC
AJMPJ101;循环
;---------------------------------------------
DELY:
PUSH02H
DEL2:
PUSH02H
DEL3:
PUSH02H;延时
DEL4:
DJNZR2,DEL4
POP02H
DJNZR2,DEL3
POP02H
DJNZR2,DEL2
POP02H
DJNZR2,DELY
RET
;--------------------------------------------
END
;=====================硬件实验四工业顺序控制========================
ORG0190H
PO10:
MOVP1,#7FH
ORLP3,#00H
PO11:
JNBP3.4,PO11;开工吗?
ORLIE,#84H
ORLIP,#01H
MOVPSW,#00H;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 实验室 汇编 源程序