MCS51 三字節(jié)無符號除法程序(ASM)
;三字節(jié)無符號除法程序(R2R3R4/R7)=(R2)R3R4 余數(shù)R7
;入口 :R2,R3,R4,R7
;占用資源:ACC,B,F0
;堆棧需求:3字節(jié)
;出口 :(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