You might want to try making includes NOT processor specific. Otherwise you go back to that multiple version problem again. If you need a new file for every chip you use, you'll be writing include files for ever.Sure, you can pop in and out of asm whenever you want, but passing arguments can be a little trickier. Let's go back to the first exampleis there any way to make a macro in asm, then put PBP code inside the macro?This could also be done this wayCode:ASM TMR1_ON macro bsf T1CON, TMR1ON endm TMR1_OFF macro bcf T1CON, TMR1ON endm ENDASMBut, as you can see, it's harder to read that way, but will compile to the exact same thing.Code:ASM TMR1_ON macro ENDASM T1CON.0 = 1 ' PBP statement in a macro ASM endm TMR1_OFF macro ENDASM T1CON.0 = 0 ASM endm ENDASMLet's try the LCD thing with PBP statements too. This may not be the most efficient way to handle the LCD, but it does answer the specific question...so that LCDCMD Clear, Line1, Right would have the effect of LCDOUT $FE, $01, $FE, $80, $FE, $14Then to use the macro you can do it this way...Code:Clr CON 1 system Home CON 2 system Line1 CON 4 system Line2 CON 8 system Line3 CON 16 system Line4 CON 32 system CurOFF CON 64 system CurBlink CON 128 system CurUL CON 256 system ASM LCDCMD macro options if (options & Clr) > 0 ; Clear Screen ENDASM LCDOUT $FE, $01 ASM endif if (options & Home) > 0 ; Home Cursor ENDASM LCDOUT $FE, $02 ASM endif if (options & Line1) > 0 ; Move to Line 1 ENDASM LCDOUT $FE, $80 ASM endif if (options & Line2) > 0 ; Move to Line 2 ENDASM LCDOUT $FE, $C0 ASM endif if (options & Line3) > 0 ; Move to Line 3 ENDASM LCDOUT $FE, $90 ; may be $94 on some displays ASM endif if (options & Line4) > 0 ; Move to Line 4 ENDASM LCDOUT $FE, $D0 ; may be $D4 on some displays ASM endif if (options & CurOFF) > 0 ; Turn Off Cursor ENDASM LCDOUT $FE, $0C ASM endif if (options & CurBlink) > 0 ; Blinking Cursor ENDASM LCDOUT $FE, $0F ASM endif if (options & CurUL) > 0 ; Underline Cursor ENDASM LCDOUT $FE, $0E ASM endif endm ENDASMAny of the options can be combined together, and only the options you use will actually create code.Code:@ LCDCMD Clr + CurBlink ; Clear screen and turn on blinking cursor '-- OR -- @ LCDCMD Clr + Line2 + CurOFF ; Clr screen, Move to Line2 and turn off cursor
HTH,
Darrel




Bookmarks