Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/11/02 08:38
Read: times


 
#34205 - help me with division-here it is rahman.
Dear Rahman,
I am presenting with a code for 32bit by 32bit division here.I did this long back when i was new to 8051 so there are not much comments. I think this should be helful to u.

good luck,
-sathish.

;*********************************************************************************
;MODULE : 24 BIT BY 24 BIT DIVISION SUBROUTINE ;
;AUTHOR : SATHISH KUMAR T S ;
;***********************************************;
;INPUTS ;
; DIVIDEND : QregHH,QregH,Qregm,Qregl ;
; DIVISOR : MregHH,MregH,Mregm,Mregl ;
; ;
;OUTPUTS ;
; QUOTIENT : QregHH,QregH,Qregm,Qregl ;
; REMAINDER : aregHH,aregH,aregm,aregl ;
; ;
;note:
;1. Before calling this routine,load both dividend and divisor with non zero values.
;2. Also ensure that dividend is greater than divisor

;*********************************************************************************
div32by32_rn: ;
mov count,#020h ;
mov aregl,#00H ;
mov aregm,#00H ;
mov aregh,#00H ;
mov areghh,#00H ;
div32by32: ;
push acc ;
mov acc,Qregl ;
RLC A ;
mov Qregl,acc ;
mov acc,Qregm ;
RLC A ;
mov Qregm,acc ;
mov acc,Qregh ;
RLC A ;
mov Qregh,acc ;
mov acc,Qreghh ;
RLC A ;
mov Qreghh,acc ;
mov acc,aregl ;
RLC A ;
mov aregl,acc ;
mov acc,aregm ;
RLC A ;
mov aregm,acc ;
mov acc,aregh ;
RLC A ;
mov aregh,acc ;
mov acc,areghh ;
RLC A ;
mov areghh,acc ;
pop acc ;
mov acc,areghh ;
subb a,mreghh ;
jnz nochk32by32 ;
mov acc,aregh ;
subb a,mregh ;
jnz nochk32by32 ;
mov acc,aregm ;
subb a,mregm ;
jnz nochk32by32 ;
mov acc,aregl ;
subb a,mregl ;
nochk32by32: ;
jc restore32by32 ;
mov acc,aregl ;
subb a,mregl ;
mov aregl,acc ;
mov acc,aregm ;
subb a,mregm ;
mov aregm,acc ;
mov acc,aregh ;
subb a,mregh ;
mov aregh,acc ;
mov acc,areghh ;
subb a,mreghh ;
mov areghh,acc ;
setb qregl.0 ;
ljmp div32by3201 ;
restore32by32: ;
clr c ;
div32by3201: ;
DJNZ COUNT,div32by3202 ;
ret ;
div32by3202: ;
ljmp div32by32 ;
;*********************************************************************************
; end of 32 bit by 32 bit division routine
;*********************************************************************************

good luck,
-sathish.


List of 4 messages in thread
TopicAuthorDate
help meeee with division!!!            01/01/70 00:00      
RE: help meeee with division!!!            01/01/70 00:00      
RE: help meeee with division!!!            01/01/70 00:00      
help me with division-here it is rahman.            01/01/70 00:00      

Back to Subject List