please dont rip this site

SX Microcontroller Math Method

24 bit binary addition

Translated and optimized for the Scenix SX by Nikolai Golovchenko

From: Dwayne Reid

...here is an example that takes the value in R1H,M,L and adds it to the value contained in AD2H,M,L (result in AD2H,M,L). You should be able to see how to extend it to more than 24 bits.

There is a similar version that does subtraction. I often extend to 40 bits or more - its easier to do this when manipulating integer values than it is to try and figure out which bits I can discard.

;now add new sample
	mov	W, R1L		;
	add	AD2L, W	;LS byte

	mov	W, R1M		;middle byte
	snb	C		;take R1M+1 if carry
	movsz	W, ++R1M	;if R1M+1==0 skip addition to preserve carry
	add	AD2M, W	;

	mov	W, R1H		;MS byte
	snb	C
	movsz	W, ++R1H
	add	AD2H, W	;

And 24-bit substraction: AD2 = AD2 - R1

	mov	W, R1L		;
	sub	AD2L, W	;LS byte

	mov	W, R1M		;middle byte
	sb	C		;take middle byte + 1 if borrow
	movsz	W, ++R1M	;if R1M+1==0 skip substraction to preserve borrow
	sub	AD2M, W	;

	mov	W, R1H		;MS byte
	sb	C
	movsz	W, ++R1H
	sub	AD2H, W	;

file: /Techref/scenix/lib/math/add/24b_sx.htm, 1KB, , updated: 2004/6/10 14:40, local time: 2024/3/28 11:16,
TOP NEW HELP FIND: 
44.201.131.213: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://www.sxlist.com/techref/scenix/lib/math/add/24b_sx.htm"> SX Microcontroller Math Method 24 bit binary addition</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 sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to www.sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .