Tom,
Declaring the variables as volatile has stopped it from crashing, I can understand why it would stop it but I would still like to know why the compiler feels the need to optimise them away in the first place and how I can tell it not to.
Sorry to be a newbie about all this, I've come into embedded from a slightly sideways angle so have a few gaping holes in my knowledge. One thing I'm slightly mystfied about is what I can do in the interrupt handler to prevent stack trashing - currently I'm using Freescale's example code (qspi.c, uart.c, etc.) with their own interrupt routines and handler with very few changes.
I've looked in the .lcf files to see if I can increase the stack size (with no success currently) so will explore that too.
Fundamentally I think that now the compiler is behaving it's stopped the stack trashing problem, so until it falls over again I will assume the ISR code is reasonably sane. I realise that's quite a big assumption 