Commit e1d4294a4534ef0c14fa83e958f352f5f783e931

Authored by bellard
1 parent c3c7c292

more tests


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@51 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 79 additions and 0 deletions
tests/test-i386.c
... ... @@ -714,6 +714,10 @@ void test_segs(void)
714 714 long long ldt_table[3];
715 715 int res, res2;
716 716 char tmp;
  717 + struct {
  718 + uint32_t offset;
  719 + uint16_t seg;
  720 + } __attribute__((packed)) segoff;
717 721  
718 722 ldt.entry_number = 1;
719 723 ldt.base_addr = (unsigned long)&seg_data1;
... ... @@ -772,6 +776,14 @@ void test_segs(void)
772 776 : "r" (MK_SEL(1)), "r" (&tmp));
773 777 printf("DS[1] = %02x\n", res);
774 778 printf("SS[tmp] = %02x\n", res2);
  779 +
  780 + segoff.seg = MK_SEL(2);
  781 + segoff.offset = 0xabcdef12;
  782 + asm volatile("lfs %2, %0\n\t"
  783 + "movl %%fs, %1\n\t"
  784 + : "=r" (res), "=g" (res2)
  785 + : "m" (segoff));
  786 + printf("FS:reg = %04x:%08x\n", res2, res);
775 787 }
776 788  
777 789 /* 16 bit code test */
... ... @@ -812,6 +824,71 @@ void test_code16(void)
812 824 printf("func3() = 0x%08x\n", res);
813 825 }
814 826  
  827 +void test_misc(void)
  828 +{
  829 + char table[256];
  830 + int res, i;
  831 +
  832 + for(i=0;i<256;i++) table[i] = 256 - i;
  833 + res = 0x12345678;
  834 + asm ("xlat" : "=a" (res) : "b" (table), "0" (res));
  835 + printf("xlat: EAX=%08x\n", res);
  836 +}
  837 +
  838 +uint8_t str_buffer[4096];
  839 +
  840 +#define TEST_STRING1(OP, size, DF, REP)\
  841 +{\
  842 + int esi, edi, eax, ecx, eflags;\
  843 +\
  844 + esi = (long)(str_buffer + sizeof(str_buffer) / 2);\
  845 + edi = (long)(str_buffer + sizeof(str_buffer) / 2) + 16;\
  846 + eax = 0x12345678;\
  847 + ecx = 17;\
  848 +\
  849 + asm volatile ("pushl $0\n\t"\
  850 + "popf\n\t"\
  851 + DF "\n\t"\
  852 + REP #OP size "\n\t"\
  853 + "cld\n\t"\
  854 + "pushf\n\t"\
  855 + "popl %4\n\t"\
  856 + : "=S" (esi), "=D" (edi), "=a" (eax), "=c" (ecx), "=g" (eflags)\
  857 + : "0" (esi), "1" (edi), "2" (eax), "3" (ecx));\
  858 + printf("%-10s ESI=%08x EDI=%08x EAX=%08x ECX=%08x EFL=%04x\n",\
  859 + REP #OP size, esi, edi, eax, ecx,\
  860 + eflags & (CC_C | CC_P | CC_Z | CC_S | CC_O | CC_A));\
  861 +}
  862 +
  863 +#define TEST_STRING(OP, REP)\
  864 + TEST_STRING1(OP, "b", "", REP);\
  865 + TEST_STRING1(OP, "w", "", REP);\
  866 + TEST_STRING1(OP, "l", "", REP);\
  867 + TEST_STRING1(OP, "b", "std", REP);\
  868 + TEST_STRING1(OP, "w", "std", REP);\
  869 + TEST_STRING1(OP, "l", "std", REP)
  870 +
  871 +void test_string(void)
  872 +{
  873 + int i;
  874 + for(i = 0;i < sizeof(str_buffer); i++)
  875 + str_buffer[i] = i + 0x56;
  876 + TEST_STRING(stos, "");
  877 + TEST_STRING(stos, "rep ");
  878 + TEST_STRING(lods, ""); /* to verify stos */
  879 + TEST_STRING(lods, "rep ");
  880 + TEST_STRING(movs, "");
  881 + TEST_STRING(movs, "rep ");
  882 + TEST_STRING(lods, ""); /* to verify stos */
  883 +
  884 + /* XXX: better tests */
  885 + TEST_STRING(scas, "");
  886 + TEST_STRING(scas, "repz ");
  887 + TEST_STRING(scas, "repnz ");
  888 + TEST_STRING(cmps, "");
  889 + TEST_STRING(cmps, "repz ");
  890 + TEST_STRING(cmps, "repnz ");
  891 +}
815 892  
816 893 static void *call_end __init_call = NULL;
817 894  
... ... @@ -831,6 +908,8 @@ int main(int argc, char **argv)
831 908 test_floats();
832 909 test_bcd();
833 910 test_xchg();
  911 + test_string();
  912 + test_misc();
834 913 test_lea();
835 914 test_segs();
836 915 test_code16();
... ...