N-Bit_MATH


Results 1 to 39 of 39

Thread: N-Bit_MATH

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Much easier than using a calculator and separating the bytes.
    You can load the number you want like this ...

    Code:
    @  MOVE?CP  100000, _SetPoint
    Which puts up to a 32-bit Constant (4,294,967,295) into a PVAR.

    Displaying the big numbers is just a matter of dividing them down to useable amounts.
    For small numbers like 100,000 a single divide will do.
    Code:
    Divisor    VAR BYTE[PRECISION]
    Result     VAR BYTE[PRECISION]
    WordVar    VAR WORD
    Remainder  VAR WORD
    
    @   MOVE?CP   10000, _Divisor              ; load 10,000 into Divisor
    @   MATH_DIV  _SetPoint, _Divisor, _Result ; isolate lowest 4 digits
    @   MOVE?PW   _Result, _WordVar            ; copy Result to a PBP Word
    @   MOVE?PW   REG_Z, _Remainder            ; copy remainder to a PBP Word 
    
        IF WordVar > 0 THEN 
            LCDOUT DEC Wordvar, DEC4 Remainder
        ELSE
            LCDOUT DEC Remainder
        ENDIF
    It should work up to 655,359,999. Larger numbers will require more divisions.
    That's just off the top of my head, untested.
    Let me know if you have problems.
    Last edited by Darrel Taylor; - 14th March 2010 at 04:49. Reason: Added DEC to first LCDOUT ... removed ENDASM
    DT

Members who have read this thread : 1

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