32-bit Variables and DIV32, Hourmeter 99999.9


Closed Thread
Results 1 to 10 of 10

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi Peter,

    Sure, you can do it.

    First off, you'll need to lose one of zero's from that 1,250,000,000

    If you start off with 125,000,000 it brings it down to a managable range.

    125,000,000 / 32000 = 3906.2
    125,000,000 / 6200 = 20161.2

    Then you have most of the number from the integer portion, and the last digit is in the remainder, in the form of a Modulas. By dividing the (Modulas*10) by the original divisor, you can recover the last digit.
    Code:
    <font color="#000000"><b>Temp       </b><font color="#008000"><b>VAR  WORD</b></font>
    <b>Divisor    </b><font color="#008000"><b>VAR  WORD
    </b></font><b>Remainder  </b><font color="#008000"><b>VAR  WORD
    
    </b></font><font color="#0000FF"><b><i>;----[Load a 32-bit constant into PBP registers, Prior to DIV32]--------
    </i></b></font><font color="#008000"><b>ASM
    </b></font><font color="#000080">PutMulResult macro Const32
        MOVE?CB   low Const32, R2
        MOVE?CB   low (Const32 &gt;&gt; 8), R2 + 1
        MOVE?CB   low (Const32 &gt;&gt; 16), R0
        MOVE?CB   low (Const32 &gt;&gt; 24), R0 + 1
      endm
    </font><font color="#008000"><b>ENDASM
    
    </b></font><b>Divisor </b>= <b>6200
    </b><font color="#000080">@  PutMulResult   125000000
    </font><b>Temp </b>= <font color="#008000"><b>DIV32 </b></font><b>Divisor
    Remainder </b>= <b>R2 </b>* <b>10
    Remainder </b>= <font color="#008000"><b>DIV32 </b></font><b>Divisor
    </b><font color="#008000"><b>LCDOUT  </b></font><font color="#FF0000">&quot;Result=&quot;</font>,<font color="#008000"><b>DEC </b></font><b>Temp</b>,<font color="#008000"><b>DEC1 </b></font><b>Remainder</b>
    Result = 201612

    HTH,
    &nbsp;&nbsp;Darrel

  2. #2
    palmed's Avatar
    palmed Guest


    Did you find this post helpful? Yes | No

    Default

    Hi, Darrel,

    thanks a lot. After all, the answer was contained in some postings before, but sometimes you "don't see the trees in the wood" (correct saying?).

    I tested it and it works great!

    Peter

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


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    You constantly amaze me. What would this forum do without you?
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Thumbs up

    probably just trying to use the PBP statement stated in the manual or ... hum hum.. change to another boat... wich, after trying, i reaaaallly don't recommend
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Thanks Charles,

    And, without me... The forum would be reading a lot more SPAM from PCB houses in China. &nbsp; Love that delete command.

    But, with over 2400 posts, I'm wondering what we'd do without mister_e.
    Glad he didn't like the other boat. He makes up for like 10 people.

    DT

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


    Did you find this post helpful? Yes | No

    Default

    The first one to blame here is Bruce... if i'd never discover his website, i'd never buyed this addictive compiler... can't live without! Chances are that the other boat wasn't buyed from him... i would hate him now LMAO!

    Well thanks to the forum ! I learn almost everything here by trying to help other with their questions. Learning by trying/debugging never killed.. kinda challenge. My avatar choice says long It also give me a better english.. oh yeah far to be perfect but better than before... i guess... i hope. Where are my firsts posts?

    Thanks Darrel, Bruce, Melanie and all other gurus... i wish one day i'll be as good as you are!
    Last edited by mister_e; - 2nd August 2006 at 18:27.
    Steve

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

  7. #7
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Just remember Godess of Wisdom and Godess of Wealth can not stay in a single house.

    Thanks steve for your tip in #6 on the other boat. I was about to buy it.

    Thanks once again for sharing your wisdom on this forum, which goes to all the guru's.

    really appreciate help from all.

    regards

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