Skip to content

Instantly share code, notes, and snippets.

@ir4y
Created March 15, 2015 14:32
Show Gist options
  • Select an option

  • Save ir4y/c1bcb7f10708192d14a1 to your computer and use it in GitHub Desktop.

Select an option

Save ir4y/c1bcb7f10708192d14a1 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void add(unsigned long long *dst, unsigned long long *src){
asm ("movq %0, %%rbx\n"
/*"addq $8, %%rbx\n"*/
"movq (%%rbx), %%rax\n"
"addq (%1), %%rax\n"
"mov %%rax, (%%rbx)\n"
/*"adcq $0, %%rax\n"*/
/*"addq $8, %%rbx\n"*/
/*"mov %%rax, (%%rbx)\n"*/
: /* No outputs. */
: "r" (dst), "r" (src)
: "rax", "rbx");
}
int main(){
unsigned long long a[3], b[3];
a[0]=1;
a[1]=-1;
a[2]=0;
b[0]=1;
b[1]=1;
b[2]=0;
add(a,b);
printf("%x %x %x\n",a[0],a[1],a[2]);
printf("%x %x %x\n",b[0],b[1],b[2]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment