Skip to content

Instantly share code, notes, and snippets.

@Nkawu
Created June 11, 2019 22:35
Show Gist options
  • Save Nkawu/5b18d383a6fddf552035107efff6d96f to your computer and use it in GitHub Desktop.
Save Nkawu/5b18d383a6fddf552035107efff6d96f to your computer and use it in GitHub Desktop.
perl script running inline C running inline ASM
#!/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