[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 07/17] target/m68k: add chk and chk2
From: |
Laurent Vivier |
Subject: |
Re: [Qemu-devel] [PATCH v6 07/17] target/m68k: add chk and chk2 |
Date: |
Thu, 4 Jan 2018 00:40:34 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
Le 03/01/2018 à 22:52, Richard Henderson a écrit :
> On 01/02/2018 03:40 PM, Laurent Vivier wrote:
>> +void HELPER(chk)(CPUM68KState *env, int32_t val, int32_t ub)
>> +{
>> + if (val < 0 || val > ub) {
>> + CPUState *cs = CPU(m68k_env_get_cpu(env));
>> +
>> + /* Recover PC and CC_OP for the beginning of the insn. */
>> + cpu_restore_state(cs, GETPC());
>> +
>> + /* Adjust PC and FLAGS to end of the insn. */
>> + env->pc += 2;
>> + helper_flush_flags(env, env->cc_op);
>> + env->cc_n = val;
>> +
>> + cs->exception_index = EXCP_CHK;
>> + cpu_loop_exit(cs);
>> + }
>> +}
>> +
>
> I thought you said for 68040, N is always unset for val >= 0.
> That would suggest
>
> helper_flush_flags(env, env->cc_op);
> env->cc_n = val;
> if (val < 0 || val > ub) {
> ...
> }
ok, my though was it is better to not update the flag if it is not
needed (it should be undefined), but what you suggest is closer to the
real hardware so I will update it.
> Did you examine the real hw change to the other flags?
yes, C is modified, and the logic is:
C = 0 <= ub ? val < 0 || ub < val : val < 0 && ub < val;
All other flags are not modified.
I'm going to update the patch to reflect the change of N and C by the
real hardware.
> Because they're officially undefined, which suggests
>
> env->cc_n = val;
> env->cc_op = CC_OP_LOGIC;
>
>> +void HELPER(chk2)(CPUM68KState *env, int32_t val, int32_t lb, int32_t ub)
>> +{
>> + helper_flush_flags(env, env->cc_op);
>> +
>> + env->cc_z = val != lb && val != ub;
>> + env->cc_c = lb <= ub ? val < lb || val > ub : val > ub && val < lb;
>> +
>> + if (env->cc_c) {
>> + CPUState *cs = CPU(m68k_env_get_cpu(env));
>> +
>> + cpu_restore_state(cs, GETPC());
>> + env->cc_op = CC_OP_FLAGS;
>
> A comment that we're reverting a change made during unwind would be helpful
> here.
Ok
Thanks,
Laurent
- [Qemu-devel] [PATCH v6 03/17] linux-user, m68k: correctly manage SR in context, (continued)
- [Qemu-devel] [PATCH v6 03/17] linux-user, m68k: correctly manage SR in context, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 04/17] target/m68k: use insn_pc to generate instruction fault address, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 05/17] target/m68k: add CPU_LOG_INT trace, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 06/17] target/m68k: manage 680x0 stack frames, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 08/17] target/m68k: add move16, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 07/17] target/m68k: add chk and chk2, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 12/17] target/m68k: implement fsave/frestore, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 10/17] target/m68k: add cpush/cinv, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 11/17] target/m68k: add reset, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 09/17] target/m68k: softmmu cleanup, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 13/17] target/m68k: move CCR/SR functions, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 14/17] target/m68k: add 680x0 "move to SR" instruction, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 15/17] target/m68k: add andi/ori/eori to SR/CCR, Laurent Vivier, 2018/01/02
- [Qemu-devel] [PATCH v6 16/17] target/m68k: add the Interrupt Stack Pointer, Laurent Vivier, 2018/01/02