Calculation Problem - value goes to zero after 65


Results 1 to 15 of 15

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    1. I thought that "@" usually proceeds "one line of assembly code"?
    It does, and that's what it is.
    But he had the value stored in a specific location in an array, so you should just forget that part and make it ...

    Knots VAR WORD

    R0 and R2 are two of PBP's system variables.
    When you do a multiplication (Knots * 9881), R2 has the low word of the result which also gets copied to Dec_speed.
    And R0 has the High Word of the result, the same as if you did a Knots ** 9881, without having to do the multiplication a second time.

    So yes, the second Dec_speed does "negate" the first one, but the result is still in R0 and R2 so it doesn't matter.


    MPH = Knots * 1.150779
    And 9881 / 65536 = 0.150772, which is as close as we can get with integer math. That's the decimal part.
    The integer part is 1, so just adding Knots to the final result is the same thing.

    R2.15 is the highest bit in the low word, so it indicates if the high word should be rounded up or down.

    So all together, the multiplication does (Knots * 0.150772), the result is in R0, Round up if R2.15=1, then add Knots (knots * 1).

    Clear as mud.
    <br>
    Last edited by Darrel Taylor; - 9th March 2010 at 02:17.
    DT

Similar Threads

  1. Problem to compile my program
    By wagner in forum Off Topic
    Replies: 5
    Last Post: - 7th July 2008, 20:17
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  4. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

Members who have read this thread : 0

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