This is all very debatable, some may find this easy to read others like me, go completely banana's scrolling from the code portion to the equates portion. for me it would be easiest to have GP4 equ 1<<4 GP5 equ 1<<5 .... movlw GP4 | GP5 ; mask OR movlw b'00110000' ; mask: GP4 | GP5 which would require no scrolling and be perfectly clear. Peter van Hoof ------------- > > You'd probably be better off reading the MPASM documentation on the 'equ' > directive. But I'll give a very brief summary. > > First, GP4 and GP5 have to be defined because the assembler has no idea > what they are. Most constants are defined with the equ (short for equate) > directive. So I'd probably define GP4 and GP5 like this: > > GP4 equ 1<<4 > GP5 equ 1<<5 > > This associates the value 1<<4 or 0x10 with the label GP4 and 1<<5 or 0x20 > with the label GP5. Once this is done, you can use the constants GP4 and > GP5 and the assembler will replace them with thier equivalent numerical > values. > > So, > > MASK equ GP4 | GP5 > > will assign the logical OR (that's what the '|' means) of GP4 and GP5 to > MASK. Since GP4 and GP5 are equal to 0x10 and 0x20, MASK will become 0x10 > | 0x20 which is 0x30. Is that clear? > > Now you could've just said: > > MASK equ 0x30 > > or simpler yet: > > movlw 0x30 > instead of > movlw MASK > > and everything would've worked just fine. However, 6 months down the road > when you have to go and fix a bug in this code you're going to need every > bit of help you can get. These symbols will make the code more readable > and comprehensible. It doesn't slow the execution down at all. So use them > where ever possible!