Mixing C with Assembler: Assembly code before push instructions in a function

That sounds viable, although I don't know enough about the behaviour of those temp registers to know how long their contents will be preserved. For example, if they're trampled by a push operation then using one of these as a scratch area while you do the push would not work very well. :slight_smile:

The only way I can think of to achieve that solution is to write your ISR handler in assembler, have this save your I/O register in your temp register and then call a 'C'/C++ function for whatever logic you want to code in higher level languages. You sound as if you're comfortable writing in assembler, but if you aren't you could get a starting point by listing the assembler generated for your existing handler.