• PicŪ Basic


  • NBitMath enables PDS calculations up to 31 bytes wide

    With NBitMath you can now calculate in values from 8 to 31 bytes wide as opposed to the 4 byte width of a Dword.
    That's a maximum calculation value of: 452,312,848,583,266,388,373,324,160,190,187,140,05 1,835,877,600,158,453,279,131,187,530,910,662,655.

    For use with PIC 18's only.

    All credit for the NBitMath assembly routines belongs to Alexander Avtanski.
    All credit for the interface to PDS ("P-NBitMath.inc") belongs to Alberto Freixanet.

    NBitMath macros include:
    MATH_INC
    MATH_DEC
    MATH_ROL
    MATH_ADD
    MATH_SUB
    MATH_MUL
    MATH_DIV

    To use NBitMath first load 2 of the registers as follows:
    MOVE_CVA 4294967295, REG_B 'LOAD REG_B
    MOVE_CVA 4294967200, REG_C 'LOAD REG_C

    Then call one of the several macros with user set parameters:
    MATH_SUB REG_B, REG_C, REG_A 'equivalent of REG_B - REG_C = REG_A

    Lastly return the register to a PDS variable (Truncates if larger than the variable):
    DWORDTemp2 = MOVE_AV REG_A
    WORDTemp2 = MOVE_AV REG_A
    BYTETemp2 = MOVE_AV REG_A

    For several more complete examples see Alberto's "TEST-NBitMath.bas"

    Download the latest version of NBitMath or additionally see macroFORMAT to view and format any of the registers up to 31 bytes wide as a string.
    Rename .xyz extension to .bas

    PDS NBitsMath up to 31 Bytes wide forum.


    Above description by Norm.
    Please ask the author Alberto for specifics.
  • Recent Activity

    xldaedalus-432

    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    xldaedalus Today, 20:14 Go to last post
    Mellbreak-21950

    Watchdog timer

    Thread Starter: joesaliba

    I have a code that basically looks for four input and four outputs, depends on various timing and input conditions. I use interrupt and some delays...

    Mellbreak Today, 11:30 Go to last post