PBP 2.6C assembler


Closed Thread
Results 1 to 14 of 14
  1. #1

    Default PBP 2.6C assembler

    ok, I think I'm needing to write stuff in assembler now due to timing issues.
    However, when i open the ASM file for what i have already written, some of the mnemonics / Operands are not the standard mnemonics that are in the microchip datasheet.

    So, my question is what assembler language is PBP using and where can i find a list of the mnemonics it uses and their functions?

    Thanks

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    You need to read about assembly in the Picbasic Manual - that should give you the information you need to incorporate assembler in your program.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    yep, the pbp manual does indeed tell me how to include assembler in my code...
    However, it does not tell me what opcodes the assembler is using...

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    You use the standard Microchip opcodes. You do not edit the ASM file that PB generates, you add the assembler routines to your basic file.

    Look in your samples directory that came with PB you should find ASMINT.BAS in there, that will give you the idea of how to progress.

    Code:
    ' Interrupts in assembly language
    '  Turn LED on.  Interrupt on PORTB.0 (INTE) turns LED off.
    '  Program waits .5 seconds and turns LED back on.
    
    led     var     PORTB.7
    
    wsave   var     byte $20 system
    'wsave1  var     byte $a0 system ' Necessary for devices with RAM in bank1
    'wsave2  var     byte $120 system ' Necessary for devices with RAM in bank2
    'wsave3  var     byte $1a0 system ' Necessary for devices with RAM in bank3
    ssave   var     byte bank0 system
    psave   var     byte bank0 system
    
    
            Goto start              ' Skip around interrupt handler
    
    ' Define interrupt handler
    define  INTHAND myint
    
    ' Assembly language interrupt handler
    asm
    
    ; Save W, STATUS and PCLATH registers, if not done previously
    myint   movwf   wsave
            swapf   STATUS, W
            clrf    STATUS
            movwf   ssave
            movf    PCLATH, W
            movwf   psave
    
    ; Insert interrupt code here
    ; Save and restore FSR and any other registers used
    
            bcf     _led            ; If interrupt, turn off LED
            bcf     INTCON, 1       ; Clear interrupt flag
    
    ; Restore saved registers
            movf    psave, W
            movwf   PCLATH
            swapf   ssave, W
            movwf   STATUS
            swapf   wsave, F
            swapf   wsave, W
    
            retfie                  ; Return from interrupt
    
    endasm
    
    
    start:  TRISB = $7f             ' LED out, rest in
            OPTION_REG = $7f        ' Enable PORTB pullups
    
            INTCON = $90            ' Enable INTE interrupt
    
            led = 1                 ' Turn LED on
    
    waitloop: If led = 1 Then waitloop       ' Wait here while LED is still on
                                    ' If we get here, LED is off
            Pause   500             ' Wait .5 seconds
            Goto    start           ' Start over (turn LED back on)

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    You need to determine which you are using; PM or MPASM assembler.

    I doubt they use the exact same commands/syntax. I suspect you are using PM. MPASM is the preferred assembler today.

    Robert

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    Last edited by Archangel; - 26th October 2013 at 23:19.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    PIC is 18F46K22 @ 64MHz...
    Compiler is MPASM...

    Basically, i'm looking into an asm piece of coding to create correct timings for the WS2812B LEDs...
    When i used PBP to spit out the wave form from an arry the IF statement killed the timings. I appears to take ~30 cycles to run one command...

    The bit that i'm after is as follows...

    Code:
    00134	IF BSPTR < (NOOFWS2812 * 3 * 8) THEN
    	CMPGE?WCL	_BSPTR, 0F0h, L00007
    First line being the PBP line and the second line being the resultant assembler.
    The problem is I can not find any reference to what "CMPGE?WCL" is?

    I think, it's some sort of ALU compare with condition jump... but why is it taking so darn long on a high end MCU...

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    never mind... i just realised some of these commands are actually macros... thats why i can't find them...

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    ok, nope i'm lost again...

    The macro for CMPGT?WCL is...

    Code:
    CMPGT?WCL macro Win, Cin, Label
        if ((Cin) < 0)
            L?GOTO  Label
        else
          if ((Cin) < 0ffffh)
            MOVE?WW Win, R0
            MOVE?CB (Cin) >> 8, R1 + 1
            MOVE?CA low (Cin)
            L?CALL  CMPGT
            BIT?GOTO 0, STATUS, Z, Label
          endif
        endif
        endm
    So what is MOVE?WW, MOVE?CB and MOVE?CA oh and L?CALL and BIT?GOTO... Like... seriously!

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    Total guess; math calculations in IF?

    Robert

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    Hi,
    o what is MOVE?WW, MOVE?CB and MOVE?CA oh and L?CALL and BIT?GOTO... Like... seriously!
    They are more macros, move word to word, move constant to byte and so on. You should be able to find the actual code that those macros consists of at the same place you found the code for "top level" CMPGT?WCL macro.

    /Henrik.

  12. #12


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    Henrik, i already looked... It's not in the MAC file...
    It looks like it's embedded into PBP... which is not helpful...

  13. #13
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    They are in the .lib file for the device family you're targeting, from pbppic14.lib for example:
    Code:
    ;****************************************************************
    ;* MOVE?WW    : Macro - Move WORD variable into WORD variable   *
    ;*                                                              *
    ;* Input      : Win = WORD variable                             *
    ;* Output     : Wout = WORD variable                            *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************
    
    MOVE?WW macro Win, Wout
            MOVE?BB Win, Wout
            MOVE?BB (Win) + 1, (Wout) + 1
        endm
    Hope that's helpful....

    /Henrik.

  14. #14


    Did you find this post helpful? Yes | No

    Default Re: PBP 2.6C assembler

    Thats wonderful... I think that's everything i was missing...

    However why does the pic18 lib and macro's have bank checking routines when, according to the data-sheet the ram and program memory maps are laid out in a linear sequential manner and not in banks?
    Unless i'm missing something?

Similar Threads

  1. which Assembler
    By debutpic in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th July 2007, 23:43
  2. PBP and assembler mixing - weird goings-on?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th November 2006, 21:17
  3. Replies: 14
    Last Post: - 4th October 2006, 05:45
  4. Which assembler are you using?
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st November 2005, 20:34
  5. code assembler
    By gimmy in forum General
    Replies: 3
    Last Post: - 2nd May 2005, 01:10

Members who have read this thread : 1

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