From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch] (big) real mode emulation - aas Date: Wed, 31 Oct 2007 03:12:49 +0200 Message-ID: <4727D691.5040501@qumranet.com> References: <1193791138.9258.11.camel@lnitindesktop.sc.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: nitin.a.kamble-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org Return-path: In-Reply-To: <1193791138.9258.11.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.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/