Skip to content

Instantly share code, notes, and snippets.

@apskii
Created February 15, 2013 13:31
Show Gist options
  • Save apskii/4960378 to your computer and use it in GitHub Desktop.
Save apskii/4960378 to your computer and use it in GitHub Desktop.
gcc -std=c99 -ffixed-ebx
#include <stdio.h>
#include <stdint.h>
uint32_t quux(void) {
uint32_t ebx;
__asm ("inc %ebx");
__asm ("mov %%ebx, %0" : "=r"(ebx));
return ebx;
}
void kzyf(void) {
printf("%d\n", quux());
}
int main(void) {
__asm ("mov $0, %ebx");
printf("%d\n", quux()); // => 1
printf("%d\n", quux()); // => 2
quux(); // =( 3 )>
kzyf(); // => 4
printf("%d\n", quux()); // => 5
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment