51单片机---多字节除法---汇编程序

2024-12-02 10:58:46
推荐回答(2个)
回答(1):

不会,应根据进位标志来处理

回答(2):

WAVE6000验证通过

R5R4R3/R2R1

BUF1 EQU 2000H
BUF2 EQU 3000H

ORG 00H
AJMP _INIT_SYS

_INIT_SYS:
MOV SP,#80H

; R5R4R3/R2R1 = R4R3

MOV R1,#00H
MOV R2,#0FH

MOV R3,#04H
MOV R4,#05H
MOV R5,#06H
LCALL _DIV

AJMP $

_DIV: ;{
CLR C
MOV 30H,#0
MOV 31H,#0
MOV 32H,#0

_DIV_LOOP:
CLR C
MOV A,R3
SUBB A,R1
MOV R3,A
MOV A,R4
SUBB A,R2
MOV R4,A
MOV A,R5
SUBB A,#0
MOV R5,A
JC _DIV_END
_INC_SHANG:
CLR C
MOV A,30H
ADDC A,#1
MOV 30H,A
MOV A,31H
ADDC A,#0
MOV 31H,A
MOV A,32H
ADDC A,#0
MOV 32H,A
LJMP _DIV_LOOP

_DIV_END:
CLR C
MOV A,R1
ADDC A,R3
MOV A,R2
ADDC A,R4

MOV R3,30H
MOV R4,31H

RET