32 bit square root


Results 1 to 21 of 21

Threaded View

  1. #14
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Square Root 16 and 32 bit include file

    Quote Originally Posted by Charles Linquis View Post
    I'll try timing it Monday.
    Thanks Charles,

    No worries, I was just curious if pbpl was any slower compared to using pbp with the square root assembly code. Since pbpl uses a bit more space, I was curious to know if it was faster, or slower. It appears that a 20mhz chip can do about 5 or 6 of these in 1 ms using the assembly include file.

    If anyone is interested, to make things easier, I have attached it as an include file. It can only be used on PIC18 chips, and according to TB040, must be modified for use with PIC17 devices that have a hardware multiplier. But if you did not have a new version of pbp (that had pbpl included), this would allow you to perform 32 bit square root. And it is much smaller than compiling in pbpl.

    To use, load argh with the upper 16 bits, and argl with the lower 16 bits, then call square. Result will be in word variable RES.

    Code:
    INCLUDE "square.pbp"
    
    'some defines here
    main:
    'and a little bit of code there....
    
    ARGH = $0001       'load upper 16 bits into argument (any value you want)
    ARGL = $ffff       'load lower 16 bits into argument (any value you want)
    call square        'call square assembly function
    lcdout $FE,1,#RES  'print result to lcd
    Here are the results from codetimer.bas:
    Time: 84.66328 usec
    OSC Freq: 48 Mhz
    Attached Files Attached Files
    Last edited by ScaleRobotics; - 5th February 2011 at 19:49. Reason: added codetimer speed at 48 mhz

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Replies: 3
    Last Post: - 18th March 2008, 04:29
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. 32 bit data displaying on LCD
    By selahattin in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 15th September 2006, 13:33
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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