Why is this inline assembly not working with a separate asm volatile statement for each instruction?

前端 未结 3 1322
没有蜡笔的小新
没有蜡笔的小新 2020-12-19 02:12

For the the following code:

long buf[64];

register long rrax asm (\"rax\");
register long rrbx asm (\"rbx\");
register long rrsi asm (\"rsi\");

rrax = 0x34         


        
3条回答
  •  眼角桃花
    2020-12-19 02:28

    The compiler uses registers, and it may write over the values you have put in them.

    In this case, the compiler probably uses the rbx register after the rrbx assignment and before the inline assembly section.

    In general, you shouldn't expect registers to keep their values after and between inline assembly code sequences.

提交回复
热议问题