• 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.