4 * Copyright (c) 2006 CodeSourcery
5 * Written by Paul Brook
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 void cpu_m68k_flush_flags(CPUM68KState
*env
, int cc_op
)
35 #define HIGHBIT 0x80000000u
37 #define SET_NZ(x) do { \
40 else if ((int32_t)(x) < 0) \
44 #define SET_FLAGS_SUB(type, utype) do { \
47 if ((utype) tmp < (utype) src) \
49 if ((1u << (sizeof(type) * 8 - 1)) & (tmp ^ dest) & (tmp ^ src)) \
68 if (HIGHBIT
& (src
^ dest
) & ~(tmp
^ src
))
72 SET_FLAGS_SUB(int32_t, uint32_t);
75 SET_FLAGS_SUB(int8_t, uint8_t);
78 SET_FLAGS_SUB(int16_t, uint16_t);
85 if (HIGHBIT
& (src
^ dest
) & ~(tmp
^ src
))
93 if (HIGHBIT
& (tmp
^ dest
) & (tmp
^ src
))
103 if (src
&& src
<= 32 && (dest
& (1 << (32 - src
))))
113 if (src
&& src
<= 32 && ((dest
>> (src
- 1)) & 1))
120 tmp
= (int32_t)dest
>> src
;
123 if (src
&& src
<= 32 && (((int32_t)dest
>> (src
- 1)) & 1))
127 cpu_abort(env
, "Bad CC_OP %d", cc_op
);
129 env
->cc_op
= CC_OP_FLAGS
;
130 env
->cc_dest
= flags
;
133 float64
helper_sub_cmpf64(CPUM68KState
*env
, float64 src0
, float64 src1
)
135 /* ??? This may incorrectly raise exceptions. */
136 /* ??? Should flush denormals to zero. */
138 res
= float64_sub(src0
, src1
, &env
->fp_status
);
139 if (float64_is_nan(res
)) {
140 /* +/-inf compares equal against itself, but sub returns nan. */
141 if (!float64_is_nan(src0
)
142 && !float64_is_nan(src1
)) {
144 if (float64_lt_quiet(src0
, res
, &env
->fp_status
))
145 res
= float64_chs(res
);