# How to find macro “usage position” in microchip MPLab

I'm having troubles when MPLab shows me error within a macros (with assembly language). It gives the line number of where macros is defined. That's not very helpful if the macros is working fine, but the parameters passed are wrong. Is there a way to trace the macros back? (by "trace" I don't mean "runtime debug trace")

P.S. Note that this is not a question if macros should or should not be used.

For example let's have this macro (defined in an include file macro.inc):

loadWreg   macro x
movlw x
endm


Then use in in 3 .asm files more than 10 times. One usage is wrong:

  loadWreg 0xFFFF    ; 16 bit value can't be loaded in WREG


Microchip shows the error in macro.inc on line with movlw x. How do I know where I passed wrong parameter to the macro?

• You immediate problem is that you tried to stuff a 16 bit value into a 8 bit register. FFFFh doesn't fit into the 8 bit W register. Also, why use a macro for something that can be done natively in a single instruction. LoadWreg does nothing additional for you. It just makes your code harder to read and dependent on the macro file you are using. – Olin Lathrop Oct 6 '12 at 23:19