PBPL Math...new math takes more cycles...Always?


Closed Thread
Results 1 to 3 of 3
  1. #1
    skimask's Avatar
    skimask Guest

    Question PBPL Math...new math takes more cycles...Always?

    Has anybody else noticed that PBPL (PBP2.50a) multiply and divide routines are ALL 32 bit?
    I was running my latest program tonight trying to figure out why it was quite a bit slower than it used to be. Come to figure out that all of that math that I thought I might be saving by not using DIV32 gets used up by the new 32 bit routines...
    Not that it's a bad thing...but...
    Heck, only a few of the calculations I do in the program really NEED the full 32 bits of precision. Most of them are byte/byte or word/byte, very few are Long/Long or Long/Byte.
    I did some quick figuring by looking at my .lst file for an 18F4620 using the new 32 bit routines.
    IF my figuring is right, a 32/32 bit divide can take anywhere from 628 - 1868 cycles.
    32/32 bit multiply, up to 298 cycles.
    neither of those figures include setting up the system variables, jumps into and out of the routines and any housekeeping that PBP does, so they're obviously longer.
    If I'm doing word/byte division, I figure it should only take roughly 388-1028 cycles. Quite a bit of savings to be had there.
    In my case especially. My loop can only run about 4 times per second as it is, mainly because of all of that 32 bit math involved (92 divisions/mods, 35 multiplies, numerous adds and subtracts, and a handful of shifts that already take the place of ^2 multiply/divides).

    So, I guess my question is, can I have my cake and eat it too? Short of writing extra math routines on top of PBP's built-in routines, is there any way to short-circuit PBP into using quicker methods that don't use all 32 bits while keeping the option open to using all of those 32 bits?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Ski

    That's fully written at the bottom of 4.17 "new" manual chapter ...

    you should browse the µChip site : there are "complex" functions like LOG,SIN, ... in the Floating point routines, that are not in the Melabs Download.

    so, you could use those 24 and 32 bits functions ... just when needed.

    I'll try to find the µChip link ( I have it here for PIC 16 and 17 on a CD ...)

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Ski
    That's fully written at the bottom of 4.17 "new" manual chapter ...
    Yep, I just re-read, in-depth, every single word of that chapter, and compared it to the listings of newer compiled programs vs. old (2.47 and earlier) programs.

    you should browse the µChip site : there are "complex" functions like LOG,SIN, ... in the Floating point routines, that are not in the Melabs Download.
    so, you could use those 24 and 32 bits functions ... just when needed.
    I'll try to find the µChip link ( I have it here for PIC 16 and 17 on a CD ...)
    Alain
    I've got those libraries. They're quite a bit overkill for what I need. Like I said, I guess I'm just looking for a way to short-circuit PBP back into it's old evil 16/8 bit ways.

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. instruction cycles for math operations
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th July 2007, 11:03

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