- UID
- 1023166
- 性别
- 男
- 来自
- 燕山大学
|
N字节无符号除法程序(集成) ([R0]/R[1])=([R0])汇编
入口 :R0,R1,M,N
;占用资源:ACC,R2,R3,R4,R5,R7,F0
;堆栈需求:2字节
;出口 :R0
NDIVMN :MOV A,M
CLR C
SUBB A,N
MOV B,A
ADD A,R0
MOV R4,A
XCH A,R0
MOV R3,A
MOV A,R1
MOV R5,A
MOV R2,#00H
NDVMN1 :MOV R7,N
CLR C
NDVMN2 :MOV A,@R0
SUBB A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R7,NDVMN2
MOV A,R4
MOV R0,A
MOV A,R5
MOV R1,A
JC NDVMN3
INC R2
SJMP NDVMN1
NDVMN3 :MOV R7,N
CLR C
NDVMN4 :MOV A,@R0
ADDC A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R7,NDVMN4
MOV A,#08H
MUL AB
MOV B,A
NDVMN5 :MOV A,R3
MOV R0,A
MOV R7,M
CLR C
NDVMN6 :MOV A,@R0
RLC A
MOV @R0,A
INC R0
DJNZ R7,NDVMN6
MOV F0,C
MOV A,R4
MOV R0,A
MOV A,R5
MOV R1,A
MOV R7,N
CLR C
NDVMN7 :MOV A,@R0
SUBB A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R7,NDVMN7
JB F0,NDVMNB
JC NDVMN8
NDVMNB :MOV A,R3
MOV R0,A
INC @R0
SJMP NDVMNA
NDVMN8 :MOV R7,N
MOV A,R4
MOV R0,A
MOV A,R5
MOV R1,A
CLR C
NDVMN9 :MOV A,@R0
ADDC A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R7,NDVMN9
NDVMNA JNZ B,NDVMN5
MOV A,M
CLR C
SUBB A,N
ADD A,R3
MOV R1,A
MOV A,R2
MOV @R1,A
MOV A,R3
MOV R0,A
RET |
|