I am trying to design a routine that when called might be in ether of USER or SUPERVISOR privilege modes and, at some point will need to protect a heap memory allocation by temporarily switching to SUPERVISOR mode if not already there.
Before returning, the routine should be back in the privilege mode it was called-in.
Reading the 68k Programmers manual, I note that on a 68000/68008, I could safely use the MOVE SR, <ea> instruction (and then test the appropriate U/S bit in the destination) regardless of the current privilege mode, but that on the 68010 etc, this instruction is itself privileged and would cause an exception if executed in USER mode.
Ideally, I'd like the resultant code to be agnostic to processor generation (real or emulated)...
Has anyone already thought a neat and reliable approach to this?
Happy Easter Monday
