What's the purpose of the CIL nop opcode?

前端 未结 19 1327
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 10:42

I\'m going through MSIL and noticing there are a lot of nop instructions in the MSIL.

The MSDN article says they take no action and are used to fill space if the opc

19条回答
  •  星月不相逢
    2020-12-07 11:02

    50 years too late but hey.

    Nop's are useful if you are typing assembly code by hand. If you had to remove code, you could nop the old opcodes.

    similary, you could insert new code by overwriting some opcode and jump somewhere else. There you put the overwritten opcodes, and insert your new code. When ready you jump back.

    Sometimes you had to use the tools which were available. In some cases this was just a very basic machinecode editor.

    Nowadays with compilers the techniques make no sense whatsoever anymore.

提交回复
热议问题