Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC macro mov reg,lit or mov lit,reg

Status
Not open for further replies.
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:D 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
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top