News for hackers. Stuff that matters.
Re:Hello world in C inline assembly (2020) by rep_lodsb on Monday June 17, 2024 @03:51AM (#40703243)
With an older version, it works (as long as there is no optimization at least, with -O2 all the register init code disappears):

$ gcc -v

... gcc version 10.2.1 20210110 (Debian 10.2.1-6)

    0000000000001125 <main>:
        1125: 55                    push   %rbp
        1126: 48 89 e5              mov    %rsp,%rbp
        1129: b8 01 00 00 00        mov    $0x1,%eax
        112e: bf 01 00 00 00        mov    $0x1,%edi
        1133: 48 8d 35 ca 0e 00 00  lea    0xeca(%rip),%rsi        # 2004 <_IO_stdin_used+0x4>
        113a: ba 0e 00 00 00        mov    $0xe,%edx
        113f: 0f 05                 syscall 
No idea why a newer version produces worse code in this case (though of course, this way of doing inline assembly isn't "correct" anyway, so nasal demons may result)

There are no comments on this comment yet.