Created
February 15, 2013 13:31
-
-
Save apskii/4960378 to your computer and use it in GitHub Desktop.
gcc -std=c99 -ffixed-ebx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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