Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / src / r4300 / macros.h
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  *   Mupen64plus - macros.h                                                *
3  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
4  *   Copyright (C) 2002 Hacktarux                                          *
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
20  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21
22 #ifndef MACROS_H
23 #define MACROS_H
24
25 #define sign_extended(a) a = (long long)((int)a)
26 #define sign_extendedb(a) a = (long long)((signed char)a)
27 #define sign_extendedh(a) a = (long long)((short)a)
28
29 #define rrt *PC->f.r.rt
30 #define rrd *PC->f.r.rd
31 #define rfs PC->f.r.nrd
32 #define rrs *PC->f.r.rs
33 #define rsa PC->f.r.sa
34 #define irt *PC->f.i.rt
35 #define ioffset PC->f.i.immediate
36 #define iimmediate PC->f.i.immediate
37 #define irs *PC->f.i.rs
38 #define ibase *PC->f.i.rs
39 #define jinst_index PC->f.j.inst_index
40 #define lfbase PC->f.lf.base
41 #define lfft PC->f.lf.ft
42 #define lfoffset PC->f.lf.offset
43 #define cfft PC->f.cf.ft
44 #define cffs PC->f.cf.fs
45 #define cffd PC->f.cf.fd
46
47 // 32 bits macros
48 #ifndef M64P_BIG_ENDIAN
49 #define rrt32 *((int*)PC->f.r.rt)
50 #define rrd32 *((int*)PC->f.r.rd)
51 #define rrs32 *((int*)PC->f.r.rs)
52 #define irs32 *((int*)PC->f.i.rs)
53 #define irt32 *((int*)PC->f.i.rt)
54 #else
55 #define rrt32 *((int*)PC->f.r.rt+1)
56 #define rrd32 *((int*)PC->f.r.rd+1)
57 #define rrs32 *((int*)PC->f.r.rs+1)
58 #define irs32 *((int*)PC->f.i.rs+1)
59 #define irt32 *((int*)PC->f.i.rt+1)
60 #endif
61
62 //cop0 macros
63 #define Index reg_cop0[0]
64 #define Random reg_cop0[1]
65 #define EntryLo0 reg_cop0[2]
66 #define EntryLo1 reg_cop0[3]
67 #define Context reg_cop0[4]
68 #define PageMask reg_cop0[5]
69 #define Wired reg_cop0[6]
70 #define BadVAddr reg_cop0[8]
71 #define Count reg_cop0[9]
72 #define EntryHi reg_cop0[10]
73 #define Compare reg_cop0[11]
74 #define Status reg_cop0[12]
75 #define Cause reg_cop0[13]
76 #define EPC reg_cop0[14]
77 #define PRevID reg_cop0[15]
78 #define Config reg_cop0[16]
79 #define LLAddr reg_cop0[17]
80 #define WatchLo reg_cop0[18]
81 #define WatchHi reg_cop0[19]
82 #define XContext reg_cop0[20]
83 #define PErr reg_cop0[26]
84 #define CacheErr reg_cop0[27]
85 #define TagLo reg_cop0[28]
86 #define TagHi reg_cop0[29]
87 #define ErrorEPC reg_cop0[30]
88
89 #endif
90