File: ctrl87.c

package info (click to toggle)
bb 1.3rc1-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,424 kB
  • ctags: 1,330
  • sloc: ansic: 32,502; sh: 329; makefile: 54
file content (50 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * ctrl87.c
 * This file is part of msdos driver for XaoS
 */


#define __CONTROL87_C__


#include "ctrl87.h"


/***** _control87 *****/
unsigned short _control87(unsigned short newcw, unsigned short mask)
{
    unsigned short cw;
#ifdef __GNUC__
#ifdef __i386__

    asm volatile ("                                                    \n\
      wait                                                          \n\
      fstcw  %0                                                       "
		  : /* outputs */ "=m" (cw)
		  :		/* inputs */
    );

    if (mask) {			/* mask is not 0 */
	asm volatile ("                                                  \n\
        mov    %2, %%ax                                             \n\
        mov    %3, %%bx                                             \n\
        and    %%bx, %%ax                                           \n\
        not    %%bx                                                 \n\
        nop                                                         \n\
        wait                                                        \n\
        mov    %1, %%dx                                             \n\
        and    %%bx, %%dx                                           \n\
        or     %%ax, %%dx                                           \n\
        mov    %%dx, %0                                             \n\
        wait                                                        \n\
        fldcw  %1                                                     "
		      : /* outputs */ "=g" (cw)
		      : /* inputs */ "g"(cw), "g"(newcw), "g"(mask)
		      : /* registers */ "ax", "bx", "dx"
	);
    }
    return cw;
#endif
#endif

}				/* _control87 */