1 /* Test segment register getting. */
2 
3 #include <stdio.h>
4 
main(void)5 int main(void)
6 {
7    unsigned short csw = -1;
8    unsigned int csl = -1;
9    unsigned long csq = -1;
10    unsigned short csw_mem = -1;
11 
12    __asm__ __volatile__ (
13        "movw %%cs, %0\n" /* mov segReg, r16 */
14        "movl %%cs, %1\n" /* mov segReg, r32 */
15        "movq %%cs, %2\n" /* mov segReg, r64 */
16        "movw %%cs, %3\n" /* mov segReg, mem16 */
17        : "=r" (csw), "=r" (csl), "=r" (csq), "=m" (csw_mem));
18 
19    printf("cs(w)=%u\n", csw);
20    printf("cs(l)=%u\n", csl);
21    printf("cs(q)=%lu\n", csq);
22    printf("cs(w_mem)=%u\n", csw_mem);
23 
24    return 0;
25 }
26