Extending the xPortPendSVHandler save area for ARM_CM0

I’m not sure. Here’s what the datasheet says:

To support save and restore on interrupt handler entry/exit (or on e.g. an RTOS context switch), the result registers are
also writable. Writing to a result register will cancel any operation in progress at the time. The DIV_CSR.DIRTY flag can
help make save/restore more efficient: this flag is set when any divider register (operand or result) is written to, and
cleared when the quotient is read.

I think that’s an optimization I could look at in the future.

The SDK module pico_divider https://github.com/raspberrypi/pico-sdk/tree/master/src/common/pico_divider/include/
pico/divider.h provides both the AEABI implementation needed to hook the C / and % operators for both 32-bit and 64-bit
integer division, as well as some additional C functions that return quotients and remainders at the same time. All of
these functions correctly save and restore the hardware divider state (when dirty) so that they can be used in either user
or IRQ handler code.

The SDK book says this:

47 // For a really fast divide, you can use the inlined versions... the / involves a function
  call as / always does
48 // when using the ARM AEABI, so if you really want the best performance use the inlined
  versions.
49 // Note that the / operator function DOES use the hardware divider by default, although
  you can change
50 // that behavior by calling pico_set_divider_implementation in the cmake build for your
Raspberry Pi Pico C/C++ SDK
  target.
51 printf("%d / %d = (by operator %d) (inlined %d)\n", dividend, divisor,
52 dividend / divisor, hw_divider_s32_quotient_inlined(dividend, divisor));
53
54 // Note however you must manually save/restore the divider state if you call the inlined
methods from within an IRQ
55 // handler.
56 hw_divider_state_t state;
57 hw_divider_divmod_s32_start(dividend, divisor);
58 hw_divider_save_state(&state);
59
60 hw_divider_divmod_s32_start(123, 7);
61 printf("inner %d / %d = %d\n", 123, 7, hw_divider_s32_quotient_wait());
62
63 hw_divider_restore_state(&state);
64 int32_t tmp = hw_divider_s32_quotient_wait();
65 printf("outer divide %d / %d = %d\n", dividend, divisor, tmp);

My thought was that if I could copy the behavior of hw_divider_save_state and hw_divider_restore_state, that should do the job. I’m hoping to get some more advice from the Raspberry people.