Overflow bit?


Closed Thread
Results 1 to 11 of 11

Thread: Overflow bit?

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default Overflow bit?

    PBP has a bunch of system variables, does it have any that I can test for overflow? In other words, is there NO way I can find out if the result of an addition or multiplication led to a variable overflow? Must I do the math in assembly to get that information?
    Charles Linquist

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi, Charles

    IF the result of an addition or multiplication is smaller than one of its terms ... there was an overflow !!!

    an so on ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Euh... lower than the Higher term is probably better IMHO Asumming 1*10, 10*10000, etc
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Talking Probably too hard a working night ...

    Quote Originally Posted by mister_e
    Euh... lower than the Higher term is probably better IMHO Asumming 1*10, 10*10000, etc
    And WHAT's wrong then, Mr Super E ??????????????????????????

    Cheers !!!

    Alain
    Last edited by Acetronics2; - 12th October 2006 at 12:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Makes me wonder why I didn't think of this before!
    Charles Linquist

  6. #6
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    [quote]Makes me wonder why I didn't think of this before!{/quote]

    Actually, I wonder why the authors of PBP didn't think of this in the first place, and set a readable flag that would indicate an overflow/underflow condition.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Talking Errors in my program ??? IMPOSSIBLE !!!

    Hi, Ernie

    Just because you're supposed to think to everything happening ... and of course because you're an " up to the top " PbP programmer ...

    ...

    Thinking to that ... there's a CARRY BIT that exists in PICS ... I bet 1$ it is not automatically cleared by PbP ( ... ) in an overflow situation.
    Just an idea ...

    regards
    Alain
    Last edited by Acetronics2; - 12th October 2006 at 15:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    I bet 1$ it is not automatically cleared by PBP ( ... ) in an overflow situation.
    Go ahead and bet your dollar. I'm using PBP for software in a human patient connected device. If my device fails to work when it's supposed to that person will die.

    You can bet your buck but I'm not betting someone's life on an undocumented "feature."

    I do code very defensively when using integer math; typically checking inputs for values in the expected range to keep the output from overflowing is sufficient.

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink 10 Bucks to see ...

    Quote Originally Posted by ErnieM
    Go ahead and bet your dollar. I'm using PBP for software in a human patient connected device. If my device fails to work when it's supposed to that person will die.

    You can bet your buck but I'm not betting someone's life on an undocumented "feature."

    I do code very defensively when using integer math; typically checking inputs for values in the expected range to keep the output from overflowing is sufficient.
    Hi, Ernie

    Great to you, but, as the source code is available ( PbP**.lib ), you can verify it quietly. Add to that it can easily be verified " live ( ! ) " in a little test example, using MPLAB in debugging mode ...

    One more thing ... I remember having read somewhere those softs do not guarantee they are bug free ( special lines for life critical systems , last page of the manual ... also saw that lines from µChip datas !!! ).


    Sooo , documented or not, it's all at your own risks ... and you have to verify everything.

    Just for fun ... most of my systems are intended to care of the flying security of giant size model aircrafts ...

    We're aboard the same boat, it seems ...

    Regards

    Alain
    Last edited by Acetronics2; - 13th October 2006 at 19:59.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    And my code is used by Lockheed-Martin, Northrup Grumman, Boeing, British Aerospace, General Atomics, Raytheon, Rockwell-Collins, Smiths Aerospace, Fermi Labs, Lawrence Livermore Labs and others. So I need reliability as well.
    Charles Linquist

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    If you were to bet any amount of money on the carry/borrow flag being correct after a math operation in PBP, you would lose. Because there are several instances where it ends up wrong.

    Being capable of only 16-bit math, they apparently weren't worried about anyone using larger numbers and took shortcuts in the math routines to save a couple words in the compiled code. Causing me many days of headaches, because I originally thought it would have worked correctly.

    Essentially it boils down to the possibility of 2 overflows in a 16-bit operation. And the PBP math routines only account for 1 of them.

    Sure makes 32-bit math a pain in the asparagus.
    <br>
    DT

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts