Commit a300e69170319f9736b67cfcb9dc0c05cf175769

Authored by bellard
1 parent 1a9353d2

cmpxchg test


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@30 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 28 additions and 0 deletions
tests/test-i386.c
... ... @@ -701,6 +701,18 @@ void test_segs(void)
701 701 #op, op0, op1);\
702 702 }
703 703  
  704 +#define TEST_CMPXCHG(op, size, opconst, eax)\
  705 +{\
  706 + int op0, op1;\
  707 + op0 = 0x12345678;\
  708 + op1 = 0xfbca7654;\
  709 + asm(#op " %" size "0, %" size "1" \
  710 + : "=q" (op0), opconst (op1) \
  711 + : "0" (op0), "1" (op1), "a" (eax));\
  712 + printf("%-10s EAX=%08x A=%08x C=%08x\n",\
  713 + #op, eax, op0, op1);\
  714 +}
  715 +
704 716 void test_xchg(void)
705 717 {
706 718 TEST_XCHG(xchgl, "", "=q");
... ... @@ -718,6 +730,22 @@ void test_xchg(void)
718 730 TEST_XCHG(xaddl, "", "=m");
719 731 TEST_XCHG(xaddw, "w", "=m");
720 732 TEST_XCHG(xaddb, "b", "=m");
  733 +
  734 + TEST_CMPXCHG(cmpxchgl, "", "=q", 0xfbca7654);
  735 + TEST_CMPXCHG(cmpxchgw, "w", "=q", 0xfbca7654);
  736 + TEST_CMPXCHG(cmpxchgb, "b", "=q", 0xfbca7654);
  737 +
  738 + TEST_CMPXCHG(cmpxchgl, "", "=q", 0xfffefdfc);
  739 + TEST_CMPXCHG(cmpxchgw, "w", "=q", 0xfffefdfc);
  740 + TEST_CMPXCHG(cmpxchgb, "b", "=q", 0xfffefdfc);
  741 +
  742 + TEST_CMPXCHG(cmpxchgl, "", "=m", 0xfbca7654);
  743 + TEST_CMPXCHG(cmpxchgw, "w", "=m", 0xfbca7654);
  744 + TEST_CMPXCHG(cmpxchgb, "b", "=m", 0xfbca7654);
  745 +
  746 + TEST_CMPXCHG(cmpxchgl, "", "=m", 0xfffefdfc);
  747 + TEST_CMPXCHG(cmpxchgw, "w", "=m", 0xfffefdfc);
  748 + TEST_CMPXCHG(cmpxchgb, "b", "=m", 0xfffefdfc);
721 749 }
722 750  
723 751 static void *call_end __init_call = NULL;
... ...