power6_mf_gpr.c revision e739ac0589b4fb43561f801c4faba8c1b89f8680
1/*  Copyright (C) 2007 IBM
2
3    Author: Pete Eberlein  eberlein@us.ibm.com
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307, USA.
19
20    The GNU General Public License is contained in the file COPYING.
21*/
22
23#include <stdio.h>
24#include <string.h>
25
26
27
28int main(int argc, char *argv[])
29{
30
31   long i;
32   double f;
33
34   i = 0;
35   f = 100.0;
36
37   printf("%lx %f\n", i, f);
38
39 asm("mftgpr %0, %1\n": "=r"(i):"f"(f));
40
41   f = 0.0;
42   printf("%lx %f\n", i, f);
43
44 asm("mffgpr %0, %1\n": "=f"(f):"r"(i));
45
46   printf("%lx %f\n", i, f);
47
48   return 0;
49}
50