From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: nitin.a.kamble-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [patch] (big) real mode emulation - aas
Date: Wed, 31 Oct 2007 03:12:49 +0200 [thread overview]
Message-ID: <4727D691.5040501@qumranet.com> (raw)
In-Reply-To: <1193791138.9258.11.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org>
Nitin A Kamble wrote:
> Hi Avi,
> Attached is the patch to implement emulation of instruction aas
>
> + case 0x3f: /* aas */ {
> + u8 al, ah, af, cf;
> + al = c->regs[VCPU_REGS_RAX] & 0xff;
> + ah = (c->regs[VCPU_REGS_RAX] >> 8) & 0xff;
> + af = (ctxt->eflags & EFLG_AF);
> + cf = (ctxt->eflags & EFLG_CF);
> + if (((al & 0x0f) > 9) || af) {
> + al = al - 6;
> + ah = ah - 1;
> + af = cf = 1;
> + } else {
> + cf = af = 0;
> + }
> + al = al & 0x0f;
> + if (af)
> + ctxt->eflags |= EFLG_AF;
> + else
> + ctxt->eflags &= ~EFLG_AF;
> + if (cf)
> + ctxt->eflags |= EFLG_CF;
> + else
> + ctxt->eflags &= ~EFLG_CF;
> + *(u16 *) &c->regs[VCPU_REGS_RAX] = (ah << 8) & al;
> + }
> + break;
Please move the whole thing to a static function in order to reduce clutter.
Also, a helper
static void set_flag_value(struct emulate_context *ctxt, u32 mask,
int value) {... }
can simplify some of the code.
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
prev parent reply other threads:[~2007-10-31 1:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-31 0:38 [patch] (big) real mode emulation - aas Nitin A Kamble
[not found] ` <1193791138.9258.11.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org>
2007-10-31 1:12 ` Avi Kivity [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=4727D691.5040501@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=nitin.a.kamble-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/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.