gcc, inline assembly - pushad/popad missing?

2019-02-26 15:52发布

问题:

Any way to avoid having to copy-paste the pushad/popad instruction body into my code?

Because gcc (current flags: -Wall -m32) complains that

__asm__("pushad;");

Error: no such instruction: `pushad'

__asm__("popad;");

Error: no such instruction: `popad'

回答1:

GCC use AT/T assembly syntax, while pushad/popad are Intel convention, try this:

__asm__("pushal;");
__asm__("popal;");