Retrieving 32bit Multiply Result


Closed Thread
Results 1 to 40 of 43

Hybrid View

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


    Did you find this post helpful? Yes | No

    Thumbs up

    Yup,

    Looks great to me.

    Nice reduction.
    <br>
    DT

  2. #2


    Did you find this post helpful? Yes | No

    Red face Another trick?

    I was so confused about the Multiply operation that i posted here but.... i am now just using ** and * :s sorry
    Last edited by Josuetas; - 31st July 2007 at 20:11.

  3. #3


    Did you find this post helpful? Yes | No

    Smile Divide BigWord by Word

    Well i am really proud of this, i Hope its ok.

    For anyone in need of a Division of a BigWord by some number i found this problem:

    Lets think of a BigWord as considered before ^

    Now you might want to Divide a value stored in tBigWord1 by some other value, in this case (EXAMPLE CODE) the value is stored in factoriva.

    One could use the DIV32 function as proposed by Darrel in this or other post BUT if factoriva is too small the result CAN be higher than a word size FFFF, and the the result is no good.

    For example:

    4:01F5 DIV32 2 the result of DIV32 is

    Result = FFFF, Remainder = 01F7 !! Wrong i guess

    This code is possible just thanks to Darrel`s @ PutMulResult?D MACRO

    Code:
    Bigword   var word [2]
    BigwordL  var BigWord(0)
    BigwordH  var BigWord(1)
    Bigword1  var word [2]
    Bigword1L var BigWord(0)
    Bigword1H var BigWord(1)
    
    MainLoop:
        lcdout $fe,1
        tbigword1H = 4         ' My Dollars Value High Word
        tbigword1L = 501      ' My Dollars value Low Word
        cents = 24              ' My cents value
    
        GOSUB DIVBIGWORD
        HSEROUT [#FactorIva," ",HEX4 tBigWordH,":", HEX4 tBigWordHL,10,13]
    
        FactorIva= FactorIva+ 1
        IF FactorIva= 101 THEN
             END
        ENDIF    
        GOTO MainLoop
    
    'This SUB receives  tBigWord1(Dword) a value to be divided by
    'FactorIva (word), Result in tBigWord, works for any value of FactorIva
    'and tBigWord1 in their limits.
    DIVBigWord:  
        tBigWordH= tBigWord1H / FactorIva
        tBigWord1H = tBigWord1H // FactorIva
        @ PutMulResult?D  _tBigWord1
        tBigWordL = DIV32 FactorIva
        Remainder = R2
        RETURN
    This code in the serial port os The value tBigWord1 Divided for Factors 1 to 100
    Seems to work.
    Factor Result
    2 0002:00FA

    Remember to Add the @ PutMulResult?D MACRO posted by Darrel at the begining of the Code.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hello everyone,

    I was wandering if it is possible to implement the extended 32 bit idea to something as simple as for / next loop.
    How will this simple loop look like if I need to deal with more than word size index:

    For index =0 to big_number
    Hserout [record(index),13,10]
    Pause 100
    Next

    Is it possible to have a big_number = 1,000,000 – 2,000,000?

    Thank you for your input.

    Nick

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Nicmus View Post
    Is it possible to have a big_number = 1,000,000 – 2,000,000?
    Nick
    It's directly possible if you have the PBP 2.50a upgrade, which supports signed/32 bit LONG variables...

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


    Did you find this post helpful? Yes | No

    Default

    for PIC18 only !
    Steve

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

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Quote Originally Posted by mister_e View Post
    for PIC18 only !
    Got my back everywhere, dontcha?

Similar Threads

  1. Strugling without floating point
    By pjsmith in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 27th March 2011, 06:29
  2. Math help please!!!
    By jbirnsch in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th August 2007, 14:45
  3. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 07:23
  4. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 14:21
  5. Retrieving Div32 Remainder
    By Darrel Taylor in forum Code Examples
    Replies: 4
    Last Post: - 20th August 2003, 03:53

Members who have read this thread : 4

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