Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I need instruction about division algorithm in 8051

Status
Not open for further replies.

tri2061990

Newbie level 5
Joined
May 20, 2011
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,366
Code
;INPUT R7.R6 : dividend 16 BIT , R7->high byte, R6->low byte
; B:divisor
;
;OUTPUT : R7.R6 : quotient
; B : remainder

Code:
DIV16TO8     :
	PUSH 02H ;
	PUSH ACC ;
	MOV R2,#16 ; 
	CLR A
DIVIDE     :
	XCH A,R6
	CLR C ; 
	RLC A  ; 
	XCH A,R6 ; 
	XCH A,R7 ; 
	RLC A ; 
	XCH A,R7
	RLC A ; 
	CJNE A,B,NOT_EQUAL ; 
	SJMP A_GREATER_EQ_B 
NOT_EQUAL    :
	JC BELOW ; N: 
A_GREATER_EQ_B:
	SUBB A,B ;Y: 
	XCH A,R6
	ORL A,#1 ;
	XCH A,R6	; 
BELOW     :
	DJNZ R2,DIVIDE ; 
	XCH A,B ; 
	POP ACC
	POP 02H
	RET

I can understand how it work,can you explain it to me?
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top