PIC macro mov reg,lit or mov lit,reg

Status
Not open for further replies.
Personally I like the look of the intel and parallax version of mov ie:

mov PORTA, 0x03

Vs

mov 0x03, PORTA

Just reads better but may seem backwards to some.
What do you prefer?
 
Last edited:
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
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…