I think the biggest reason is code space. With a subroutine there is only one instance of that subroutine in the code, all calls to it branch to that address. With a macro you are using something called 'inline code', every time you "call" the macro a copy of that code gets added, so 20 "calls" to the macro, 20 copies of that code. Now whether this is a bad thing or not is up to you and your circumstance. A macro consisting of 1 or 2 lines of code is mostly better then a subroutine, a macro 30 lines long is probably best done as a subroutine, but it's up to you. In timing critical applications it MAY be better to use a macro since you don't have the overhead of the subroutine call (which admitidly on a PIC is only two extra cycles, but that might be important in certain circumstances, in other micro's calling a subroutine can hit you with a relatvily large cycle penalty). TTYL > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Ray Gallas > Sent: Friday, February 15, 2002 04:00 > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: Basic question about macros > > > This is a beginner question, so I apologise if it seems dumb -- > I've been studying various assembly programs and I've noticed that many > of them invoke an assembler directive, "MACRO". > > Now from what I can see (and perhaps I'm missing something here), they > seem to fill essentially the same role as a subroutine. That is, they're > a predefined set of commands, which at some point in your program, you > would have to, well, *define*. It seems to me that doesn't really save > you much work over just calling a subroutine, which you also write out. > > Obviously, MACROs must have some good reason for existing, otherwise, > why would anyone use them? So my question is, what's the difference > between a MACRO, and just using a subroutine? Why would one choose one > over the other in a given situation? > > Thanks for any clues! > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu