PBP command execution time


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default PBP command execution time

    Main logic snippet:
    Code:
    ...
    mainloop:
        TRISA = %11111100
        PORTA = %00000001
    
        PORTA = %00000010
        goto mainloop
    End
    ASM listing:
    Code:
    ...
    	LABEL?L	_mainloop	
    	MOVE?CB	0FCh, TRISA
    	MOVE?CB	001h, PORTA
    	MOVE?CB	002h, PORTA
    	GOTO?L	_mainloop
    	END?	
    
    	END
    Saleae sampling:
    Name:  Saleae Charlie-plex 2 pins.PNG
Views: 736
Size:  43.0 KB

    1 uSec per instruction at 8MHz on a 18F44K22.

    Is it that simple? Or is there more going on and I'm not getting it?

    (1978-1984 is so far away. Yeah, I didn't have sec 5 math so I had to take it before starting 3-yr data processing program. Of course I dropped out sec 5 math on first try; culture shock coming from high school where teachers kicked me in the butt to get things done and had to come back the next September to get it done.)

    Robert

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,642


    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

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


    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

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,642


    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.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    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

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,642


    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

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


    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,154


    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
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    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