> I agree with the last, but IMHO asm offers a very weak environment for > re-useable code, because there is no automatic > - removal of un-used code The librarian and linker do that, independent of language. > - static-stack-like variable allocation I'm not sure what you mean here. I don't know how to envision a static variable that is stack-like. However, I have a method of RAM useage on PICs that has worked very nicely accross dozens of projects and is easy to implement. It works well in assembler, but could just as easily be applied to a higher level language (for all I know it has been). I reserve part of the global RAM as "general registers", much like the general registers of other machines. 13 of these (REG0 - REG12) are usually allocated on the 16 family in the 70h - 7Fh global region. They are used as call and return arguments to subroutines, and for temporary scratch inside a subroutine. By convention, subroutines preserve all these registers to the caller except those that are explicitly documented to hold return values. A software stack is used to save/restore those general registers used by a subroutine on entry and return. All this is automated with the GLBSUB subroutine entry macro, and the LEAVEREST subroutine end macro. These and others can be found in STD.INS.ASPIC at http://www.embedinc.com/pic. The general registers are usually more than enough for all the temporary local storage of a subroutine. Therefore, the only RAM reserved by each module is the persistant state it needs to maintain. This scheme makes very efficient use of RAM, and effective use of the limited global memory. Of course one size doesn't fit all, so on relatively rare occasions a subroutine may define a static variable that is really local, use an overlay, trash some general registers on return, or whatever. Fortunately in assembler you can break the rules and do what you need to when you need to. But again, this happens quite rarely and of course is well documented when it does. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body