1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney and Red Hat.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
28 #include "sim-basics.h"
29 #include "sim-assert.h"
35 LSMASKED (unsigned_word val
,
39 /* NOTE - start, stop can wrap */
40 val
&= LSMASK (start
, stop
);
47 MSMASKED (unsigned_word val
,
51 /* NOTE - start, stop can wrap */
52 val
&= MSMASK (start
, stop
);
59 LSEXTRACTED (unsigned_word val
,
63 ASSERT (start
>= stop
);
64 #if (WITH_TARGET_WORD_BITSIZE == 64)
65 return LSEXTRACTED64 (val
, start
, stop
);
67 #if (WITH_TARGET_WORD_BITSIZE == 32)
73 val
&= LSMASK (start
, 0);
78 #if (WITH_TARGET_WORD_BITSIZE == 16)
84 val
&= LSMASK (start
, 0);
94 MSEXTRACTED (unsigned_word val
,
98 ASSERT (start
<= stop
);
99 #if (WITH_TARGET_WORD_BITSIZE == 64)
100 return MSEXTRACTED64 (val
, start
, stop
);
102 #if (WITH_TARGET_WORD_BITSIZE == 32)
108 val
&= MSMASK (start
, 64 - 1);
109 val
>>= (64 - stop
- 1);
113 #if (WITH_TARGET_WORD_BITSIZE == 16)
119 val
&= MSMASK (start
, 64 - 1);
120 val
>>= (64 - stop
- 1);
129 LSINSERTED (unsigned_word val
,
133 ASSERT (start
>= stop
);
134 #if (WITH_TARGET_WORD_BITSIZE == 64)
135 return LSINSERTED64 (val
, start
, stop
);
137 #if (WITH_TARGET_WORD_BITSIZE == 32)
138 /* Bit numbers are 63..0, even for 32 bit targets.
139 On 32 bit targets we ignore 63..32 */
145 val
&= LSMASK (start
, stop
);
149 #if (WITH_TARGET_WORD_BITSIZE == 16)
150 /* Bit numbers are 63..0, even for 16 bit targets.
151 On 16 bit targets we ignore 63..16 */
157 val
&= LSMASK (start
, stop
);
165 MSINSERTED (unsigned_word val
,
169 ASSERT (start
<= stop
);
170 #if (WITH_TARGET_WORD_BITSIZE == 64)
171 return MSINSERTED64 (val
, start
, stop
);
173 #if (WITH_TARGET_WORD_BITSIZE == 32)
174 /* Bit numbers are 0..63, even for 32 bit targets.
175 On 32 bit targets we ignore 0..31. */
180 val
<<= ((64 - 1) - stop
);
181 val
&= MSMASK (start
, stop
);
185 #if (WITH_TARGET_WORD_BITSIZE == 16)
186 /* Bit numbers are 0..63, even for 16 bit targets.
187 On 16 bit targets we ignore 0..47. */
192 val
<<= ((64 - 1) - stop
);
193 val
&= MSMASK (start
, stop
);
203 LSSEXT (signed_word val
,
206 ASSERT (sign_bit
< 64);
207 #if (WITH_TARGET_WORD_BITSIZE == 64)
208 return LSSEXT64 (val
, sign_bit
);
210 #if (WITH_TARGET_WORD_BITSIZE == 32)
214 val
= LSSEXT32 (val
, sign_bit
);
218 #if (WITH_TARGET_WORD_BITSIZE == 16)
222 val
= LSSEXT16 (val
, sign_bit
);
230 MSSEXT (signed_word val
,
233 ASSERT (sign_bit
< 64);
234 #if (WITH_TARGET_WORD_BITSIZE == 64)
235 return MSSEXT64 (val
, sign_bit
);
237 #if (WITH_TARGET_WORD_BITSIZE == 32)
241 val
= MSSEXT32 (val
, sign_bit
- 32);
245 #if (WITH_TARGET_WORD_BITSIZE == 16)
246 if (sign_bit
< 32 + 16)
249 val
= MSSEXT16 (val
, sign_bit
- 32 - 16);
258 #include "sim-n-bits.h"
262 #include "sim-n-bits.h"
266 #include "sim-n-bits.h"
270 #include "sim-n-bits.h"
273 #endif /* _SIM_BITS_C_ */