From 241e9e14df3405cbecb1f499daa6b3ab3be4b095 Mon Sep 17 00:00:00 2001 From: mpohoreski Date: Wed, 15 Dec 2010 16:03:22 +0000 Subject: [PATCH] 2.6.3.0 Fixed: Assembler now accepts lower-case mnemonics --- AppleWin/source/Debugger/Debug.cpp | 4 +- .../source/Debugger/Debugger_Assembler.cpp | 45 ++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/AppleWin/source/Debugger/Debug.cpp b/AppleWin/source/Debugger/Debug.cpp index c863d4eb..21da2795 100644 --- a/AppleWin/source/Debugger/Debug.cpp +++ b/AppleWin/source/Debugger/Debug.cpp @@ -4,7 +4,7 @@ AppleWin : An Apple //e emulator for Windows Copyright (C) 1994-1996, Michael O'Brien Copyright (C) 1999-2001, Oliver Schmidt Copyright (C) 2002-2005, Tom Charlesworth -Copyright (C) 2006-2009, Tom Charlesworth, Michael Pohoreski +Copyright (C) 2006-2010, Tom Charlesworth, Michael Pohoreski AppleWin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define ALLOW_INPUT_LOWERCASE 1 // See Debugger_Changelong.txt for full details - const int DEBUGGER_VERSION = MAKE_VERSION(2,6,2,0); + const int DEBUGGER_VERSION = MAKE_VERSION(2,6,3,0); // Public _________________________________________________________________________________________ diff --git a/AppleWin/source/Debugger/Debugger_Assembler.cpp b/AppleWin/source/Debugger/Debugger_Assembler.cpp index f4e61cf2..96fc69ba 100644 --- a/AppleWin/source/Debugger/Debugger_Assembler.cpp +++ b/AppleWin/source/Debugger/Debugger_Assembler.cpp @@ -4,7 +4,7 @@ AppleWin : An Apple //e emulator for Windows Copyright (C) 1994-1996, Michael O'Brien Copyright (C) 1999-2001, Oliver Schmidt Copyright (C) 2002-2005, Tom Charlesworth -Copyright (C) 2006-2009, Tom Charlesworth, Michael Pohoreski +Copyright (C) 2006-2010, Tom Charlesworth, Michael Pohoreski AppleWin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" +#define DEBUG_ASSEMBLER 0 + // Globals __________________________________________________________________ @@ -718,9 +720,24 @@ int AssemblerHashMnemonic ( const TCHAR * pMnemonic ) const int NUM_MSK_BITS = 5; // 4 -> 5 prime const Hash_t BIT_MSK_HIGH = ((1 << NUM_MSK_BITS) - 1) << NUM_LOW_BITS; - for( int iChar = 0; iChar < 4; iChar++ ) + int nLen = strlen( pMnemonic ); + +#if DEBUG_ASSEMBLER + static char sText[ CONSOLE_WIDTH * 3 ]; + static int nMaxLen = 0; + if (nMaxLen < nLen) { + nMaxLen = nLen; + sprintf( sText, "New Max Len: %d %s", nMaxLen, pMnemonic ); + ConsolePrint( sText ); + } +#endif + + while( *pText ) +// for( int iChar = 0; iChar < 4; iChar++ ) { - nMnemonicHash = (nMnemonicHash << NUM_MSK_BITS) + *pText; + char c = tolower( *pText ); // TODO: based on ALLOW_INPUT_LOWERCASE ?? + + nMnemonicHash = (nMnemonicHash << NUM_MSK_BITS) + c; iHighBits = (nMnemonicHash & BIT_MSK_HIGH); if (iHighBits) { @@ -736,6 +753,8 @@ int AssemblerHashMnemonic ( const TCHAR * pMnemonic ) //=========================================================================== void AssemblerHashOpcodes () { +static char sText[ 128 ]; + Hash_t nMnemonicHash; int iOpcode; @@ -744,8 +763,14 @@ void AssemblerHashOpcodes () const TCHAR *pMnemonic = g_aOpcodes65C02[ iOpcode ].sMnemonic; nMnemonicHash = AssemblerHashMnemonic( pMnemonic ); g_aOpcodesHash[ iOpcode ] = nMnemonicHash; +#if DEBUG_ASSEMBLER + //OutputDebugString( "" ); + sprintf( sText, "%s : %08X ", pMnemonic, nMnemonicHash ); + ConsolePrint( sText ); + // CLC: 002B864 +#endif } - + ConsoleUpdate(); } // TODO: Change .. AssemblerHashDirectives() @@ -1307,6 +1332,17 @@ bool Assemble( int iArg, int nArgs, WORD nAddress ) TCHAR *pMnemonic = g_aArgs[ iArg ].sArg; int nMnemonicHash = AssemblerHashMnemonic( pMnemonic ); +#if DEBUG_ASSEMBLER + static char sText[ CONSOLE_WIDTH * 2 ]; + sprintf( sText, "%s%04X%s: %s%s%s -> %s%08X", + CHC_ADDRESS, nAddress, + CHC_DEFAULT, + CHC_STRING, pMnemonic, + CHC_DEFAULT, + CHC_NUM_HEX, nMnemonicHash ); + ConsolePrint( sText ); +#endif + m_vAsmOpcodes.clear(); // Candiate opcodes int iOpcode; @@ -1324,7 +1360,6 @@ bool Assemble( int iArg, int nArgs, WORD nAddress ) { // Check for assembler directive - ConsoleBufferPush( TEXT(" Syntax Error: Invalid mnemonic") ); return false; }