Created
June 11, 2019 22:35
-
-
Save Nkawu/5b18d383a6fddf552035107efff6d96f to your computer and use it in GitHub Desktop.
perl script running inline C running inline ASM
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
#!/usr/bin/env perl | |
use Inline 'C'; | |
my $a = 10; | |
my $b = 15; | |
print "$a + $b = ", add_c_asm($a, $b), "\n"; | |
__END__ | |
__C__ | |
int add_c_asm(int foo, int bar) { | |
asm volatile ( "addl %%ebx,%%eax" | |
:"=a"(foo) | |
:"a"(foo), "b"(bar) | |
); | |
return foo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment