All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Wei Yongjun <yjwei@cn.fujitsu.com>
Cc: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH] test: Add test for setcc instruction
Date: Fri, 06 Aug 2010 13:04:29 +0200	[thread overview]
Message-ID: <4C5BEC3D.8060405@redhat.com> (raw)
In-Reply-To: <4C5BD1AD.10207@cn.fujitsu.com>

On 08/06/2010 11:11 AM, Wei Yongjun wrote:
> Signed-off-by: Wei Yongjun<yjwei@cn.fujitsu.com>
> 
> 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

      reply	other threads:[~2010-08-06 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06  9:11 [PATCH] test: Add test for setcc instruction Wei Yongjun
2010-08-06 11:04 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5BEC3D.8060405@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=yjwei@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.