共2条
1/1 1 跳转至页
51 急求教关于51的,请各位看看我的程序错误在哪里
问
ORG 0000H
AJUMP INBCD
ORG 0013H
AJUMP INT1
ORG 0013H
AJUMP INT2
ORG 0100H
INBCD: MOV P2,#0FFH /输入预订值8421码
MOV P3,#80H
MOV R0,#60H
MOV P2,#7FH
MOV @R0,A
INC R0
MOV P2,#0BFH
MOV A,P2
SWAP A
MOV @R0,A
MOV P2,#DFH
MOV A,P2
XCHD A,@R0
INC R0
MOV P2,#EFH
MOV A,P2
SWAP A
XCH A,@R0
MOV P2,#F7H
MOV A,P2
XCHD A,@R0
ORG 0200H
ADD1:SETB P3.4 /第一次a/d
MOV IP ,#04H
SETB IT1
SETB EX1
SETB EA
CLR P3.4
INT1: PUSH PSW
PUSH A
MOV P1,#0FFH
MOV P3,#64H
MOV R0,#30H
JB P3.6 OVER
JNB P3.5 OVER
MOV @R0,#00H
JUMP1:JB P1.7 LOOP1
SJMP JUMP1
LOOP1:MOV P1,#0FH
MOV @R0,A
INC R0
JUMP2:JB P1.6 LOOP2
SJMP JUMP2
LOOP2:MOV P1,#0FH
MOV @R0,A
ANL A,#0FH
SWAP A
JUMP3: JB P1.5 LOOP3
SJMP JUMP3
LOOP3:MOV P1,#0FH
MOV A,P1
MOV @R0,A
INC R0
JUMP4: JB P1.4 LOOP4
SJMP JUMP4
LOOP4: MOV P1,#0FH
MOV A,P1
ANL A,0FH
SWAP A
MOV @R0,A
JUMP5: JB P3.2 LOOP5
SJMP JUMP5
LOOP5:MOV P1,#0FH
MOV A,P1
XCHD A,@R0
POP A
POP PSW
OVER:SETBP0.3
RET1
ORG 0400H
AJUST1: MOV R2,60H /和预订之比较
MOV A,30H
CLR C
SUBB A,R2
JC ADD2
JNC AJUST12
AJUMP OUT
OUT:SETB P0.3
AJUST11: MOV R2,61H
MOV A,31H
CLR C
SUBB A,R2
JC ADD2
JNC AJUST13
AJUMP OUT
AJUST13; MOV R2,62H
MOV A,32H
CLR C
SUBB A,R2
JC ADD2
AJUMP OUT
ORG 0500H
ADD2: SETB P3.4 /第二次a/d转换
MOV IP,#04H
SETB IT1
SETB EX1
SETB EA
CLR P3.4
INT2: PUSH PSW
PUSH A
MOV P1,#0FFH
MOV P3,#64H
MOV R0,#040H
JB P3.6 OVER
JB P3.5 OVER
MOV @R0,#00H
OVER:SETB P0.3
JUMP21:JB P1.7 LOOP21
AJMP JUMP21
LOOP21:MOV P1,#0FH
MOV @R0,A
INC R0
JMP22:JB P1.6 LOOP22
SJMP JUMP22
LOOP22: MOV P1,#0FH
MOV @R0,A
ANL A,#0FH
SWAP A
JUMP23:JB P1.5 LOOP23
SIMP JUMP23
LOOP23:MOV P1,#0FH
MOV A,P1
MOV @R0,A
INC R0
JUMP24:JB P1.4 LOOP24
SJMP JUMP24
LOOP24:MOV P1,#0FH
MOV A,P1
ANL A,0FH
SWAP A
MOV @R0,A
JUMP25:JB P3.2 LOOP25
SJMP JUMP25
LOOP25:MOV P1,#OFH
MOV A,P1
XCHD A,@R0
POP A
POP PSW
RET1
ORG 0700H
AJUST2: MOV R2,60H / 和预订之比较
MOV A,40H
CLR C
SUBB A,R2
JC SUB
JNC AJUST22
AJMP OUT
OUT:SETB P0.3
AJUST22: MOV R2,61H
MOV A,41H
CLR C
SUBB A,R2
JC SUB
JNC AJUST23
AJMP OUT
AJUST23:MOV R2,62H
MOV A, 42H
CLR C
SUBB A,R2
JC SUB
AJMP OUT
ORG 0800H
SUB: MOV R1,#40H /两次a/d 的差
MOV R0.#30H
CLR C
ACALL BUSUBB
MOV 52H,A
ACALL BUSUBB
MOV 51H,A
ACALL BUSUBB
MOV 50H,A
BUSUBB: MOV A,#9AH
SUBB A,@R0
ADD A,@R1
DA A
INC R0
INC R1
CPL C
RET
ORG 0900H
DIR:MOV SCON #00H /显示差值
CLR ES
CLR T1
MOV R7,#05H
MOV R0,# H
DL0:MOV A,@R0
MOVC A,@A+DPTR
MOV SBUF,A
DL1:
JNB T1,DL1
CLR T1
DEC R0
DJNZ R7,RL0
RET
答 1: 有AJUMP这条指令? 答 2: 出错提示是什么? 答 3: 乱来。你的初始化程序呢?SP在什么地方?INBCD的返回呢?
毛病太多,好好找找!!! 答 4: 还是把指令好好看看再说吧 答 5: 看看别人的吧这也叫编程,程序不是指令的堆砌! 答 6: 写软件先写好注释与描述。
AJUMP INBCD
ORG 0013H
AJUMP INT1
ORG 0013H
AJUMP INT2
ORG 0100H
INBCD: MOV P2,#0FFH /输入预订值8421码
MOV P3,#80H
MOV R0,#60H
MOV P2,#7FH
MOV @R0,A
INC R0
MOV P2,#0BFH
MOV A,P2
SWAP A
MOV @R0,A
MOV P2,#DFH
MOV A,P2
XCHD A,@R0
INC R0
MOV P2,#EFH
MOV A,P2
SWAP A
XCH A,@R0
MOV P2,#F7H
MOV A,P2
XCHD A,@R0
ORG 0200H
ADD1:SETB P3.4 /第一次a/d
MOV IP ,#04H
SETB IT1
SETB EX1
SETB EA
CLR P3.4
INT1: PUSH PSW
PUSH A
MOV P1,#0FFH
MOV P3,#64H
MOV R0,#30H
JB P3.6 OVER
JNB P3.5 OVER
MOV @R0,#00H
JUMP1:JB P1.7 LOOP1
SJMP JUMP1
LOOP1:MOV P1,#0FH
MOV @R0,A
INC R0
JUMP2:JB P1.6 LOOP2
SJMP JUMP2
LOOP2:MOV P1,#0FH
MOV @R0,A
ANL A,#0FH
SWAP A
JUMP3: JB P1.5 LOOP3
SJMP JUMP3
LOOP3:MOV P1,#0FH
MOV A,P1
MOV @R0,A
INC R0
JUMP4: JB P1.4 LOOP4
SJMP JUMP4
LOOP4: MOV P1,#0FH
MOV A,P1
ANL A,0FH
SWAP A
MOV @R0,A
JUMP5: JB P3.2 LOOP5
SJMP JUMP5
LOOP5:MOV P1,#0FH
MOV A,P1
XCHD A,@R0
POP A
POP PSW
OVER:SETBP0.3
RET1
ORG 0400H
AJUST1: MOV R2,60H /和预订之比较
MOV A,30H
CLR C
SUBB A,R2
JC ADD2
JNC AJUST12
AJUMP OUT
OUT:SETB P0.3
AJUST11: MOV R2,61H
MOV A,31H
CLR C
SUBB A,R2
JC ADD2
JNC AJUST13
AJUMP OUT
AJUST13; MOV R2,62H
MOV A,32H
CLR C
SUBB A,R2
JC ADD2
AJUMP OUT
ORG 0500H
ADD2: SETB P3.4 /第二次a/d转换
MOV IP,#04H
SETB IT1
SETB EX1
SETB EA
CLR P3.4
INT2: PUSH PSW
PUSH A
MOV P1,#0FFH
MOV P3,#64H
MOV R0,#040H
JB P3.6 OVER
JB P3.5 OVER
MOV @R0,#00H
OVER:SETB P0.3
JUMP21:JB P1.7 LOOP21
AJMP JUMP21
LOOP21:MOV P1,#0FH
MOV @R0,A
INC R0
JMP22:JB P1.6 LOOP22
SJMP JUMP22
LOOP22: MOV P1,#0FH
MOV @R0,A
ANL A,#0FH
SWAP A
JUMP23:JB P1.5 LOOP23
SIMP JUMP23
LOOP23:MOV P1,#0FH
MOV A,P1
MOV @R0,A
INC R0
JUMP24:JB P1.4 LOOP24
SJMP JUMP24
LOOP24:MOV P1,#0FH
MOV A,P1
ANL A,0FH
SWAP A
MOV @R0,A
JUMP25:JB P3.2 LOOP25
SJMP JUMP25
LOOP25:MOV P1,#OFH
MOV A,P1
XCHD A,@R0
POP A
POP PSW
RET1
ORG 0700H
AJUST2: MOV R2,60H / 和预订之比较
MOV A,40H
CLR C
SUBB A,R2
JC SUB
JNC AJUST22
AJMP OUT
OUT:SETB P0.3
AJUST22: MOV R2,61H
MOV A,41H
CLR C
SUBB A,R2
JC SUB
JNC AJUST23
AJMP OUT
AJUST23:MOV R2,62H
MOV A, 42H
CLR C
SUBB A,R2
JC SUB
AJMP OUT
ORG 0800H
SUB: MOV R1,#40H /两次a/d 的差
MOV R0.#30H
CLR C
ACALL BUSUBB
MOV 52H,A
ACALL BUSUBB
MOV 51H,A
ACALL BUSUBB
MOV 50H,A
BUSUBB: MOV A,#9AH
SUBB A,@R0
ADD A,@R1
DA A
INC R0
INC R1
CPL C
RET
ORG 0900H
DIR:MOV SCON #00H /显示差值
CLR ES
CLR T1
MOV R7,#05H
MOV R0,# H
DL0:MOV A,@R0
MOVC A,@A+DPTR
MOV SBUF,A
DL1:
JNB T1,DL1
CLR T1
DEC R0
DJNZ R7,RL0
RET
答 1: 有AJUMP这条指令? 答 2: 出错提示是什么? 答 3: 乱来。你的初始化程序呢?SP在什么地方?INBCD的返回呢?
毛病太多,好好找找!!! 答 4: 还是把指令好好看看再说吧 答 5: 看看别人的吧这也叫编程,程序不是指令的堆砌! 答 6: 写软件先写好注释与描述。
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 | |
【FRDM-MCXN947评测】核间通信MUTEX被打赏50分 |