1
0

test-i386-muldiv.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. void glue(glue(test_, OP), b)(long op0, long op1)
  2. {
  3. long res, s1, s0, flags;
  4. s0 = op0;
  5. s1 = op1;
  6. res = s0;
  7. flags = 0;
  8. asm ("push %4\n\t"
  9. "popf\n\t"
  10. stringify(OP)"b %b2\n\t"
  11. "pushf\n\t"
  12. "pop %1\n\t"
  13. : "=a" (res), "=g" (flags)
  14. : "q" (s1), "0" (res), "1" (flags));
  15. printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CC=%04lx\n",
  16. stringify(OP) "b", s0, s1, res, flags & CC_MASK);
  17. }
  18. void glue(glue(test_, OP), w)(long op0h, long op0, long op1)
  19. {
  20. long res, s1, flags, resh;
  21. s1 = op1;
  22. resh = op0h;
  23. res = op0;
  24. flags = 0;
  25. asm ("push %5\n\t"
  26. "popf\n\t"
  27. stringify(OP) "w %w3\n\t"
  28. "pushf\n\t"
  29. "pop %1\n\t"
  30. : "=a" (res), "=g" (flags), "=d" (resh)
  31. : "q" (s1), "0" (res), "1" (flags), "2" (resh));
  32. printf("%-10s AH=" FMTLX " AL=" FMTLX " B=" FMTLX " RH=" FMTLX " RL=" FMTLX " CC=%04lx\n",
  33. stringify(OP) "w", op0h, op0, s1, resh, res, flags & CC_MASK);
  34. }
  35. void glue(glue(test_, OP), l)(long op0h, long op0, long op1)
  36. {
  37. long res, s1, flags, resh;
  38. s1 = op1;
  39. resh = op0h;
  40. res = op0;
  41. flags = 0;
  42. asm ("push %5\n\t"
  43. "popf\n\t"
  44. stringify(OP) "l %k3\n\t"
  45. "pushf\n\t"
  46. "pop %1\n\t"
  47. : "=a" (res), "=g" (flags), "=d" (resh)
  48. : "q" (s1), "0" (res), "1" (flags), "2" (resh));
  49. printf("%-10s AH=" FMTLX " AL=" FMTLX " B=" FMTLX " RH=" FMTLX " RL=" FMTLX " CC=%04lx\n",
  50. stringify(OP) "l", op0h, op0, s1, resh, res, flags & CC_MASK);
  51. }
  52. #if defined(__x86_64__)
  53. void glue(glue(test_, OP), q)(long op0h, long op0, long op1)
  54. {
  55. long res, s1, flags, resh;
  56. s1 = op1;
  57. resh = op0h;
  58. res = op0;
  59. flags = 0;
  60. asm ("push %5\n\t"
  61. "popf\n\t"
  62. stringify(OP) "q %3\n\t"
  63. "pushf\n\t"
  64. "pop %1\n\t"
  65. : "=a" (res), "=g" (flags), "=d" (resh)
  66. : "q" (s1), "0" (res), "1" (flags), "2" (resh));
  67. printf("%-10s AH=" FMTLX " AL=" FMTLX " B=" FMTLX " RH=" FMTLX " RL=" FMTLX " CC=%04lx\n",
  68. stringify(OP) "q", op0h, op0, s1, resh, res, flags & CC_MASK);
  69. }
  70. #endif
  71. #undef OP