> Unfortunately, for the PIC16f886, the only access to the stack happens wi= th the call, > interrupt and return instructions. There is no other access. > I think the only option is to instrument round the instructions in > ones own code. In a previous life (before Jal) I experimented with the MPLAB macro=20 facilities. It turned out to be possible (using some weird combination=20 of #define and .macro, I forgot which) to have MPASM replace assembler=20 instructions like CALL X with an expansion of my choice. A usefully=20 expansion could be incf level, f CALL X decf level, f (The devil is in the details: preventing the CALL inside the macro from=20 being re-expanded. An easier option would be to insert the hex code for=20 the CALL.) There are of course some nasty details: call and CALL, LCALL, and=20 coditionally skipping the call. Those are left as an exercise to the read := ) Getting excited, you could insert code checks for a stack overflow, and=20 if so, writes the line number to some error logging channel. A problem: a stack overflow is harmless. It is the stack *underflow*=20 that kills your application. Instrumenting RETURN is probably no=20 problem, but instrumenting RETLW instructions might cause problems with=20 jump tables. An if you use a HLL you will need access to the sources of the compiler.=20 With anything but Jal that might be a problem :) --=20 Wouter van Ooijen -- ------------------------------------------- Van Ooijen Technische Informatica: www.voti.nl consultancy, development, PICmicro products docent Hogeschool van Utrecht: www.voti.nl/hvu --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .