This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Default 0xFF in unused flash memory (MOV R7,A)

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?

Parents
  • 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.

Reply
  • 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.

Children