This is for i86 and x86_64 types but with a bit of poking around you can probably find a similar way to do this with other CPUs.
Note: This asm requires 'sigaction'. (See the test code. And bear in mind that this is not an attempt to create a full-blown system of signal handlers. Check the libc docs for 'sigaction' for ideas on how you can use something like this for a seed for a more extensive application.)
There used to be a lot of cool little programs for the...