2.6.2.2 cleaned up assembler pseudo opcodes

This commit is contained in:
mpohoreski 2009-10-26 01:22:51 +00:00
parent f83d1fcabb
commit b05db20ba8
2 changed files with 170 additions and 29 deletions

View File

@ -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-2007, Tom Charlesworth, Michael Pohoreski
Copyright (C) 2006-2009, 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
@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/* Description: Debugger
*
* Author: Copyright (C) 2006, Michael Pohoreski
* Author: Copyright (C) 2006-2009, Michael Pohoreski
*/
#include "StdAfx.h"
@ -48,11 +48,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{TEXT("%02X,X") , 2 , "Zero Page,X" }, // AM_ZX // %s,X
{TEXT("%02X,Y") , 2 , "Zero Page,Y" }, // AM_ZY // %s,Y
{TEXT("%s") , 2 , "Relative" }, // AM_R
{TEXT("(%02X,X)"), 2 , "(Zero Page),X" }, // AM_IZX ADDR_INDX // ($%02X,X) -> %s,X
{TEXT("(%04X,X)"), 3 , "(Absolute),X" }, // AM_IAX ADDR_ABSIINDX // ($%04X,X) -> %s,X
{TEXT("(%02X),Y"), 2 , "(Zero Page),Y" }, // AM_NZY ADDR_INDY // ($%02X),Y
{TEXT("(%02X)") , 2 , "(Zero Page)" }, // AM_NZ ADDR_IZPG // ($%02X) -> $%02X
{TEXT("(%04X)") , 3 , "(Absolute)" } // AM_NA ADDR_IABS // (%04X) -> %s
{TEXT("(%02X,X)"), 2 , "(Zero Page),X" }, // AM_IZX // ($%02X,X) -> %s,X
{TEXT("(%04X,X)"), 3 , "(Absolute),X" }, // AM_IAX // ($%04X,X) -> %s,X
{TEXT("(%02X),Y"), 2 , "(Zero Page),Y" }, // AM_NZY // ($%02X),Y
{TEXT("(%02X)") , 2 , "(Zero Page)" }, // AM_NZ // ($%02X) -> $%02X
{TEXT("(%04X)") , 3 , "(Absolute)" } // AM_NA // (%04X) -> %s
};
@ -66,6 +66,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
const Opcodes_t *g_aOpcodes = NULL; // & g_aOpcodes65C02[ 0 ];
// Disassembler Data _____________________________________________________________________________
vector<DisasmData_t> g_aDisassemblerData;
// Instructions / Opcodes _________________________________________________________________________
@ -287,32 +292,50 @@ Fx BEQ r SBC (d),Y sbc (d) --- --- SBC d,X INC d,X --- SED SBC a,Y
// Private __________________________________________________________________
enum MerlinDirective_e
{
MERLIN_ASCII
, MERLIN_DEFINE_WORD
, MERLIN_DEFINE_BYTE
, MERLIN_DEFINE_STORAGE
, MERLIN_HEX
, MERLIN_ORIGIN
, NUM_MERLIN_DIRECTIVES
};
// enum Nopcode_t
// {
// NOPCODE_NONE, // line.iOpcode is valid: [0,0xFF]
AssemblerDirective_t g_aAssemblerDirectivesMerlin[ NUM_MERLIN_DIRECTIVES ] =
// Acme
AssemblerDirective_t g_aAssemblerDirectives[ NUM_ASM_DIRECTIVES ] =
{
// NULL n/a
{""},
// Acme
{"???"},
// Big Mac
{"???"},
// DOS Tool Kit
{"???"},
// Lisa
{"???"},
// Merlin
{"ASC"}, // ASC "postive" 'negative'
{"DDB"}, // Define Double Byte (Define WORD)
{"DFB"}, // DeFine Byte
{"DS" }, // Defin Storage
{"HEX"}, // HEX ###### or HEX ##,##,...
{"ORG"} // Origin
{"ORG"}, // Origin
// MicroSparc
{"???"},
// ORCA/M
{"???"},
// SC ...
{".OR"}, // ORigin
{".TA"}, // Target Address
{".EN"}, // ENd of program
{".EQ"}, // EQuate
{".DA"}, // DAta
{".AS"}, // Ascii String
{".HS"}, // Hex String
// Ted II
{"???"},
// Weller
{"???"},
};
const AssemblerDirective_t g_aAssemblerDirectivesAcme[] =
{
{"DFB"}
};
// Assemblers
enum AssemblerFlags_e
{
@ -411,6 +434,10 @@ int _6502_GetOpmodeOpbyte ( const int iAddress, int & iOpmode_, int & nOpbyte_
}
#endif
// Data Disassembler
// Smart Disassembly - Data Section
// Assemblyer Directives - Psuedo Mnemonics
int iOpcode_ = *(mem + iAddress);
iOpmode_ = g_aOpcodes[ iOpcode_ ].nAddressMode;
nOpbyte_ = g_aOpmodes[ iOpmode_ ].m_nBytes;
@ -722,19 +749,20 @@ void AssemblerHashOpcodes ()
}
// TODO: Change .. AssemblerHashDirectives()
//===========================================================================
void AssemblerHashMerlinDirectives ()
{
Hash_t nMnemonicHash;
int iOpcode;
// int nMerlinDirectives = sizeof( g_aAssemblerDirectivesMerlin ) / sizeof( AssemblerDirective_t );
for( iOpcode = 0; iOpcode < NUM_MERLIN_DIRECTIVES; iOpcode++ )
for( iOpcode = 0; iOpcode < NUM_ASM_M_DIRECTIVES; iOpcode++ )
{
const TCHAR *pMnemonic = g_aAssemblerDirectivesMerlin[ iOpcode ].m_sMnemonic;
int iNopcode = FIRST_M_DIRECTIVE + iOpcode;
//. const TCHAR *pMnemonic = g_aAssemblerDirectivesMerlin[ iOpcode ].m_pMnemonic;
const TCHAR *pMnemonic = g_aAssemblerDirectives[ iNopcode ].m_pMnemonic;
nMnemonicHash = AssemblerHashMnemonic( pMnemonic );
g_aAssemblerDirectivesMerlin[ iOpcode ].m_nHash = nMnemonicHash;
g_aAssemblerDirectives[ iNopcode ].m_nHash = nMnemonicHash;
}
}

View File

@ -1,6 +1,117 @@
#ifndef DEBUGGER_ASSEMBLER_H
#define DEBUGGER_ASSEMBLER_H
// Directives
// Assemblers
// A = Acme
// B = Big Mac S= S-C Macro Assembler
// K = DOS Tool Kit T = TED II
// L = Lisa W = Weller's Assembler
// M = Merlin
// u = MicroSparc
// O = ORCA/M
enum AsmAcmeDirective_e
{
ASM_A_DEFINE_BYTE
,NUM_ASM_A_DIRECTIVES
};
enum AsmBigMacDirective_e
{
ASM_B_DEFINE_BYTE
,NUM_ASM_B_DIRECTIVES
};
enum AsmDosToolKitDirective_e
{
ASM_K_DEFINE_BYTE
,NUM_ASM_K_DIRECTIVES
};
enum AsmLisaDirective_e
{
ASM_L_DEFINE_BYTE
,NUM_ASM_L_DIRECTIVES
};
enum AsmMerlinDirective_e
{
ASM_M_ASCII
, ASM_M_DEFINE_WORD
, ASM_M_DEFINE_BYTE
, ASM_M_DEFINE_STORAGE
, ASM_M_HEX
, ASM_M_ORIGIN
, NUM_ASM_M_DIRECTIVES
, ASM_M_DEFINE_BYTE_ALIAS
, ASM_M_DEFINE_WORD_ALIAS
};
enum AsmMicroSparcDirective_e
{
ASM_u_DEFINE_BYTE
,NUM_ASM_u_DIRECTIVES
};
enum AsmOrcamDirective_e
{
ASM_O_DEFINE_BYTE
,NUM_ASM_O_DIRECTIVES
};
enum AsmSCMacroDirective_e
{
ASM_S_ORIGIN
,ASM_S_TARGET_ADDRESS
,ASM_S_END_PROGRAM
,ASM_S_EQUATE
,ASM_S_DATA
,ASM_S_ASCII_STRING
,ASM_S_HEX_STRING
,NUM_ASM_S_DIRECTIVES
};
enum AsmTedDirective_e
{
ASM_T_DEFINE_BYTE
,NUM_ASM_T_DIRECTIVES
};
enum AsmWellersDirective_e
{
ASM_W_DEFINE_BYTE
,NUM_ASM_W_DIRECTIVES
};
// NOTE: Must keep in sync: AsmDirectives_e g_aAssemblerDirectives
enum AsmDirectives_e
{
FIRST_A_DIRECTIVE = 1,
FIRST_B_DIRECTIVE = FIRST_A_DIRECTIVE + NUM_ASM_A_DIRECTIVES, // Acme
FIRST_K_DIRECTIVE = FIRST_B_DIRECTIVE + NUM_ASM_B_DIRECTIVES, // Big Mac
FIRST_L_DIRECTIVE = FIRST_K_DIRECTIVE + NUM_ASM_K_DIRECTIVES, // DOS Tool Kit
FIRST_M_DIRECTIVE = FIRST_L_DIRECTIVE + NUM_ASM_L_DIRECTIVES, // Lisa
FIRST_u_DIRECTIVE = FIRST_M_DIRECTIVE + NUM_ASM_M_DIRECTIVES, // Merlin
FIRST_O_DIRECTIVE = FIRST_u_DIRECTIVE + NUM_ASM_u_DIRECTIVES, // MicroSparc
FIRST_S_DIRECTIVE = FIRST_O_DIRECTIVE + NUM_ASM_O_DIRECTIVES, // Orca
FIRST_T_DIRECTIVE = FIRST_S_DIRECTIVE + NUM_ASM_S_DIRECTIVES, // SC
FIRST_W_DIRECTIVE = FIRST_T_DIRECTIVE + NUM_ASM_T_DIRECTIVES, // Ted
NUM_ASM_DIRECTIVES= FIRST_W_DIRECTIVE + NUM_ASM_W_DIRECTIVES, // Ted
// NUM_ASM_DIRECTIVES = 1 + // Opcode ... rest are psuedo opcodes
// NUM_ASM_A_DIRECTIVES + // Acme
// NUM_ASM_B_DIRECTIVES + // Big Mac
// NUM_ASM_K_DIRECTIVES + // DOS Tool Kit
// NUM_ASM_L_DIRECTIVES + // Lisa
// NUM_ASM_M_DIRECTIVES + // Merlin
// NUM_ASM_u_DIRECTIVES + // MicroSparc
// NUM_ASM_O_DIRECTIVES + // Orca
// NUM_ASM_S_DIRECTIVES + // SC
// NUM_ASM_T_DIRECTIVES + // Ted
// NUM_ASM_W_DIRECTIVES // Weller
};
// Addressing _____________________________________________________________________________________
extern AddressingMode_t g_aOpmodes[ NUM_ADDRESSING_MODES ];
@ -25,7 +136,7 @@
struct AssemblerDirective_t
{
char m_sMnemonic[ MAX_MNEMONIC_LEN + 1 ];
char *m_pMnemonic;
Hash_t m_nHash;
};
@ -39,6 +150,8 @@
extern const Opcodes_t g_aOpcodes65C02[ NUM_OPCODES ];
extern const Opcodes_t g_aOpcodes6502 [ NUM_OPCODES ];
extern AssemblerDirective_t g_aAssemblerDirectives[ NUM_ASM_DIRECTIVES ];
// Prototypes _______________________________________________________________
int _6502_GetOpmodeOpbyte( const int iAddress, int & iOpmode_, int & nOpbytes_ );