Searching \ for '[SX] SXB 2.0 16bit add/sub and overflow/underflow' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/languages.htm?key=sx
Search entire site for: 'SXB 2.0 16bit add/sub and overflow/underflow'.

Exact match. Not showing close matches.
PICList Thread
'[SX] SXB 2.0 16bit add/sub and overflow/underflow'
2009\04\02@171530 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi Peter;
I will have to check again, but I use the same code, and I believe that Bean has the sequence correct, that is to say adding the 'lsb, then dealing with any carry out, and then adding the 'msb.

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=340221#m340302
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\04\02@180444 by peterverkaikn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote:

Hi pjv,
I think I made an error regarding the subtraction. The sx clears the C for underflow
and sets C when there is no underflow. So the subtract sequence appears right.

But the addition fails

dacValue = $FF00
adcValue = $0100
dacValue + adcValue = $0000 with C set
Using the sxb sequence
add the MSB yields 0 with C set
add the LSB yields 0 with C clear
so the ADDB dacValue_MSB,C leaves C clear regards peter
PS. Have you seen my latest reply on the IFDEF issue.
I thought you were looking for a macro to autocreate a jumptable.
http://forums.parallax.com/forums/default.aspx?f=7&m=339008&g=339308#m339308
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=340221#m340318
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\04\03@085916 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi Peter;

On confirming this, you are absolutely correct in the case of adding two words together. Subtracting two words is done correctly. Adding or subtracting a byte to a word are also both done correctly. In the case of adding two words, Bean simply has the order backwards, the '_lsb needs to be added before adding the '_msb.


Here is the compiled results on adding/subtracting two words as well as a word with a byte:



 
  342  0000  0215        ADD WordOne_MSB,WordTwo_MSB    ;WordOne = WordOne + WordTwo
       0001  01F5
  343  0002  0214        ADD WordOne_LSB,WordTwo_LSB  
       0003  01F4
  344  0004  0603        ADDB WordOne_MSB,C            
       0005  02B5
  345                  
  346  0006  0214        SUB WordOne_LSB,WordTwo_LSB    ;WordOne = WordOne - WordTwo
       0007  00B4
  347  0008  0703        SUBB WordOne_MSB,/C          
       0009  00F5
  348  000A  0215        SUB WordOne_MSB,WordTwo_MSB  
       000B  00B5
  349                  
  350  000C  021C        ADD WordOne_LSB,ByteOne        ;WordOne = WordOne + ByteOne
       000D  01F4
  351  000E  0603        ADDB WordOne_MSB,C            
       000F  02B5
  352                  
  353  0010  021C        SUB WordOne_LSB,ByteOne        ;WordOne = WordOne - ByteOne
       0011  00B4
  354  0012  0703        SUBB WordOne_MSB,/C          
       0013  00F5
 
Regarding the IFDEF, I have not had the time recently to mess with that, but I hope to look into it soon.

Thanks for your interest.

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=340221#m340527
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\04\03@183634 by NetHogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, NetHog wrote:

One frustrating thing about add/sub with addb/subb is that you lose the final carry/borrow and cannot check for overflow.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=340221#m340663
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...