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...
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...
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)
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
Should be it. ww1.microchip.com/downloads/en/devicedoc/31029a.pdf
Last edited by Archangel; - 27th October 2013 at 00: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.
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...
First line being the PBP line and the second line being the resultant assembler.Code:00134 IF BSPTR < (NOOFWS2812 * 3 * 8) THEN CMPGE?WCL _BSPTR, 0F0h, L00007
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...
never mind... i just realised some of these commands are actually macros... thats why i can't find them...
ok, nope i'm lost again...
The macro for CMPGT?WCL is...
So what is MOVE?WW, MOVE?CB and MOVE?CA oh and L?CALL and BIT?GOTO... Like... seriously!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
Total guess; math calculations in IF?
Robert
Bookmarks