From patchwork Fri Jan 4 14:17:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 1933051 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 788973FDDA for ; Fri, 4 Jan 2013 14:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754765Ab3ADORL (ORCPT ); Fri, 4 Jan 2013 09:17:11 -0500 Received: from mail-wg0-f48.google.com ([74.125.82.48]:33342 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754741Ab3ADORK (ORCPT ); Fri, 4 Jan 2013 09:17:10 -0500 Received: by mail-wg0-f48.google.com with SMTP id dt10so7433052wgb.15 for ; Fri, 04 Jan 2013 06:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=LfAQFvbhrIY6DA0eaM8VBUOmdZ1Uv5fBce+8uAPsFgg=; b=eyO7CkmfKpuPtDbtcdN2SB/3A4x9w544unFPS+GxFGv7Ox9XzWeVol7d/MIc0Ehv8U WZSZFHxijkdhZOBhAd6m3GwJoPu4tWCxelbND8MWq8yfj2dKossSN69L5Sm8ycZBvgKB k1CUcPRQk/pDfA2WnBUZMhFD5Oh8Tq7RFZYqPqS/wUkiJkpis20ILftQUZ5HR+HePY5F ROCzR3+wQ8ypMN69DZlL7AJ+YVxn2pbFvIJNaUkqQTfvYCHT6bnmYe88ihpz0RuhjAjX lJylhi0yt9PpZBRICyGUQFxeTnj9WV2Amjzt/MW6d2KA7FC0BaVlPMUpoqerZj+2g7kw lR6g== X-Received: by 10.194.238.5 with SMTP id vg5mr83824837wjc.40.1357309028629; Fri, 04 Jan 2013 06:17:08 -0800 (PST) Received: from localhost.localdomain (93-172-35-137.bb.netvision.net.il. [93.172.35.137]) by mx.google.com with ESMTPS id bd7sm90536728wib.8.2013.01.04.06.17.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Jan 2013 06:17:07 -0800 (PST) From: Avi Kivity To: Marcelo Tosatti , Gleb Natapov Cc: kvm@vger.kernel.org Subject: [PATCH] emulator: simple ALU tests Date: Fri, 4 Jan 2013 16:17:04 +0200 Message-Id: <1357309024-11736-1-git-send-email-avi.kivity@gmail.com> X-Mailer: git-send-email 1.8.0.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Avi Kivity --- x86/emulator.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c index c39027a..a128e13 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -863,6 +863,31 @@ static void test_ltr(volatile uint16_t *mem) report("ltr", str() == tr && (*trp & busy_mask)); } +static void test_simplealu(u32 *mem) +{ + *mem = 0x1234; + asm("or %1, %0" : "+m"(*mem) : "r"(0x8001)); + report("or", *mem == 0x9235); + asm("add %1, %0" : "+m"(*mem) : "r"(2)); + report("add", *mem == 0x9237); + asm("xor %1, %0" : "+m"(*mem) : "r"(0x1111)); + report("xor", *mem == 0x8326); + asm("sub %1, %0" : "+m"(*mem) : "r"(0x26)); + report("sub", *mem == 0x8300); + asm("clc; adc %1, %0" : "+m"(*mem) : "r"(0x100)); + report("adc(0)", *mem == 0x8400); + asm("stc; adc %1, %0" : "+m"(*mem) : "r"(0x100)); + report("adc(0)", *mem == 0x8501); + asm("clc; sbb %1, %0" : "+m"(*mem) : "r"(0)); + report("sbb(0)", *mem == 0x8501); + asm("stc; sbb %1, %0" : "+m"(*mem) : "r"(0)); + report("sbb(1)", *mem == 0x8500); + asm("and %1, %0" : "+m"(*mem) : "r"(0xfe77)); + report("and", *mem == 0x8400); + asm("test %1, %0" : "+m"(*mem) : "r"(0xf000)); + report("test", *mem == 0x8400); +} + int main() { void *mem; @@ -889,6 +914,7 @@ int main() : "memory"); report("mov reg, r/m (1)", t2 == 0x123456789abcdef); + test_simplealu(mem); test_cmps(mem); test_scas(mem);