PDA

View Full Version : PBP 2.6C assembler



comwarrior
- 26th October 2013, 01:48
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

aerostar
- 26th October 2013, 20:49
You need to read about assembly in the Picbasic Manual - that should give you the information you need to incorporate assembler in your program.

comwarrior
- 26th October 2013, 20:58
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...

aerostar
- 26th October 2013, 21:44
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.



' 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)

Demon
- 26th October 2013, 21:46
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

Archangel
- 26th October 2013, 22:54
Should be it. ww1.microchip.com/downloads/en/devicedoc/31029a.pdf

comwarrior
- 27th October 2013, 21:53
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...




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...

comwarrior
- 27th October 2013, 22:39
never mind... i just realised some of these commands are actually macros... thats why i can't find them...

comwarrior
- 28th October 2013, 00:25
ok, nope i'm lost again...

The macro for CMPGT?WCL is...




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!

Demon
- 28th October 2013, 00:37
Total guess; math calculations in IF?

Robert

HenrikOlsson
- 28th October 2013, 06:08
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.

comwarrior
- 28th October 2013, 16:16
Henrik, i already looked... It's not in the MAC file...
It looks like it's embedded into PBP... which is not helpful...

HenrikOlsson
- 28th October 2013, 16:22
They are in the .lib file for the device family you're targeting, from pbppic14.lib for example:

;************************************************* ***************
;* 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.

comwarrior
- 29th October 2013, 00:57
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?