MCS51 三字节无符号除法程序(ASM)
扫描二维码
随时随地手机看文章
;三字节无符号除法程序(R2R3R4/R7)=(R2)R3R4 余数R7
;入口 :R2,R3,R4,R7
;占用资源:ACC,B,F0
;堆栈需求:3字节
;出口 :(R2),R3,R4,R7,OV
NDIV31 :MOV A,R2
MOV B,R7
DIV AB
PUSH A
MOV R2,B
MOV B,#10H
NDV311 :CLR C
MOV A,R4
RLC A
MOV R4,A
MOV A,R3
RLC A
MOV R3,A
MOV A,R2
RLC A
MOV R2,A
MOV F0,C
CLR C
SUBB A,R7
JB F0,NDV312
JC NDV313
NDV312 :MOV R2,A
INC R4
NDV313 :DJNZ B,NDV311
POP A
CLR OV
JZ NDV314
SETB OV
NDV314 :XCH A,R2
MOV R7,A
RET