单片机汇编程序.docx
《单片机汇编程序.docx》由会员分享,可在线阅读,更多相关《单片机汇编程序.docx(16页珍藏版)》请在冰豆网上搜索。
单片机汇编程序
流水灯:
ORG0000H
MOVP1,#00H
MOVA,#01H
LJMPGO
ORG0030H
GO:
LCALLDELAY
MOVP1,A
RLA
LJMPGO
DELAY:
MOVR7,#255
D1:
MOVR6,#255
DJNZR6,$
DJNZR7,D1
RET
可控流水灯:
ORG0000H
MOVP1,#00H
MOVA,#01H
LJMPGO1
ORG0030H
GO1:
LCALLDELAY
JNBP3.2,GO2
JNBP3.3,STOP1
MOVP1,A
RLA
LJMPGO1
GO2:
LCALLDELAY
JNBP3.2,GO1
JNBP3.3,STOP2
MOVP1,A
RRA
LJMPGO2
STOP1:
LCALLDELAY
JNBP3.3,GO1
LJMPSTOP1
STOP2:
LCALLDELAY
JNBP3.3,GO2
LJMPSTOP2
可控流水灯+学号移位:
ORG0000H
MOV10H,#7DH
MOV11H,#3FH
MOV12H,#5BH
MOV13H,#3FH
MOVP1,#01H
MOVA,#01H
LJMPGO1
ORG0030H
GO1:
LCALLDELAY
JNBP3.2,GO2
JNBP3.3,STOP1
MOVP1,A
RLA
JBP3.4,GO1
MOV14H,13H
MOV13H,12H
MOV12H,11H
MOV11H,10H
MOV10H,14H
LJMPGO1
GO2:
LCALLDELAY
JNBP3.2,GO1
JNBP3.3,STOP2
MOVP1,A
RRA
JBP3.4,GO2
MOV14H,10H
MOV10H,11H
MOV11H,12H
MOV12H,13H
MOV13H,14H
LJMPGO2
STOP1:
LCALLDELAY
JNBP3.3,GO1
LJMPSTOP1
STOP2:
LCALLDELAY
JNBP3.3,GO2
LJMPSTOP2
DELAY:
MOVR7,#50
D1:
MOVR6,#100
D2:
LCALLNO
DJNZR6,D2
DJNZR7,D1
RET
NO:
MOVP0,#00H
MOVP2,#0FFH
MOVP0,13H
CLRP2.3
MOVP0,#00H
MOVP2,#0FFH
MOVP0,012H
CLRP2.2
MOVP0,#00H
MOVP2,#0FFH
MOVP0,11H
CLRP2.1
MOVP0,#00H
MOVP2,#0FFH
MOVP0,10H
CLRP2.0
RET
学号移位:
ORG0000H
MOV03H,#3FH
MOV02H,#5BH
MOV01H,#3FH
MOV00H,#7DH
LJMPNO
ORG0030H
NO:
MOVP0,#00H
MOVP2,#0FFH
MOVP0,03H
CLRP2.3
MOVP0,#00H
MOVP2,#0FFH
MOVP0,02H
CLRP2.2
MOVP0,#00H
MOVP2,#0FFH
MOVP0,01H
CLRP2.1
MOVP0,#00H
MOVP2,#0FFH
MOVP0,00H
CLRP2.0
JBP3.2,NO
LCALLDELAY
MOV04H,00H
MOV00H,01H
MOV01H,02H
MOV02H,03H
MOV03H,04H
LJMPNO
DELAY:
MOVR7,#255
D1:
MOVR6,#255
DJNZR6,$
DJNZR7,D1
RET
学号加一:
ORG0000H
MOV10H,#6
MOV11H,#0
MOV12H,#2
MOV13H,#0
LJMPJIA
ORG0030H
JIA:
LCALLDELAY
JBP3.2,JIA
INC10H
MOVR0,10H
CJNER0,#10,JIA
MOV10H,#0
INC11H
MOVR0,11H
CJNER0,#10,JIA
MOV11H,#0
INC12H
MOVR0,12H
CJNER0,#10,JIA
MOV12H,#0
INC13H
MOVR0,13H
CJNER0,#10,JIA
MOV13H,#0
LJMPJIA
DELAY:
MOVR7,#255
D1:
MOVR6,#2
D2:
LCALLNO
DJNZR6,D2
DJNZR7,D1
RET
NO:
MOVP0,#00H
MOVP2,#0FFH
MOVA,13H
LCALLDIS
CLRP2.3
MOVP0,#00H
MOVP2,#0FFH
MOVA,12H
LCALLDIS
CLRP2.2
MOVP0,#00H
MOVP2,#0FFH
MOVA,11H
LCALLDIS
CLRP2.1
MOVP0,#00H
MOVP2,#0FFH
MOVA,10H
LCALLDIS
CLRP2.0
RET
DD:
DB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
DIS:
MOVDPTR,#DD
MOVCA,@A+DPTR
MOVP0,A
RET
学号移位(正式):
ORG0000H
MOV03H,#3FH
MOV02H,#5BH
MOV01H,#3FH
MOV00H,#7DH
LJMPGO
ORG0030H
GO:
LCALLDELAY
JBP3.2,GO
MOV04H,00H
MOV00H,01H
MOV01H,02H
MOV02H,03H
MOV03H,04H
LJMPGO
NO:
MOVP0,#00H
MOVP2,#0FFH
MOVP0,03H
CLRP2.3
LCALLDELAY1
MOVP0,#00H
MOVP2,#0FFH
MOVP0,02H
CLRP2.2
LCALLDELAY1
MOVP0,#00H
MOVP2,#0FFH
MOVP0,01H
CLRP2.1
LCALLDELAY1
MOVP0,#00H
MOVP2,#0FFH
MOVP0,00H
CLRP2.0
RET
DELAY:
MOVR7,#255
D1:
MOVR6,#255
D2:
LCALLNO
DJNZR6,$
DJNZR7,D1
RET
DELAY1:
MOVR5,#100
DJNZR5,$
RET
大集合:
ORG0000H
MOV10H,#6
MOV11H,#0
MOV12H,#2
MOV13H,#0
MOVP1,#01H
MOV34H,#01H
LJMPGO1
ORG0030H
GO1:
LCALLDELAY
JNBP3.2,GO2
JNBP3.3,STOP1
MOVA,34H
MOVP1,A
RLA
MOV34H,A
JBP3.4,GO1
MOV14H,13H
MOV13H,12H
MOV12H,11H
MOV11H,10H
MOV10H,14H
LJMPGO1
GO2:
LCALLDELAY
JNBP3.2,GO1
JNBP3.3,STOP2
MOVA,34H
MOVP1,A
RRA
MOV34H,A
JBP3.4,GO2
MOV14H,10H
MOV10H,11H
MOV11H,12H
MOV12H,13H
MOV13H,14H
LJMPGO2
STOP1:
LCALLDELAY
JNBP3.3,GO1
LCALLJIA
LCALLJIAN
LJMPSTOP1
STOP2:
LCALLDELAY
JNBP3.3,GO2
LCALLJIA
LCALLJIAN
LJMPSTOP2
JIA:
JBP3.2,KO1
INC10H
MOVR0,10H
CJNER0,#10,KO1
MOV10H,#0
INC11H
MOVR0,11H
CJNER0,#10,KO1
MOV11H,#0
INC12H
MOVR0,12H
CJNER0,#10,KO1
MOV12H,#0
INC13H
MOVR0,13H
CJNER0,#10,KO1
MOV13H,#0
KO1:
RET
JIAN:
JBP3.4,KO2
DEC10H
MOVR0,10H
CJNER0,#255,KO2
MOV10H,#9
DEC11H
MOVR0,11H
CJNER0,#255,KO2
MOV11H,#9
DEC12H
MOVR0,12H
CJNER0,#255,KO2
MOV12H,#9
DEC13H
MOVR0,13H
CJNER0,#255,KO2
MOV13H,#9
KO2:
RET
DELAY:
MOVR7,#5
D1:
MOVR6,#15
D2:
LCALLNO
DJNZR6,D2
DJNZR7,D1
RET
DELAY0:
MOVR5,5
DJNZR5,$
RET
NO:
MOVP0,#00H
MOVP2,#0FFH
MOVA,13H
LCALLDIS
CLRP2.3
LCALLDELAY0
MOVP0,#00H
MOVP2,#0FFH
MOVA,12H
LCALLDIS
CLRP2.2
LCALLDELAY0
MOVP0,#00H
MOVP2,#0FFH
MOVA,11H
LCALLDIS
CLRP2.1
LCALLDELAY0
MOVP0,#00H
MOVP2,#0FFH
MOVA,10H
LCALLDIS
CLRP2.0
LCALLDELAY0
RET
DD:
DB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
DIS:
MOVDPTR,#DD
MOVCA,@A+DPTR
MOVP0,A
RET