Fast Loop in PICBASIC Pro


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce
    Code:
     I VAR BYTE SYSTEM
    
    LOOP1: ; 150 cycles. Not very fast
        For I=10 TO 1 STEP -1
        NEXT I
        
    LOOP2: ; 90 cycles. A lot better
        I = 10
        REPEAT
         I=I-1
        UNTIL I=0
    ASM   ; 31 cycles. Pretty fast
    LOOP3
         MOVLW 0xA
         MOVWF I      ; I=10
    INNER
         DECFSZ I,F   ; I=I-1. IF I=0 skip next instruction
         GOTO INNER  ; Loop until I=0
    ENDASM
    
    FINISH:
        GOTO FINISH

    ...and, there is also the expert approach!

    You know, we kiss the hand of the experts here.



    ------------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    ...and, there is also the expert approach!

    You know, we kiss the hand of the experts here.



    ------------------------------------


    Or the keyboard of the experts...

    However, I saw the original poster's first line
    ------------------
    Hi guys,

    I'm new to PICBasic!!
    -----------------------
    which says to me 'not fluent in any sort of asm', so he's probably not going to get much better than 90 cycles
    JDG

Similar Threads

  1. Controlsystem for compact sporting (clay shooting)
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2009, 17:48
  2. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 18:42
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 19:31
  4. Question for all that use MELABS PICBASIC PRO
    By oskuro in forum Off Topic
    Replies: 2
    Last Post: - 24th March 2005, 18:15
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 22:19

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