please dont rip this site

SX microcontroller CARRYX option / CF FUSEX bit

The intent of the CF_ bit is to make multiprecision adds and subtracts easier, as shown here:

   ;FF:= FF + GG with correct carry out (CF_ is 0)
	mov	W, G	;add low bytes
	clrb	STATUS.CF	;clear carry
	add	F, W
	mov	W, G+1	;add high bytes and carry
	add	F+1, W

   ;FF:= FF - GG with correct carry out (CF_ is 0)
	mov	W, G	;subtract low bytes
	setb	STATUS.CF	;set carry
	mov	W, G+1	;subtract high bytes

The following routines accomplish the same thing (although with an extra instruction), and they're compatable with the PIC 16C5x:

   ;FF:= FF + GG with correct carry out (CF_ is 1)
	mov	W, G	;add low bytes
	add	F, W
	mov	W, G+1	;get ready to add high bytes
	snb	STATUS.CF	;skip if there was no carry into high byte
	movsz	W, ++G+1	;else add in carry; if result is 0 then high
	add	F+1, W	; byte doesn't change and CF is still set

   ;FF:= FF - GG with correct carry out (CF_ is 1)
	mov	W, G	;subtract low bytes
	sub	F, W
	mov	W, G+1	;get ready to subtract high bytes
	sb	STATUS.CF	;skip if there was no borrow from high byte
	movsz	W, ++G+1	;else increase amount to subtract by 1; if it's
	sub	F+1, W	; 0 then high byte doesn't change, nor does CF

Since the carry-out is correct in all four of these routines, they can easily be extended for more bytes of precision.

We can do a double precision add in five instructions if there is a location set asideto hold a zero. Unfortunately, this can't be extended to more than two bytes of precision.

   ;FF:= FF + GG with correct carry out (CF_ is 1)
	mov	W, G	;add low bytes
	add	F, W
	mov	W, <<ZERO	;shift in carry forming either 01h or 00h
	add	W, G+1	;add carry and high bytes
	add	F+1, W

file: /Techref/scenix/carryx.htm, 2KB, , updated: 2004/4/5 18:32, local time: 2024/10/9 02:53,
TOP NEW HELP FIND: 
3.236.112.101:LOG IN
©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!

 ©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.piclist.com/techref/scenix/carryx.htm"> SX microcontroller CARRYX option</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?

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .