意法半导体(中国)投资有限公司
2020-01-15 广告
2020-01-15 广告
单片机(Microcontrollers)是一种集成电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU、随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计数器等功能(可能还包括显示驱动电路、脉宽调制...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
展开全部
下面的例子是一个多字节除法运算:
DODIV:
MOV A,R0
MOV R4, A
MOV A, R1
MOV R5, A
MOV A, R3
MOV R7, A
MOV A, R0
ADD A, R3
MOV R6,A
MOV R1, A
LP0:
MOV @R1,#00H
INC R1
DJNZ R3, LP0
MOV A,R7
ADD A, R7
MOV R2, A
MOV B, #04H
MUL AB
LP1:
PUSH A
MOV A, R2
MOV R3, A
MOV A, R4
MOV R1, A
CLR C
LP2:
MOV A,@R1
RLC A
MOV @R1, A
INC R1
DJNZ R3, LP2
NEXT:
MOV A, R6
MOV R0, A
MOV A, R5
MOV R1, A
MOV A, R7
MOV R3, A
CLR C
LP3:
MOV A,@R0
SUBB A,@R1
PUSH A
INC R0
INC R1
DJNZ R3, LP3
MOV A, R7
MOV R3, A
JC SMALL
MOV A, R4
MOV R0, A
INC @R0
MOV A, R6
ADD A, R7
DEC A
MOV R0, A
LP4:
POP A
MOV @R0, A
DEC R0
DJNZ R3, LP4
SJMP NEXT
SMALL:
POP A
DJNZ R3, SMALL
POP A
DEC A
JNZ LP1
I504:
MOV A,R6
ADD A, R7
DEC A
MOV R0, A
MOV R2, A
MOV A,@R0
JB E7H, ADD1
MOV A, R6
MOV R1, A
MOV A, R7
MOV R3, A
CLR C
LP5:
MOV A,@R1
RLC A
MOV @R1, A
INC R1
DJNZ R3, LP5
MOV A, R2
MOV R0, A
MOV A, R7
MOV R3, A
ADD A, R5
DEC A
MOV R1, A
LP6:
CLR C
MOV A,@R0
SUBB A,@R1
JC RETURN
JNZ ADD1
DEC R0
DEC
DJNZ R3, LP6
ADD1:
MOV A,R4
MOV R1, A
MOV A, R7
MOV R3, A
SETB C
LP7l:
MOV A,@R1
ADDC A, #00H
MOV @R1, A
DJNZ R3, LP7
RETURN:
MOV A,R4
MOV R0, A
MOV A, R7
MOV R3, A
RET
DODIV:
MOV A,R0
MOV R4, A
MOV A, R1
MOV R5, A
MOV A, R3
MOV R7, A
MOV A, R0
ADD A, R3
MOV R6,A
MOV R1, A
LP0:
MOV @R1,#00H
INC R1
DJNZ R3, LP0
MOV A,R7
ADD A, R7
MOV R2, A
MOV B, #04H
MUL AB
LP1:
PUSH A
MOV A, R2
MOV R3, A
MOV A, R4
MOV R1, A
CLR C
LP2:
MOV A,@R1
RLC A
MOV @R1, A
INC R1
DJNZ R3, LP2
NEXT:
MOV A, R6
MOV R0, A
MOV A, R5
MOV R1, A
MOV A, R7
MOV R3, A
CLR C
LP3:
MOV A,@R0
SUBB A,@R1
PUSH A
INC R0
INC R1
DJNZ R3, LP3
MOV A, R7
MOV R3, A
JC SMALL
MOV A, R4
MOV R0, A
INC @R0
MOV A, R6
ADD A, R7
DEC A
MOV R0, A
LP4:
POP A
MOV @R0, A
DEC R0
DJNZ R3, LP4
SJMP NEXT
SMALL:
POP A
DJNZ R3, SMALL
POP A
DEC A
JNZ LP1
I504:
MOV A,R6
ADD A, R7
DEC A
MOV R0, A
MOV R2, A
MOV A,@R0
JB E7H, ADD1
MOV A, R6
MOV R1, A
MOV A, R7
MOV R3, A
CLR C
LP5:
MOV A,@R1
RLC A
MOV @R1, A
INC R1
DJNZ R3, LP5
MOV A, R2
MOV R0, A
MOV A, R7
MOV R3, A
ADD A, R5
DEC A
MOV R1, A
LP6:
CLR C
MOV A,@R0
SUBB A,@R1
JC RETURN
JNZ ADD1
DEC R0
DEC
DJNZ R3, LP6
ADD1:
MOV A,R4
MOV R1, A
MOV A, R7
MOV R3, A
SETB C
LP7l:
MOV A,@R1
ADDC A, #00H
MOV @R1, A
DJNZ R3, LP7
RETURN:
MOV A,R4
MOV R0, A
MOV A, R7
MOV R3, A
RET
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询