If you are using GCC it is not difficult nor dangerous, you can enforce a variable into a specific register, you just declare it like this:
register unsigned int n asm(''r2''); You may also need to declare the variable ''volatile'' or the compiler may optimize out assignments to the variable if it is not explicitly used after the assignment. GCC is very effective if you need to do inline assembler. Giovanni --- ChibiOS/RT http://chibios.sourceforge.net
If you want to exercise this level of control you simply need to write the function in assembler. In C you could cast an address to a function call and also provide it with parameters. This would in effect permit you to define r0-r4, and pc. You could also use assembler inline within your function(s).
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Thanks, I would do this but I cannot grantee we will be using GCC where this code is going to run.
I ended up doing something similar to what clive1 suggested, which is just copy all the 4 parameters into the registers whether they are used by the function or not , which seems to work well enough, eg: