Cooler_

lol calc

Feb 8th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. /*
  2.  *
  3.  *   gcc -m32 -o code code.c
  4.  *   author: Antonio Costa aka Cooler_
  5.  *   contact: [email protected]
  6.  *   bugsec.com.br
  7.  *  
  8.  *   very simple calc test
  9.  *   */
  10. #include <stdio.h>
  11.  
  12. #define w printf
  13. #define foo (int,int)
  14. #define num "%d\x0a"
  15.  
  16. int add foo;
  17. int sub foo;
  18. int mul foo;
  19. int div foo;
  20.  
  21. void
  22. main(void)
  23. {
  24.  register int a=5,b=30;
  25.  w("A=%d B=%d \x0a",a,b);
  26.  w(num, add(a,b))&w(num, sub(a,b));
  27.  w(num, mul(a,b))&w(num, div(a,b));
  28. }
  29.  
  30. int add(int a, int b)
  31. {  
  32.  __asm__("movl 8(%ebp), %ebx\n"
  33.      "movl 12(%ebp), %eax\n"
  34.      "addl %ebx, %eax\n");
  35. }
  36.  
  37. int sub(int a, int b)
  38. {  
  39.  __asm__("movl 8(%ebp), %ebx\n"
  40.      "movl 12(%ebp), %eax\n"
  41.      "subl %ebx, %eax\n");
  42. }
  43.  
  44. int mul(int a, int b)
  45. {  
  46.  __asm__("movl 8(%ebp), %ebx\n"
  47.      "movl 12(%ebp), %eax\n"
  48.      "imul %ebx, %eax\n");
  49. }
  50.  
  51. int div(int a, int b)
  52. {  
  53.  __asm__("movl 8(%ebp), %ebx\n"
  54.      "movl 12(%ebp), %eax\n"
  55.      "divl %ebx, %eax\n");
  56. }
Advertisement
Add Comment
Please, Sign In to add comment