G'day piclisters I have just discovered a couple of simple macros that I'd like comments on. But first the problem. I use #define to define my port pins because I don't want to have to remember which port they belong to (plus it is easier!). example: #define SDATA RB,5 This is well and good. The problem arises when I want to manipulate a bit mask based on that pin. The wonderful expression someone came up with: iorlw b'00000001' << pin requires the form of port,pin to work. So, for all these years, I've been mixing the two styles in my code and avoiding port pin bit masks whenever possible. It finally occured to me today that a #define statement already has the information needed to make a bit mask. All it takes is a couple of one line macros as follow: sethi MACRO port,pin iorlw b'00000001' << pin endm setlo MACRO port,pin andlw ~ (b'00000001' << pin) endm Usage is simple: way up near the front of my source: #define POT GPIO,5 (rest of pin definitions) DDR EQU b'00110000' ;default port pin DDR down somewhere in the code: ;generate bit mask for RC timer pin movlw DDR ;set pin to o/p setlo POT tris GPIO . . . movlw DDR ;set pin back to input sethi POT trisi GPIO The nice thing about this is that it doesn't matter what the DDR constant gets changed to - I explicitly set the tris bit for that pin. Comments anyone? I'm not particularily happy with my chosen macro names (sethi and setlo) but thats what I came up with off the top of my head. I've tested this with the DOS version 1.40 of MPASM - it generated the same opcodes as explicit andlw and iorlw statements. dwayne Dwayne Reid Trinity Electronics Systems Ltd Edmonton, Alberta, CANADA (403) 489-3199 voice (403) 487-6397 fax