Page 1 of 1

macros inside macros

Posted: Fri Jun 29, 2012 6:56 am
by brandonb
concern arises from general paranoia on topic title... what are the rules on the above of what i cannot put in a personally made macro, ...suppose i drop in a macro and name it "stuff", can i put in 57 eeprom macros inside of it? i've done this kind of thing with lcd macros with out issues to keep things nice and tidy, but i have over a thousand eeprom macros (icons) i have to deal with and i would perfer to keep them neatly organized in 4 personal write to macros and 4 personal retreive from macros, is this ok or can this cause corruption, figured i would ask before going through all the work and have to change it incase i had some weird glitch

Re: macros inside macros

Posted: Fri Jun 29, 2012 9:48 am
by Benj
Hello Brandon,

The general limitation with 16F 8-bit PICs is that the stack is restricted to 8 jumps away from the main.

So if you imagine this.

main -> LCD Macro -> LCD Component Macro -> Low Level LCD code

This shows 3 jumps away from the main code. If you go too far away from main then the program will be unable to find it's way back to the main and can cause corruption or lockups.

Having a large number of component macro calls in a single macro should not cause any problems at all as long as you do not break the 8 jump rule.

AVRs, ARMs and 16-bit PICs do not suffer from this issue and I think the jump count for 18F PIC devices is larger then 8.