Thema: [MESSDEV] Extremely subtle bug in cpu/m6809/6809ops.c Datum: 15.06.00 14:29:23 (MEZ) - Mitteleurop. Sommerzeit From: nathan@summsoft.com Sender: owner-messdev@synthcom.com Reply-to: messdev@synthcom.com To: messdev@synthcom.com Datei: patch.zip (7523 Bytes) DL-Zeit (32000 Bit/s): < 1 Minute I found an extremely subtle bug in the CPU core. Essentially, the CLR instruction also performs a read on the target address (in non register mode). Similarly, TST performs a write. This caused a bug in a CoCo 3 program because CLR was being used on memory mapped IO where reading performed an operation. To quote John Kowalski, (a CoCo hardware guru): --- A number of 6809 opcodes don't *strictly* do what they imply that they do. One of them is the CLR opcode. Internally, CLR is lumped together with other 'read, modify, write' opcodes like NEG,COM,LSR,ROR,ASR,ASL,ROL,DEC and INC. So, instead of just writing a $00 like the name implies, CLR *actually* reads the memory location, THEN writes a zero to it. So, in this case, since CLR actually reads the register first, it resets the interrupt. Another 6809 opcode that works like a 'read, modify, write' is TST. Instead of just reading a memory location and testing the value, it also writes it *back* to memory. That's why CLR and TST have higher cycle counts than you'd expect. They perform unncessary operations. There are some other opcodes that do things like that, but mostly they're unnessary reads so they probably aren't an issue. To fix that....well, you'd have to change the 6809 emulator itself to emulate the extra operations. Until then, I think your solution is good. It probably won't break any programs. --- I've taken the liberty of modifying cpu/m6809/6809ops.c. Any chance that this file could be submitted to MAMEdev? (See attached file: patch.zip) ----------------------- Headers -------------------------------- Return-Path: <.owner-messdev@synthcom.com> Received: from rly-za04.mx.aol.com (rly-za04.mail.aol.com [172.31.36.100]) by air-za02.mail.aol.com (v74.17) with ESMTP; Thu, 15 Jun 2000 08:29:23 -0400 Received: from synthcom.com (ip67.usw3.rb1.pdx.nwlink.com [207.202.141.67]) by rly-za04.mx.aol.com (v74.17) with ESMTP; Thu, 15 Jun 2000 08:28:59 -0400 Received: (from majordom@localhost) by synthcom.com (8.9.3/8.9.3) id FAA14334 for messdev-outgoing; Thu, 15 Jun 2000 05:25:54 GMT (envelope-from owner-messdev@synthcom.com) From: nathan@summsoft.com Subject: [MESSDEV] Extremely subtle bug in cpu/m6809/6809ops.c To: messdev@synthcom.com X-Mailer: Lotus Notes Release 5.0.2 November 4, 1999 Message-ID: <.OF6C5D0892.5DFB2A47-ON852568FF.00442AAA@summsoft.com> Date: Thu, 15 Jun 2000 08:25:28 -0400 X-MIMETrack: Serialize by Router on SummitCorp/Summit Software Company(Release 5.0.2c |February 2, 2000) at 06/15/2000 08:25:32 AM MIME-Version: 1.0 Content-type: multipart/mixed; Boundary="0__=tVHWQ5uTjXCkE1Vx5nhCG6QkI4fRUPBSqVxdEaIi3bg6SdlzGhQ5n4z8" Content-Disposition: inline Sender: owner-messdev@synthcom.com Precedence: bulk Reply-To: messdev@synthcom.com