-
Notifications
You must be signed in to change notification settings - Fork 1
/
cpu_mvi.h
173 lines (158 loc) · 6.08 KB
/
cpu_mvi.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* ES40 emulator.
* Copyright (C) 2007 by Camiel Vanderhoeven
*
* Website: www.camicom.com
* E-mail : [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Although this is not required, the author would appreciate being notified of,
* and receiving any modifications you may make to the source code that might serve
* the general public.
*/
/**
* \file
* Contains code macros for the processor MVI (multimedia) instructions.
*
* X-1.3 Camiel Vanderhoeven 11-APR-2007
* Moved all data that should be saved to a state file to a structure
* "state".
*
* X-1.2 Camiel Vanderhoeven 30-MAR-2007
* Added old changelog comments.
*
* X-1.1 Camiel Vanderhoeven 18-FEB-2007
* File created. Contains code previously found in AlphaCPU.h
*
* \author Camiel Vanderhoeven ([email protected] / http://www.camicom.com)
**/
#define DO_MINUB8 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 8) { \
if ((u8)((temp_64_1>>i)&X64_BYTE) > (u8)((temp_64_2>>i)&X64_BYTE)) \
temp_64 |= (((temp_64_2>>i)&X64_BYTE)<<i); \
else \
temp_64 |= (((temp_64_1>>i)&X64_BYTE)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MINSB8 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 8) { \
if ((s8)((temp_64_1>>i)&X64_BYTE) > (s8)((temp_64_2>>i)&X64_BYTE)) \
temp_64 |= (((temp_64_2>>i)&X64_BYTE)<<i); \
else \
temp_64 |= (((temp_64_1>>i)&X64_BYTE)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MINUW4 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 16) { \
if ((u16)((temp_64_1>>i)&X64_WORD) > (u16)((temp_64_2>>i)&X64_WORD)) \
temp_64 |= (((temp_64_2>>i)&X64_WORD)<<i); \
else \
temp_64 |= (((temp_64_1>>i)&X64_WORD)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MINSW4 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 16) { \
if ((s16)((temp_64_1>>i)&X64_WORD) > (s16)((temp_64_2>>i)&X64_WORD)) \
temp_64 |= (((temp_64_2>>i)&X64_WORD)<<i); \
else \
temp_64 |= (((temp_64_1>>i)&X64_WORD)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MAXUB8 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 8) { \
if ((u8)((temp_64_1>>i)&X64_BYTE) > (u8)((temp_64_2>>i)&X64_BYTE)) \
temp_64 |= (((temp_64_1>>i)&X64_BYTE)<<i); \
else \
temp_64 |= (((temp_64_2>>i)&X64_BYTE)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MAXSB8 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 8) { \
if ((s8)((temp_64_1>>i)&X64_BYTE) > (s8)((temp_64_2>>i)&X64_BYTE)) \
temp_64 |= (((temp_64_1>>i)&X64_BYTE)<<i); \
else \
temp_64 |= (((temp_64_2>>i)&X64_BYTE)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MAXUW4 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 16) { \
if ((u16)((temp_64_1>>i)&X64_WORD) > (u16)((temp_64_2>>i)&X64_WORD)) \
temp_64 |= (((temp_64_1>>i)&X64_WORD)<<i); \
else \
temp_64 |= (((temp_64_2>>i)&X64_WORD)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_MAXSW4 \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+= 16) { \
if ((s16)((temp_64_1>>i)&X64_WORD) > (s16)((temp_64_2>>i)&X64_WORD)) \
temp_64 |= (((temp_64_1>>i)&X64_WORD)<<i); \
else \
temp_64 |= (((temp_64_2>>i)&X64_WORD)<<i); \
} \
state.r[REG_3] = temp_64;
#define DO_PERR \
temp_64 = 0; \
temp_64_1 = state.r[REG_1]; \
temp_64_2 = V_2; \
for(i=0;i<64;i+=8) \
if ((s8)((temp_64_1>>i)&X64_BYTE) > (s8)((temp_64_2>>i)&X64_BYTE)) \
temp_64 |= ((u64)((s8)((temp_64_1>>i)&X64_BYTE) - (s8)((temp_64_2>>i)&X64_BYTE))<<i); \
else \
temp_64 |= ((u64)((s8)((temp_64_2>>i)&X64_BYTE) - (s8)((temp_64_1>>i)&X64_BYTE))<<i); \
state.r[REG_3] = temp_64;
#define DO_PKLB \
temp_64_2 = V_2; \
state.r[REG_3] = (temp_64_2 & X64(00000000000000ff)) \
| ((temp_64_2 & X64(000000ff00000000)) >> 24);
#define DO_PKWB \
temp_64_2 = V_2; \
state.r[REG_3] = (temp_64_2 & X64(00000000000000ff)) \
| ((temp_64_2 & X64(0000000000ff0000)) >> 8) \
| ((temp_64_2 & X64(000000ff00000000)) >> 16) \
| ((temp_64_2 & X64(00ff000000000000)) >> 24);
#define DO_UNPKBL \
temp_64_2 = V_2; \
state.r[REG_3] = (temp_64_2 & X64(000000ff)) \
| ((temp_64_2 & X64(0000ff00)) << 24);
#define DO_UNPKBW \
temp_64_2 = V_2; \
state.r[REG_3] = (temp_64_2 & X64(000000ff)) \
| ((temp_64_2 & X64(0000ff00)) << 8) \
| ((temp_64_2 & X64(00ff0000)) << 16) \
| ((temp_64_2 & X64(ff000000)) << 24);