please dont rip this site

Atmel AVR Microcontroller Basic Math Code Library

for Multiplication

Multiply 32 bits by 32 bits in software by http://elm-chan.org/

;-----------------------------------------------------------------------------;
; 32bit x 32bit unsigned multiply
;
; Register Variables
;  Call:  var1[3:0] = 32bit multiplicand
;         var1[7:4] = <don't care>
;         var2[3:0] = 32bit multiplier
;         lc        = <don't care> (high register must be allocated)
;
;  Result:var1[7:0] = 64bit result of var1[3:0] * var2[3:0]
;         var2[3:0] = <not changed>
;         lc        = 0
;
; Size  = 21 words
; Clock = 436..532 cycles (+ret)
; Stack = 0 byte


mul32u:		sub	var17,var17	;initialize variables
		sub	var16,var16	;
		sub	var15,var15	;
		sub	var14,var14	;
		ldi	lc,33		; lc = 33;
		brcc	PC+5		;---- calcurating loop
		add	var14,var20	;
		adc	var15,var21	;
		adc	var16,var22	;
		adc	var17,var23	;
		ror	var17		;
		ror	var16		;
		ror	var15		;
		ror	var14		;
		ror	var13		;
		ror	var12		;
		ror	var11		;
		ror	var10		;
		dec	lc		;if (--lc > 0)
		brne	PC-14		; continue loop;
		ret



mul32s:		clr	lc		; Optional fast signed helper
		clr	var14		;  process with fast unsinged routine
		tst	var13
		brpl	PC+10
		inc	var14
		com	var10
		com	var11
		com	var12
		com	var13
		adc	var10,lc
		adc	var11,lc
		adc	var12,lc
		adc	var13,lc
		tst	var21
		brpl	PC+10
		inc	var14
		com	var20
		com	var21
		com	var22
		com	var23
		adc	var20,lc
		adc	var21,lc
		adc	var22,lc
		adc	var23,lc
		bst	var14,0

		rcall	mul16u

		brtc	PC+17
		com	var10
		com	var11
		com	var12
		com	var13
		com	var14
		com	var15
		com	var16
		com	var17
		adc	var10,lc
		adc	var11,lc
		adc	var12,lc
		adc	var13,lc
		adc	var14,lc
		adc	var15,lc
		adc	var16,lc
		adc	var17,lc
		ret







file: /Techref/atmel/avr/mul32x32sw-ec.htm, 2KB, , updated: 2007/9/14 17:13, local time: 2024/12/22 18:09,
TOP NEW HELP FIND: 
3.138.102.163:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/Techref/atmel/avr/mul32x32sw-ec.htm"> Atmel AVR, atmega, Microcontroller, embedded controller, math 32x32, elm-chan.org</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .