PIC macro mov reg,lit or mov lit,reg

I personally don't like macros that look like actual instructions. An experienced programmer could look for a bug all day long and not find it because they don't realise that mov PORTA,03 corrupts W. If I had to choose a name for such a macro it would be something like _init PORTA,3 or _Store 3,PORTA or _Set PORTA,3 or _Poke PORTA,3. The underscore being there to remind me that it is a macro. I know that MPLAB differentiates by changing colour but that is lost when using a different text editor or posting the code on the internet etc.

Mike.
 
Anything is OK if it's for your own personal use, if you intend publishing it then I think the possible confusion weighed against saving 1 line of typing just isn't worth it.

Mike.
 
It simply makes the final code listing shorter and eaiser to read. Also has the banksel. (leaves it in the register bank though)

Code:
_mov     macro     register, literal      ;_mov <register>, <literal>
         movlw     literal                ;W = literal
         banksel   register               ;make sure it's in the right bank
         movwf     register               ;register = W
         endm
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…