binutils: describe gas hello world hack

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-05 00:00:02 +00:00
parent b60784d59b
commit 23f80c2310
3 changed files with 93 additions and 6 deletions

View File

@@ -2,15 +2,15 @@
#include <inttypes.h>
int main(void) {
uint32_t in = 1;
uint32_t out = 0;
uint64_t in = 0xFFFFFFFF;
uint64_t out = 0;
__asm__ (
"mov %[in], %%eax;"
"inc %%eax;"
"mov %%eax, %[out]"
"mov %[in], %%rax;"
"inc %%rax;"
"movq %%rax, %[out]"
: [out] "=g" (out)
: [in] "g" (in)
: "%eax"
: "rax"
);
assert(out == in + 1);
}

View File

@@ -0,0 +1,18 @@
#include <assert.h>
#include <inttypes.h>
int main(void) {
#if 0
uint64_t in = 0xFFFFFFFF;
uint64_t out = 0;
__asm__ (
"mov %[in], %%rax;"
"myinc %%rax;"
"movq %%rax, %[out]"
: [out] "=g" (out)
: [in] "g" (in)
: "rax"
);
assert(out == in + 1);
#endif
}