please dont rip this site

Atmel AVR Microcontroller Basic Math Code Library

for Multiplication

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

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


mul16u:		sub	var13,var13	;initialize variables
		sub	var12,var12	;
		ldi	lc,17		; lc = 17;
		brcc	PC+3		;---- calcurating loop
		add	var12,var20	;
		adc	var13,var21	;
		ror	var13		;
		ror	var12		;
		ror	var11		;
		ror	var10		;
		dec	lc		;if (--lc > 0)
		brne	PC-8		; continue loop;
		ret



mul16s:		clr	lc		; Optional fast signed helper
		clr	var12		;  process with fast unsinged routine
		tst	var11
		brpl	PC+6
		inc	var12
		com	var10
		com	var11
		adc	var10,lc
		adc	var11,lc
		tst	var21
		brpl	PC+6
		inc	var12
		com	var20
		com	var21
		adc	var20,lc
		adc	var21,lc
		bst	var12,0
		rcall	mul16u
		brtc	PC+9
		com	var10
		com	var11
		com	var12
		com	var13
		adc	var10,lc
		adc	var11,lc
		adc	var12,lc
		adc	var13,lc
		ret





file: /Techref/atmel/avr/mul16x16sw-ec.htm, 1KB, , updated: 2007/9/14 17:13, local time: 2024/11/29 21:49,
TOP NEW HELP FIND: 
3.135.184.27: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.ecomorder.com/techref/atmel/avr/mul16x16sw-ec.htm"> Atmel AVR, atmega, Microcontroller, embedded controller, math 16x16, 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 ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .