How many ways to set a register to zero?

前端 未结 8 1087
有刺的猬
有刺的猬 2020-12-02 17:00

I\'m curious how many ways are there to set a register to zero in x86 assembly. Using one instruction. Someone told me that he managed to find at least 10 ways to do it.

8条回答
  •  余生分开走
    2020-12-02 17:40

    Of course, specific cases have additional ways to set a register to 0: e.g. if you have eax set to a positive integer, you can set edx to 0 with a cdq/cltd (this trick is used on a famous 24 byte shellcode, which appears on "Insecure programming by example").

提交回复
热议问题