PBP command execution time


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,671


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    @8mhz each instruction takes 0.5uS what you are looking at there are macro's you need the asm to see the actual code


    it wood go something like

    mainloop:
    movf 0fh,w
    movwf trisa
    movf 1,w
    movwf porta
    movf 0,w
    movwf porta
    goto mainloop

    ps pbp probably sticks a clrwdt in there somewhere too
    Last edited by richard; - 16th December 2014 at 03:47. Reason: ps

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    I found this by looking for mainloop in the LST file:

    Code:
    ...
                          00086         LABEL?L _mainloop       
                              M         RST?RP
                              M     if (PREV_ALT != 0)
                              M         bcf     WDTCON, ADSHR
                              M PREV_ALT = 0
                              M     endif
                              M     if (PREV_BANK != 0)
                              M         movlb   0
                              M PREV_BANK = 0
                              M     endif
                              M     ifdef PM_USED
                              M         LALL
                              M _mainloop
                              M         XALL
                              M     else
    000074                    M _mainloop
                              M     endif
                          00087         MOVE?CB 0FCh, TRISA
                              M         CHK?RP  TRISA
                              M     if (((TRISA) & 8000h) != PREV_ALT)
                              M       if ((TRISA) & 8000h)
                              M         bsf     WDTCON, ADSHR
                              M       else
                              M         bcf     WDTCON, ADSHR
                              M       endif
                              M PREV_ALT = (TRISA) & 8000h
                              M     endif
                              M     if ((((TRISA) & 0fffh) > BANKA_END) & (((TRISA) & 0fffh) < (0f01h + BANKA_END)))
                              M       if (((TRISA) & 0f00h) != (PREV_BANK << 8))
                              M         movlb   high (TRISA)
                              M PREV_BANK = high (TRISA)
                              M       endif
                              M     endif
                              M     if (low (0FCh) == 0)
                              M         clrf    TRISA
                              M     else
                              M       if (low (0FCh) == 255)
                              M         setf    TRISA
                              M       else
    000074 0EFC               M         movlw   low (0FCh)
    000076 6E92               M         movwf   TRISA
                              M       endif
                              M     endif
    MPASM  5.49                      BLINK1~1.ASM   12-15-2014  22:49:14         PAGE 15
    
    
    LOC  OBJECT CODE     LINE SOURCE TEXT
      VALUE
    
                          00088         MOVE?CB 001h, PORTA
                              M         CHK?RP  PORTA
                              M     if (((PORTA) & 8000h) != PREV_ALT)
                              M       if ((PORTA) & 8000h)
                              M         bsf     WDTCON, ADSHR
                              M       else
                              M         bcf     WDTCON, ADSHR
                              M       endif
                              M PREV_ALT = (PORTA) & 8000h
                              M     endif
                              M     if ((((PORTA) & 0fffh) > BANKA_END) & (((PORTA) & 0fffh) < (0f01h + BANKA_END)))
                              M       if (((PORTA) & 0f00h) != (PREV_BANK << 8))
                              M         movlb   high (PORTA)
                              M PREV_BANK = high (PORTA)
                              M       endif
                              M     endif
                              M     if (low (001h) == 0)
                              M         clrf    PORTA
                              M     else
                              M       if (low (001h) == 255)
                              M         setf    PORTA
                              M       else
    000078 0E01               M         movlw   low (001h)
    00007A 6E80               M         movwf   PORTA
                              M       endif
                              M     endif
                          00089         MOVE?CB 002h, PORTA
                              M         CHK?RP  PORTA
                              M     if (((PORTA) & 8000h) != PREV_ALT)
                              M       if ((PORTA) & 8000h)
                              M         bsf     WDTCON, ADSHR
                              M       else
                              M         bcf     WDTCON, ADSHR
                              M       endif
                              M PREV_ALT = (PORTA) & 8000h
                              M     endif
                              M     if ((((PORTA) & 0fffh) > BANKA_END) & (((PORTA) & 0fffh) < (0f01h + BANKA_END)))
                              M       if (((PORTA) & 0f00h) != (PREV_BANK << 8))
                              M         movlb   high (PORTA)
                              M PREV_BANK = high (PORTA)
                              M       endif
                              M     endif
                              M     if (low (002h) == 0)
                              M         clrf    PORTA
                              M     else
                              M       if (low (002h) == 255)
                              M         setf    PORTA
                              M       else
    00007C 0E02               M         movlw   low (002h)
    00007E 6E80               M         movwf   PORTA
                              M       endif
                              M     endif
                          00090         MOVE?CB 0F3h, TRISA
    MPASM  5.49                      BLINK1~1.ASM   12-15-2014  22:49:14         PAGE 16
    
    
    LOC  OBJECT CODE     LINE SOURCE TEXT
      VALUE
    
                              M         CHK?RP  TRISA
                              M     if (((TRISA) & 8000h) != PREV_ALT)
                              M       if ((TRISA) & 8000h)
                              M         bsf     WDTCON, ADSHR
                              M       else
                              M         bcf     WDTCON, ADSHR
                              M       endif
                              M PREV_ALT = (TRISA) & 8000h
                              M     endif
                              M     if ((((TRISA) & 0fffh) > BANKA_END) & (((TRISA) & 0fffh) < (0f01h + BANKA_END)))
                              M       if (((TRISA) & 0f00h) != (PREV_BANK << 8))
                              M         movlb   high (TRISA)
                              M PREV_BANK = high (TRISA)
                              M       endif
                              M     endif
                              M     if (low (0F3h) == 0)
                              M         clrf    TRISA
                              M     else
                              M       if (low (0F3h) == 255)
                              M         setf    TRISA
                              M       else
    000080 0EF3               M         movlw   low (0F3h)
    000082 6E92               M         movwf   TRISA
                              M       endif
                              M     endif
                          00091         MOVE?CB 004h, PORTA
                              M         CHK?RP  PORTA
                              M     if (((PORTA) & 8000h) != PREV_ALT)
                              M       if ((PORTA) & 8000h)
                              M         bsf     WDTCON, ADSHR
                              M       else
                              M         bcf     WDTCON, ADSHR
                              M       endif
                              M PREV_ALT = (PORTA) & 8000h
                              M     endif
                              M     if ((((PORTA) & 0fffh) > BANKA_END) & (((PORTA) & 0fffh) < (0f01h + BANKA_END)))
                              M       if (((PORTA) & 0f00h) != (PREV_BANK << 8))
                              M         movlb   high (PORTA)
                              M PREV_BANK = high (PORTA)
                              M       endif
                              M     endif
                              M     if (low (004h) == 0)
                              M         clrf    PORTA
                              M     else
                              M       if (low (004h) == 255)
                              M         setf    PORTA
                              M       else
    000084 0E04               M         movlw   low (004h)
    000086 6E80               M         movwf   PORTA
                              M       endif
                              M     endif
                          00092         MOVE?CB 008h, PORTA
                              M         CHK?RP  PORTA
    MPASM  5.49                      BLINK1~1.ASM   12-15-2014  22:49:14         PAGE 17
    
    
    LOC  OBJECT CODE     LINE SOURCE TEXT
      VALUE
    
                              M     if (((PORTA) & 8000h) != PREV_ALT)
                              M       if ((PORTA) & 8000h)
                              M         bsf     WDTCON, ADSHR
                              M       else
                              M         bcf     WDTCON, ADSHR
                              M       endif
                              M PREV_ALT = (PORTA) & 8000h
                              M     endif
                              M     if ((((PORTA) & 0fffh) > BANKA_END) & (((PORTA) & 0fffh) < (0f01h + BANKA_END)))
                              M       if (((PORTA) & 0f00h) != (PREV_BANK << 8))
                              M         movlb   high (PORTA)
                              M PREV_BANK = high (PORTA)
                              M       endif
                              M     endif
                              M     if (low (008h) == 0)
                              M         clrf    PORTA
                              M     else
                              M       if (low (008h) == 255)
                              M         setf    PORTA
                              M       else
    000088 0E08               M         movlw   low (008h)
    00008A 6E80               M         movwf   PORTA
                              M       endif
                              M     endif
                          00093         GOTO?L  _mainloop
                              M         L?GOTO  _mainloop
    ...
    A lot more going on before and after that snippet.

    Robert

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,671


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    that why your own asm routines are often used , if you know every thing is in the same mem bank then ALL that bank ckecking (chk:rp) can be eliminated ,but what you have there is a lst file I would expect any decent compiler to optimise most if not all that unnecessary code out , the assembled file should look cleaner than that, but need to disassemble the hex file to see it
    Last edited by richard; - 16th December 2014 at 04:10.

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    When I look in the folder where I compile, I see that ASM file I copied above, plus BAS, HEX, LST, MAC and O files.

    I don't see a "trimmed" assembler file.

    Robert

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,671


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    When I look in the folder where I compile, I see that ASM file I copied above, plus BAS, HEX, LST, MAC and O files.
    my bad
    I really meant the actual assembled code ---- you need a disassembler to see what really happened

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Quote Originally Posted by richard View Post
    ... you need a disassembler to see what really happened
    So Darryl must have been using a development tool to know exactly what was going on in the background?

    Robert

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,671


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    How do we get calculate 0.5uS again? I never remember how to do that. I'm sure the datasheet comes into play.
    each instruction takes 4 clock cycles . a clock cycle is 1/8000000 = 125nS therefore 1 instruction = 4*125 nS = 0.5uS

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Quote Originally Posted by richard View Post
    each instruction takes 4 clock cycles . a clock cycle is 1/8000000 = 125nS therefore 1 instruction = 4*125 nS = 0.5uS
    Unless I can't use a Saleae probe properly, each asm macro ran in 1uS (4uS for one pass). That's not bad considering the chunk of asm in there.

    Robert

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,671


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    each asm macro ran in 1uS (4uS for one pass). That's not bad considering the chunk of asm in there.
    means the compiler is making nicely optimised code
    I'm sure dt would have had some nice tools , my disassembler won't function any longer it steeps back to windows98 days , but since I gave up hand assembly its not missed that much .
    imho most compliers do a reasonable job except maybe the free version of xc8 which is apparently deliberately de-optimised

  10. #10
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Unless I can't use a Saleae probe properly, each asm macro ran in 1uS (4uS for one pass). That's not bad considering the chunk of asm in there.
    I think you're not using it properly. As far as I can see you have the sampling rate set to 4Mhz, so there's no way the logic analyzer is going to resolve anythning shorter than 1us. Increase the sampling rate and see if it makes any difference.

    By the way, these chk:rp macro things, aren't those assembler macros, ie they check, at compile time, if there's a need to switch banks and only then actually inserts the code? Ie, chk:rp isn't runtime code, it's assembly time code.

    /Henrik.

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Quote Originally Posted by richard View Post
    @8mhz each instruction takes 0.5uS ...
    How do we get calculate 0.5uS again? I never remember how to do that. I'm sure the datasheet comes into play.


    ...ps pbp probably sticks a clrwdt in there somewhere too
    Yup, right after the GOTO at the bottom.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Code speed and execution time
    By aajgss in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 12th May 2011, 03:44
  2. Code execution time?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th February 2009, 16:07
  3. Execution time in programme
    By Adrian in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th November 2007, 22:29
  4. Command execution time
    By barkerben in forum General
    Replies: 2
    Last Post: - 7th December 2004, 20:29
  5. instruction execution time
    By tjg in forum Code Examples
    Replies: 3
    Last Post: - 21st April 2004, 18: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