/[qemu]/qemu/tests/test-i386.c
ViewVC logotype

Diff of /qemu/tests/test-i386.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.48 by bellard, Sun Mar 20 10:40:15 2005 UTC revision 1.49 by bellard, Sat Apr 23 17:54:59 2005 UTC
# Line 1321  void test_code16(void) Line 1321  void test_code16(void)
1321  }  }
1322  #endif  #endif
1323    
1324  extern char func_lret32;  #if defined(__x86_64__)
1325  extern char func_iret32;  asm(".globl func_lret\n"
1326        "func_lret:\n"
1327        "movl $0x87654641, %eax\n"
1328        "lretq\n");
1329    #else
1330    asm(".globl func_lret\n"
1331        "func_lret:\n"
1332        "movl $0x87654321, %eax\n"
1333        "lret\n"
1334    
1335        ".globl func_iret\n"
1336        "func_iret:\n"
1337        "movl $0xabcd4321, %eax\n"
1338        "iret\n");
1339    #endif
1340    
1341    extern char func_lret;
1342    extern char func_iret;
1343    
1344  void test_misc(void)  void test_misc(void)
1345  {  {
# Line 1334  void test_misc(void) Line 1351  void test_misc(void)
1351      asm ("xlat" : "=a" (res) : "b" (table), "0" (res));      asm ("xlat" : "=a" (res) : "b" (table), "0" (res));
1352      printf("xlat: EAX=" FMTLX "\n", res);      printf("xlat: EAX=" FMTLX "\n", res);
1353    
1354  #if !defined(__x86_64__)  #if defined(__x86_64__)
1355        {
1356            static struct __attribute__((packed)) {
1357                uint32_t offset;
1358                uint16_t seg;
1359            } desc;
1360            long cs_sel;
1361    
1362            asm volatile ("mov %%cs, %0" : "=r" (cs_sel));
1363    
1364            asm volatile ("push %1\n"
1365                          "call func_lret\n"
1366                          : "=a" (res)
1367                          : "r" (cs_sel) : "memory", "cc");
1368            printf("func_lret=" FMTLX "\n", res);
1369    
1370            /* NOTE: we assume that &func_lret < 4GB */
1371            desc.offset = (long)&func_lret;
1372            desc.seg = cs_sel;
1373            
1374            asm volatile ("xor %%rax, %%rax\n"
1375                          "rex64 lcall %1\n"
1376                          : "=a" (res)
1377                          : "m" (desc)
1378                          : "memory", "cc");
1379            printf("func_lret2=" FMTLX "\n", res);
1380    
1381            asm volatile ("push %2\n"
1382                          "mov $ 1f, %%rax\n"
1383                          "push %%rax\n"
1384                          "ljmp %1\n"
1385                          "1:\n"
1386                          : "=a" (res)
1387                          : "m" (desc), "b" (cs_sel)
1388                          : "memory", "cc");
1389            printf("func_lret3=" FMTLX "\n", res);
1390        }
1391    #else
1392      asm volatile ("push %%cs ; call %1"      asm volatile ("push %%cs ; call %1"
1393                    : "=a" (res)                    : "=a" (res)
1394                    : "m" (func_lret32): "memory", "cc");                    : "m" (func_lret): "memory", "cc");
1395      printf("func_lret32=" FMTLX "\n", res);      printf("func_lret=" FMTLX "\n", res);
1396    
1397      asm volatile ("pushf ; push %%cs ; call %1"      asm volatile ("pushf ; push %%cs ; call %1"
1398                    : "=a" (res)                    : "=a" (res)
1399                    : "m" (func_iret32): "memory", "cc");                    : "m" (func_iret): "memory", "cc");
1400      printf("func_iret32=" FMTLX "\n", res);      printf("func_iret=" FMTLX "\n", res);
1401  #endif  #endif
1402    
1403  #if defined(__x86_64__)  #if defined(__x86_64__)

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26