HELP WITH SOME Nbit MATH


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: HELP WITH SOME Nbit MATH

    thanks that make a bit more sense to me now

    i had only used the M_GTE flag = 0 for < values
    and M_GTE_flag = 1 for > values
    Code:
    @  MATH_CMP _Result_32bit , _Slow_Sublap_32bit            ' Compare Pvars - result in M_EQ and M_GTE bits - if sublap result < slow_sublap then slow_sublap = sublap resutl
                      @  MOVE?PB  _M_GTE, _glc_s                                ' get result of compare ( Z=>X) into a tmp PBP byte                                                         
                      if glc_s = 0  then                                        ' if result is 0 then compare sublap < slow_sublap = true 
                         @  MOVE?PP  _Result_32bit , _Slow_Sublap_32bit         ' copy the sublap time to slow_sublap time 
                    etc ......
    which is not correct i think

    i am using the nmath for time to sort out fastest , slowest times from a record
    each record shows time value for each lap

    base method is
    tmp0 = 0
    slowlap = 0
    fastlap = 0

    loop:
    get a lap time & its record ref
    convert time to secs_result
    secs_result - tmp0 ' to get lap time in sec
    tmp0 = secs_result ' copy last time into tmp for next loop
    if sec_result < slowlap then
    slowlap = sec_result
    store other pbp records
    endif

    if sec_result > fastlap then
    fastlap = sec_result
    store other pbp records
    endif
    endloop

  2. #2
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: HELP WITH SOME Nbit MATH

    You are over complicated this
    Code:
    @  MOVE?PB  _M_GTE, _glc_s                                ' get result of compare ( Z=>X) into a tmp PBP byte   THIS IS NOT CORRECT!!!                                            
    if glc_s = 0  then                                        ' if result is 0 then compare sublap < slow_sublap = true
    Look at lines 25 and 26 of DT's include:
    Code:
    M_EQ            VAR BIT   ; Equal to, for CMP
    M_GTE           VAR BIT   ; Greater than or Equal to, for CMP
    M_GTE and M_EQ are PBP variables(bit).
    So you don't need to copy them or what ever MOVE?PB will do to bit. Just use it as any variable in pbp.
    Look at my example, and use it that way to make life little bit easier
    EDIT (again):
    Look at lines 201 and 202
    Code:
        MOVE?TT  STATUS,Z, _M_EQ     ; STATUS,Z set if Z == X
        MOVE?TT  STATUS,C, _M_GTE    ; STATUS,C set if Z => X;
    They move results from PIC STATUS register to bit defined at line 25 and 26.

Similar Threads

  1. some help with math
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 64
    Last Post: - 16th October 2015, 02:03
  2. Help with the math
    By Ramius in forum FAQ - Frequently Asked Questions
    Replies: 3
    Last Post: - 5th September 2014, 07:15
  3. Math help please...
    By Ioannis in forum General
    Replies: 2
    Last Post: - 20th June 2008, 10:18
  4. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 10:22
  5. math help
    By houa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th January 2006, 16:58

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