File: ctrl87.c

package info (click to toggle)
gnuplot 3.5beta6.340-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,792 kB
  • ctags: 4,205
  • sloc: ansic: 41,878; asm: 539; makefile: 498; objc: 379; csh: 297; sh: 277; pascal: 194; perl: 138; lisp: 88
file content (46 lines) | stat: -rw-r--r-- 1,619 bytes parent folder | download
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
/*
 * ctrl87.c
 *
 */


#define __CONTROL87_C__


#include "ctrl87.h"


/***** _control87 *****/
unsigned short _control87(unsigned short newcw, unsigned short mask)
{
  unsigned short cw;

  asm volatile("                                                    \n\
      wait                                                          \n\
      fstcw  %0                                                       "
      : /* outputs */   "=g" (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;
} /* _control87 */