How to learn assembely?


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post Reason why Select Case is faster!

    Main reason why Select Case is faster than using multiple IF's is because not all conditions are checked, only the first true condition in a Select Case argument has its underlying block of code executed.

    That's my theory on it anyway.

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


    Did you find this post helpful? Yes | No

    Default

    unless your using a little bit of your brain, it's true.
    Code:
    plah plah plah
    Avar=Whatever
    Gosub StartSelectCase
    plah
    plah
    plah
    '
    '
    '
    
    StartSelectCase:
        If AVar=1 then
            Dosomething
            Return
            Endif
    
        If AVar=2 then
            Dosomething
            Return
            Endif
        '
        '
        '
        If AVar=x then
            Dosomething
            Endif
    
        Return
    V2
    Code:
    AVar = Whatever
    
    StartSelectCase:
        If AVar=1 then
            Dosomething
            Goto EndSelectCase
            Endif
    
        If AVar=x then
            Dosomething
            Goto EndSelectCase
            Endif
        '
        '
        '
        If AVar=y then
            Dosomething
            Endif
    EndSelectCase:
    Sort of what's under the SelectCase hood.

    Now depending how the compiler, language interpret/optimise it, one can be faster than the other. It's hard to tell which will ALWAYS be faster so far as there's millions (and more) different possible itteration/conditions.

    Both get the job done! One is easier to read, implement debug.
    Steve

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

  3. #3
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default I think there's other diferences too.

    Pretty sure you'll find that for every IF argument, unlike Select Case, the subject variable to compare with is loaded into a working register each time.
    However with Select Case it's already there for the next compare. Possibly the closed analogy of Select Case would be ELSEIF. But it's no where near as flexible unfortunately.
    <br/>
    Last edited by T.Jackson; - 7th May 2007 at 02:58.

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


    Did you find this post helpful? Yes | No

    Default

    Back to the original topic. Here's an interesting MicroChip on-line flash tutorial.

    http://techtrain.microchip.com/x14/
    Steve

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

Similar Threads

  1. Can you teach a PIC to learn?
    By lew247 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st December 2009, 01:06
  2. help converting assembely program
    By ahmed_salah in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 7th August 2008, 15:28
  3. How do you learn best?
    By T.Jackson in forum Off Topic
    Replies: 41
    Last Post: - 30th May 2008, 14:32
  4. Who wants to learn...
    By Stoverus in forum Off Topic
    Replies: 1
    Last Post: - 21st October 2006, 07:08
  5. How to learn PIC BASIC compiler in 7 days?
    By luqman83salleh in forum General
    Replies: 2
    Last Post: - 13th August 2004, 14:15

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