We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
C8051F360
It has recently occured to me that the default instruction 0xFF that exists in all un-used flash memory is not a NOP instruction.
I understand that flash memory just works that way, and the legacy of the 8051 instruction set must be maintained, but what happens if the stack corrupts the program counter? Would it not be better to have it executing NOPs instead of MOV R7,A instructions? (assuming it landed on empty flash-ROM)
I suppose it could execute code from anywhere - with varying degrees of dangerousness.
I don't know the answer. Any thoughts?
I think that it is easier to just initialize your flash memory to a "Safer" value rather then change the instruction set of the 8051.
Yes, it's generally best to assume that the processor instruction set is fixed...
Can we call that the Second Moore's Law...?
;-)
Would it not be better to have it executing NOPs instead of MOV R7,A instructions?
No, it wouldn't be. If the processor starts executing garbage, the program is messed up already. And if it starts doing so somewhere behind the actual program code, it doesn't matter whether it executes a NOP or a MOV R7, A since it will hit the reset vector eventually anyway.
However, you're free to fill the unused code space with whatever data you want.
I would tend to agree with that - that is doesn't matter. Either case it is running out of control.
Filling the un-used space with something other than 0xFF is going to take much longer to load the part. I'd rather not do that.
Also, MOV R7, A is still fairly "safe", since it doesn't mess with any port pins and hence can't turn on rotary saws, remove radiation safety interlocks or turn on rocket motors. ;)