From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21947 invoked by alias); 27 Dec 2014 23:20:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21937 invoked by uid 89); 27 Dec 2014 23:20:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-ie0-f173.google.com Received: from mail-ie0-f173.google.com (HELO mail-ie0-f173.google.com) (209.85.223.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 27 Dec 2014 23:20:26 +0000 Received: by mail-ie0-f173.google.com with SMTP id y20so10813803ier.18 for ; Sat, 27 Dec 2014 15:20:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=dKHVYttEwBaCoSio9rjKzgGF+OD6V6nFfcERXfNBBBM=; b=KIkvOaSLd8fcyvKeDL0AD9jW6C1M9CzURIOtUqujyeJyov423GjljAX8zW6ltIju75 W0ezAOklFv3CJfhsNHfGaO24Nan7cDuaEPB68VcDq/pb1HTPzEACzWntriz0gi0zBXrm PMMwQ9c3v20K9ZyCBpGdBgGrAJcLkjcIzmHiHNBBrwVJ7zEcqqooK098OUgL8386klft V92Ngbx/UuPa/E4dPgwQ8wNJt/EBH6hEsn1tRooH8Ao03EzGgKvicJwDcm1uBl1hiXcL +Ih0AvjpZe5JdmKpb7jI/ccJY5Ff0BqlwGQoSV4qk0mcjhOlKfZljFiixMRk5lLink0j 13Zw== X-Gm-Message-State: ALoCoQknEBbmp7frTjERrSOwxEUZZsgdDunmzQtP30oFh0oKbYuoZRYWqoquVROoFqalWU2c1efU X-Received: by 10.42.25.144 with SMTP id a16mr38314463icc.66.1419722423918; Sat, 27 Dec 2014 15:20:23 -0800 (PST) Received: from localhost (CPE687f74122463-CM84948c2e0610.cpe.net.cable.rogers.com. [99.226.94.59]) by mx.google.com with ESMTPSA id g5sm15831589iod.25.2014.12.27.15.20.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Dec 2014 15:20:23 -0800 (PST) From: Anthony Green To: gdb-patches@sourceware.org Subject: [PATCH, moxie, sim] moxie ldo/sto instructions use 16 bit offsets Date: Sat, 27 Dec 2014 23:20:00 -0000 Message-ID: <87lhlsbryi.fsf@moxielogic.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00645.txt.bz2 This patch, which I have committed, introduces support for a recent ISA change in Moxie. The ldo and sto instructions now use a 16 bit offset instead of a 32 bit offset. The binutils and GCC changes have already been checked in. Moxie implementations (cores and other sims) are in the process of being updated. AG 2014-12-27 Anthony Green * interp.c (EXTRACT_OFFSET): Define. (sim_resume): ldo/sto instructions now use 16 bit offset instead of 32. Also swap mul.x/umul.x opcodes (reversed by mistake). diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c index 6a72e41..4dbb1dd 100644 --- a/sim/moxie/interp.c +++ b/sim/moxie/interp.c @@ -50,6 +50,12 @@ FILE *tracefile; + (sim_core_read_aligned_1 (scpu, cia, read_map, addr+2) << 8) \ + (sim_core_read_aligned_1 (scpu, cia, read_map, addr+3))) +#define EXTRACT_OFFSET(addr) \ + (unsigned int) \ + (((signed short) \ + ((sim_core_read_aligned_1 (scpu, cia, read_map, addr) << 8) \ + + (sim_core_read_aligned_1 (scpu, cia, read_map, addr+1))) << 16) >> 16) + unsigned long moxie_extract_unsigned_integer (addr, len) unsigned char * addr; @@ -555,26 +561,26 @@ sim_resume (sd, step, siggnal) break; case 0x0c: /* ldo.l */ { - unsigned int addr = EXTRACT_WORD(pc+2); + unsigned int addr = EXTRACT_OFFSET(pc+2); int a = (inst >> 4) & 0xf; int b = inst & 0xf; TRACE("ldo.l"); addr += cpu.asregs.regs[b]; cpu.asregs.regs[a] = rlat (scpu, opc, addr); - pc += 4; + pc += 2; } break; case 0x0d: /* sto.l */ { - unsigned int addr = EXTRACT_WORD(pc+2); + unsigned int addr = EXTRACT_OFFSET(pc+2); int a = (inst >> 4) & 0xf; int b = inst & 0xf; TRACE("sto.l"); addr += cpu.asregs.regs[a]; wlat (scpu, opc, addr, cpu.asregs.regs[b]); - pc += 4; + pc += 2; } break; case 0x0e: /* cmp */ @@ -641,29 +647,29 @@ sim_resume (sd, step, siggnal) cpu.asregs.regs[a] = (int) bv & 0xffff; } break; - case 0x14: /* mul.x */ + case 0x14: /* umul.x */ { int a = (inst >> 4) & 0xf; int b = inst & 0xf; unsigned av = cpu.asregs.regs[a]; unsigned bv = cpu.asregs.regs[b]; - signed long long r = - (signed long long) av * (signed long long) bv; + unsigned long long r = + (unsigned long long) av * (unsigned long long) bv; - TRACE("mul.x"); + TRACE("umul.x"); cpu.asregs.regs[a] = r >> 32; } break; - case 0x15: /* umul.x */ + case 0x15: /* mul.x */ { int a = (inst >> 4) & 0xf; int b = inst & 0xf; unsigned av = cpu.asregs.regs[a]; unsigned bv = cpu.asregs.regs[b]; - unsigned long long r = - (unsigned long long) av * (unsigned long long) bv; + signed long long r = + (signed long long) av * (signed long long) bv; - TRACE("umul.x"); + TRACE("mul.x"); cpu.asregs.regs[a] = r >> 32; } break; @@ -1057,50 +1063,50 @@ sim_resume (sd, step, siggnal) break; case 0x36: /* ldo.b */ { - unsigned int addr = EXTRACT_WORD(pc+2); + unsigned int addr = EXTRACT_OFFSET(pc+2); int a = (inst >> 4) & 0xf; int b = inst & 0xf; TRACE("ldo.b"); addr += cpu.asregs.regs[b]; cpu.asregs.regs[a] = rbat (scpu, opc, addr); - pc += 4; + pc += 2; } break; case 0x37: /* sto.b */ { - unsigned int addr = EXTRACT_WORD(pc+2); + unsigned int addr = EXTRACT_OFFSET(pc+2); int a = (inst >> 4) & 0xf; int b = inst & 0xf; TRACE("sto.b"); addr += cpu.asregs.regs[a]; wbat (scpu, opc, addr, cpu.asregs.regs[b]); - pc += 4; + pc += 2; } break; case 0x38: /* ldo.s */ { - unsigned int addr = EXTRACT_WORD(pc+2); + unsigned int addr = EXTRACT_OFFSET(pc+2); int a = (inst >> 4) & 0xf; int b = inst & 0xf; TRACE("ldo.s"); addr += cpu.asregs.regs[b]; cpu.asregs.regs[a] = rsat (scpu, opc, addr); - pc += 4; + pc += 2; } break; case 0x39: /* sto.s */ { - unsigned int addr = EXTRACT_WORD(pc+2); + unsigned int addr = EXTRACT_OFFSET(pc+2); int a = (inst >> 4) & 0xf; int b = inst & 0xf; TRACE("sto.s"); addr += cpu.asregs.regs[a]; wsat (scpu, opc, addr, cpu.asregs.regs[b]); - pc += 4; + pc += 2; } break; default: