From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9107 invoked by alias); 31 Jul 2006 11:58:46 -0000 Received: (qmail 9098 invoked by uid 22791); 31 Jul 2006 11:58:45 -0000 X-Spam-Check-By: sourceware.org Received: from mailrelay1.uni-rostock.de (HELO antivirus.uni-rostock.de) (139.30.8.201) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 31 Jul 2006 11:58:43 +0000 Received: from antivirus.exch.rz.uni-rostock.de ([127.0.0.1]) by antivirus.uni-rostock.de with Microsoft SMTPSVC(6.0.3790.1830); Mon, 31 Jul 2006 13:58:40 +0200 Received: from antivirus.uni-rostock.de (unverified) by antivirus.exch.rz.uni-rostock.de (Content Technologies SMTPRS 4.3.20) with ESMTP id for ; Mon, 31 Jul 2006 13:58:40 +0200 Received: from mail pickup service by antivirus.uni-rostock.de with Microsoft SMTPSVC; Mon, 31 Jul 2006 13:58:40 +0200 X-SCL: 6 85.69% Received: from mail.uni-rostock.de ([139.30.8.11]) by antivirus.uni-rostock.de with Microsoft SMTPSVC(6.0.3790.1830); Mon, 31 Jul 2006 13:57:29 +0200 Received: from conversion-daemon.mail2.uni-rostock.de by mail2.uni-rostock.de (iPlanet Messaging Server 5.2 HotFix 2.09 (built Nov 18 2005)) id <0J3900A01NO9X2@mail.uni-rostock.de> (original mail from ronald.hecht@uni-rostock.de) for cgen@sourceware.org; Mon, 31 Jul 2006 13:57:28 +0200 (MEST) Received: from [139.30.201.25] (pike.e-technik.uni-rostock.de [139.30.201.25]) by mail2.uni-rostock.de (iPlanet Messaging Server 5.2 HotFix 2.09 (built Nov 18 2005)) with ESMTPS id <0J3900AJINUWFU@mail.uni-rostock.de> for cgen@sourceware.org; Mon, 31 Jul 2006 13:56:56 +0200 (MEST) Date: Mon, 31 Jul 2006 11:58:00 -0000 From: Ronald Hecht Subject: Simulator: base_insn and insn in decode.c To: cgen@sourceware.org Message-id: <44CDF0AC.6070707@uni-rostock.de> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT User-Agent: Mozilla Thunderbird 1.0.8-1.1.fc4 (X11/20060501) X-IsSubscribed: yes Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2006-q3/txt/msg00015.txt.bz2 Hello again, i found another problem in decode. c. As I have variable instruction size, decode.c does not handle base_insn and insn in the right way. The file looks like this: const IDESC * proc8bf_decode (SIM_CPU *current_cpu, IADDR pc, CGEN_INSN_INT base_insn, CGEN_INSN_INT entire_insn, ARGBUF *abuf) { /* Result of decoder. */ PROC8BF_INSN_TYPE itype; { CGEN_INSN_INT insn = base_insn; { unsigned int val = (((insn >> 0) & (63 << 0))); switch (val) { case 0 : if ((entire_insn & 0xff) == 0x0) { itype = PROC8BF_INSN_NOP; goto extract_sfmt_nop; } itype = PROC8BF_INSN_X_INVALID; goto extract_sfmt_empty; case 1 : if ((entire_insn & 0xff) == 0x1) { itype = PROC8BF_INSN_LDA; goto extract_sfmt_lda; } itype = PROC8BF_INSN_X_INVALID; goto extract_sfmt_empty; case 2 : if ((entire_insn & 0xff) == 0x2) { itype = PROC8BF_INSN_LDC; goto extract_sfmt_ldc; } itype = PROC8BF_INSN_X_INVALID; goto extract_sfmt_empty; I have given the first instruction byte as base_insn and entire_insn is the complete instruction. The location of the base instruction depends on the instruction size. So the calculation unsigned int val = (((insn >> 0) & (63 << 0))); is not correct. If I remove the if-statement around the goto extract_sfmt_ everything works correct. The simulatior does the right things. By the way: I found it a bit confusing to write mloop.in. It was difficult to handle different size instructions. I did it this way: xextract-pbb) # Inputs: current_cpu, pc, sc, max_insns, FAST_P # Outputs: sc, pc # sc must be left pointing past the last created entry. # pc must be left pointing past the last created entry. # If the pbb is terminated by a cti insn, SET_CTI_VPC(sc) must be called # to record the vpc of the cti insn. # SET_INSN_COUNT(n) must be called to record number of real insns. cat < 0) { CGEN_INSN_INT insn; CGEN_INSN_INT base_insn = GETIMEMUQI (current_cpu, pc); idesc = @cpu@_decode(current_cpu, pc, base_insn, base_insn, &sc->argbuf); switch (idesc->length) { case 1 : break; case 2 : insn = base_insn * 256 + GETIMEMUQI (current_cpu, pc + 1); break; case 3 : insn = base_insn * 256 * 256 + GETIMEMUQI (current_cpu, pc + 1) * 256 + GETIMEMUQI (current_cpu, pc + 2); break; } idesc = @cpu@_decode(current_cpu, pc, base_insn, insn, &sc->argbuf); @cpu@_fill_argbuf (current_cpu, &sc->argbuf, idesc, pc, FAST_P); if (! FAST_P) { int trace_p = PC_IN_TRACE_RANGE_P (current_cpu, pc); int profile_p = PC_IN_PROFILE_RANGE_P (current_cpu, pc); @cpu@_fill_argbuf_tp (current_cpu, &sc->argbuf, trace_p, profile_p); } ++sc; --max_insns; ++icount; pc += idesc->length; if (IDESC_CTI_P (idesc)) { SET_CTI_VPC (sc - 1); break; } } Finish: SET_INSN_COUNT (icount); } EOF ;; Is there an easier way to write this down? Ronald