Fast Loop in PICBASIC Pro


Results 1 to 12 of 12

Threaded View

  1. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    could be...
    Code:
    DEFINE OSC 20
    TRISB.0 = 0
    PORTB = 0
    pauseus 0 ' do nothing good but include PAUSEUS?C macro
    TRISB.0 = 0
    PORTB = 0
    start:
    asm
        CHK?RP PORTB
        local a=0
        while a<16        
            BSF PORTB,0
            nop
            PAUSEUS?C 12
            BCF PORTB,0
            nop
            PAUSEUS?C 12
    a+=1
        endw
    endasm
    pause 100
    goto start
    now play with the a < x value, and look what happen to your code size.. interesting eh?

    Now compare the code size of
    Code:
    PORTB.0 = 1   
    @ nop
    Pauseus 12
    PORTB.0 = 0     
    @ nop
    PAUSEUS 12
    copy and pasted 16 times, with the one generated with my solution... mmm interesting

    Sometime MPASM directive are really handy!

    EDIT: you could also use
    Code:
    @   local a=0
    @   while a<16
            PORTB.0=1
            @ nop
            PAUSEUS 12
            PORTB.0=0
            @ nop
            PAUSEUS 12
    @a+=1
    @       endw
    If you don't like the PAUSE?C, BSF, BCF option... both generate the same code.
    Last edited by mister_e; - 18th December 2006 at 05:03.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

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

Members who have read this thread : 2

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