On 08/06/2010 11:11 AM, Wei Yongjun wrote:
> Signed-off-by: Wei Yongjun<[email protected]>
> 
> diff --git a/x86/emulator.c b/x86/emulator.c
> index e278812..5c8093e 100644
> --- a/x86/emulator.c
> +++ b/x86/emulator.c
> @@ -375,6 +375,44 @@ void test_btc(void *mem)
>       report("btcl reg, r/m", a[0] == 1&&  a[1] == 2&&  a[2] == 0x80000004);
>   }
> 
> +void test_setcc(void *mem)
> +{
> +     unsigned char *memb = mem;
> +
> +     asm ("seto %0":"=m"(*memb));
> +     report("seto r/m8", *memb == 0);
> +     asm ("setno %0":"=m"(*memb));
> +     report("setno r/m8", *memb == 1);
> +     asm ("setc %0":"=m"(*memb));
> +     report("setc r/m8", *memb == 0);
> +     asm ("setnc %0":"=m"(*memb));
> +     report("setnc r/m8", *memb == 1);
> +     asm ("sete %0":"=m"(*memb));
> +     report("setz r/m8", *memb == 0);
> +     asm ("setne %0":"=m"(*memb));
> +     report("setnz r/m8", *memb == 1);
> +     asm ("seta %0":"=m"(*memb));
> +     report("seta r/m8", *memb == 1);
> +     asm ("setna %0":"=m"(*memb));
> +     report("setna r/m8", *memb == 0);
> +     asm ("sets %0":"=m"(*memb));
> +     report("sets r/m8", *memb == 0);
> +     asm ("setns %0":"=m"(*memb));
> +     report("setns r/m8", *memb == 1);
> +     asm ("setp %0":"=m"(*memb));
> +     report("setp r/m8", *memb == 0);
> +     asm ("setnp %0":"=m"(*memb));
> +     report("setnp r/m8", *memb == 1);
> +     asm ("setl %0":"=m"(*memb));
> +     report("setl r/m8", *memb == 0);
> +     asm ("setnl %0":"=m"(*memb));
> +     report("setnl r/m8", *memb == 1);
> +     asm ("setle %0":"=m"(*memb));
> +     report("setle r/m8", *memb == 0);
> +     asm ("setnle %0":"=m"(*memb));
> +     report("setnle r/m8", *memb == 1);
> +}

These results depend on the environment, since you do not know which
instruction last set the flags.  You can add a mov+cmp pair before the
setcc instruction to guarantee that the flags are set correctly.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to