Created
October 27, 2015 23:44
-
-
Save mr1337357/50dcc6d0a16790a862b2 to your computer and use it in GitHub Desktop.
This file contains 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> | |
#define go(n) __asm__("jmp *%%rax\n"::"a"(n)) | |
void sw(int n) { | |
volatile void *dests[4] = {&&l0,&&l1,&&l2,&&l3}; | |
go(dests[n]); | |
l0: | |
printf("zero\n"); | |
goto end; | |
l1: | |
printf("one\n"); | |
goto end; | |
l2: | |
printf("two\n"); | |
goto end; | |
l3: | |
printf("three\n"); | |
goto end; | |
end: | |
return; | |
} | |
int main() { | |
int i; | |
for(i=0;i<4;i++) { | |
sw(i); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment