===PIC Macros... another set... just what the internet needs.=== Yet another list of PIC macros. These are ones I use a lot that make RISC assembler a bit easier (rolls eyes). I use these all the time in my code so if you take anything from this section, you'll probably need these too. They just add some nice functionality like compare and skips. Also emulates some later opcodes e.g MOVFF ; common macros ; a lot of these bring Z80-like "opcodes" ; which makes code much more readable (RISC opcodes can be horrible) ; NOLIST ; a two cycle NOP with only a single word NOOP MACRO GOTO $+1 ENDM ; compare register with value. trashes W, Zflag set if values are the same CP MACRO REGF,VAL MOVLW VAL SUBWF REGF,W ENDM ;set carry flag SCF MACRO BSF STATUS,C ENDM ;clear carry flag CCF MACRO BCF STATUS,C ENDM ;set zero flag SZF MACRO BSF STATUS,Z ENDM ;clear zero flag CZF MACRO BCF STATUS,Z ENDM ;move literal to file register - trashes W MOVLF MACRO LITERAL,REG MOVLW LITERAL MOVWF REG ENDM ;move file to file - trashes W MOVFF MACRO REGSRC,REGDEST MOVFW REGSRC MOVWF REGDEST ENDM ;bitwise shortcuts just a bit clearer than bcf & bsf ; set a pin Lo LO MACRO REGX,BITY BCF REGX,BITY ENDM ;set a pin Hi HI MACRO REGX,BITY BSF REGX,BITY ENDM ; pulse a pin, don't care how long, just want the edges HIPULSE MACRO REGX,BITY BSF REGX,BITY BCF REGX,BITY ENDM LOPULSE MACRO REGX,BITY BCF REGX,BITY BSF REGX,BITY ENDM ; program flow conditionals ; skip the next instruction on specific conditions ; bit in register SKIPHI MACRO REGX,BITY BTFSS REGX,BITY ENDM SKIPLO MACRO REGX,BITY BTFSC REGX,BITY ENDM ; zero condition SKIPZ MACRO BTFSS STATUS,Z ENDM SKIPNZ MACRO BTFSC STATUS,Z ENDM ; carry condition SKIPC MACRO BTFSS STATUS,C ENDM SKIPNC MACRO BTFSC STATUS,C ENDM ; jump on zero condition JMPZ MACRO K BTFSC STATUS,Z GOTO K ENDM JMPNZ MACRO K BTFSS STATUS,Z GOTO K ENDM ; jump on carry condition JMPC MACRO K BTFSC STATUS,C GOTO K ENDM JMPNC MACRO K BTFSS STATUS,C GOTO K ENDM ; call on zero condition CALLZ MACRO K BTFSC STATUS,Z CALL K ENDM CALLNZ MACRO K BTFSS STATUS,Z CALL K ENDM ; call on carry condition CALLC MACRO K BTFSC STATUS,C CALL K ENDM CALLNC MACRO K BTFSS STATUS,C CALL K ENDM ; return on zero condition RETZ MACRO BTFSC STATUS,Z RETURN ENDM RETNZ MACRO BTFSS STATUS,Z RETURN ENDM ; return on carry condition RETC MACRO BTFSC STATUS,C RETURN ENDM RETNC MACRO BTFSS STATUS,C RETURN ENDM LIST