2010-06-11 15:38:22 +00:00
|
|
|
#ifndef DEBUGGER_ASSEMBLER_H
|
|
|
|
#define DEBUGGER_ASSEMBLER_H
|
|
|
|
|
|
|
|
// Directives
|
|
|
|
|
|
|
|
// Assemblers
|
|
|
|
// A = Acme
|
|
|
|
// B = Big Mac S= S-C Macro Assembler
|
2010-12-16 06:43:05 +00:00
|
|
|
// D = DOS Tool Kit T = TED II
|
2010-06-11 15:38:22 +00:00
|
|
|
// L = Lisa W = Weller's Assembler
|
|
|
|
// M = Merlin
|
|
|
|
// u = MicroSparc
|
|
|
|
// O = ORCA/M
|
2010-12-16 06:43:05 +00:00
|
|
|
enum Assemblers_e
|
|
|
|
{
|
|
|
|
ASM_ACME
|
|
|
|
, ASM_BIG_MAC
|
|
|
|
, ASM_DOS_TOOL_KIT
|
|
|
|
, ASM_LISA
|
|
|
|
, ASM_MERLIN
|
|
|
|
, ASM_MICROSPARC
|
|
|
|
, ASM_ORCA
|
|
|
|
, ASM_SC
|
|
|
|
, ASM_TED
|
|
|
|
, ASM_WELLERS
|
|
|
|
, ASM_CUSTOM
|
|
|
|
,NUM_ASSEMBLERS
|
|
|
|
};
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
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
|
|
|
|
{
|
2010-12-16 06:43:05 +00:00
|
|
|
ASM_D_DEFINE_BYTE
|
|
|
|
,NUM_ASM_D_DIRECTIVES
|
2010-06-11 15:38:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2022-01-06 18:10:09 +00:00
|
|
|
// NOTE: Keep in sync! AsmCustomDirective_e g_aAssemblerDirectives
|
2010-12-16 06:43:05 +00:00
|
|
|
enum AsmCustomDirective_e
|
|
|
|
{
|
|
|
|
ASM_DEFINE_BYTE
|
|
|
|
,ASM_DEFINE_WORD
|
|
|
|
// ,ASM_DEFINE_ADDRESS_8
|
|
|
|
,ASM_DEFINE_ADDRESS_16
|
|
|
|
// String/Text/Ascii
|
|
|
|
,ASM_DEFINE_ASCII_TEXT
|
|
|
|
,ASM_DEFINE_APPLE_TEXT
|
|
|
|
,ASM_DEFINE_TEXT_HI_LO // i.e. Applesoft Basic Tokens
|
|
|
|
// FAC
|
|
|
|
,ASM_DEFINE_FLOAT // Applesoft float
|
|
|
|
,ASM_DEFINE_FLOAT_X // Applesoft float unpacked/expanded
|
|
|
|
,NUM_ASM_Z_DIRECTIVES
|
|
|
|
};
|
|
|
|
|
|
|
|
// NOTE: Keep in sync AsmDirectives_e g_aAssemblerDirectives !
|
2010-06-11 15:38:22 +00:00
|
|
|
enum AsmDirectives_e
|
|
|
|
{
|
2014-08-28 23:52:41 +00:00
|
|
|
FIRST_A_DIRECTIVE = 1 , // Acme
|
|
|
|
FIRST_B_DIRECTIVE = FIRST_A_DIRECTIVE + NUM_ASM_A_DIRECTIVES, // Big Mac
|
|
|
|
FIRST_D_DIRECTIVE = FIRST_B_DIRECTIVE + NUM_ASM_B_DIRECTIVES, // DOS Tool Kit
|
|
|
|
FIRST_L_DIRECTIVE = FIRST_D_DIRECTIVE + NUM_ASM_D_DIRECTIVES, // Lisa
|
|
|
|
FIRST_M_DIRECTIVE = FIRST_L_DIRECTIVE + NUM_ASM_L_DIRECTIVES, // Merlin
|
|
|
|
FIRST_u_DIRECTIVE = FIRST_M_DIRECTIVE + NUM_ASM_M_DIRECTIVES, // MicroSparc
|
|
|
|
FIRST_O_DIRECTIVE = FIRST_u_DIRECTIVE + NUM_ASM_u_DIRECTIVES, // Orca
|
|
|
|
FIRST_S_DIRECTIVE = FIRST_O_DIRECTIVE + NUM_ASM_O_DIRECTIVES, // SC
|
|
|
|
FIRST_T_DIRECTIVE = FIRST_S_DIRECTIVE + NUM_ASM_S_DIRECTIVES, // Ted
|
|
|
|
FIRST_W_DIRECTIVE = FIRST_T_DIRECTIVE + NUM_ASM_T_DIRECTIVES, // Weller
|
|
|
|
FIRST_Z_DIRECTIVE = FIRST_W_DIRECTIVE + NUM_ASM_W_DIRECTIVES, // Custom
|
|
|
|
NUM_ASM_DIRECTIVES = FIRST_Z_DIRECTIVE + NUM_ASM_Z_DIRECTIVES
|
2010-06-11 15:38:22 +00:00
|
|
|
|
|
|
|
// NUM_ASM_DIRECTIVES = 1 + // Opcode ... rest are psuedo opcodes
|
|
|
|
// NUM_ASM_A_DIRECTIVES + // Acme
|
|
|
|
// NUM_ASM_B_DIRECTIVES + // Big Mac
|
2010-12-16 06:43:05 +00:00
|
|
|
// NUM_ASM_D_DIRECTIVES + // DOS Tool Kit
|
2010-06-11 15:38:22 +00:00
|
|
|
// 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
|
|
|
|
};
|
|
|
|
|
2010-12-16 06:43:05 +00:00
|
|
|
extern int g_iAssemblerSyntax;
|
|
|
|
extern int g_aAssemblerFirstDirective[ NUM_ASSEMBLERS ];
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
// Addressing _____________________________________________________________________________________
|
|
|
|
|
|
|
|
extern AddressingMode_t g_aOpmodes[ NUM_ADDRESSING_MODES ];
|
|
|
|
|
|
|
|
// Assembler ______________________________________________________________________________________
|
|
|
|
|
|
|
|
// Hashing for Assembler
|
|
|
|
typedef unsigned int Hash_t;
|
|
|
|
|
|
|
|
struct HashOpcode_t
|
|
|
|
{
|
|
|
|
int m_iOpcode;
|
|
|
|
Hash_t m_nValue;
|
|
|
|
|
|
|
|
// functor
|
|
|
|
bool operator () (const HashOpcode_t & rLHS, const HashOpcode_t & rRHS) const
|
|
|
|
{
|
|
|
|
bool bLessThan = (rLHS.m_nValue < rRHS.m_nValue);
|
|
|
|
return bLessThan;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AssemblerDirective_t
|
|
|
|
{
|
2021-02-10 21:05:00 +00:00
|
|
|
const char *m_pMnemonic;
|
2010-06-11 15:38:22 +00:00
|
|
|
Hash_t m_nHash;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int g_bAssemblerOpcodesHashed; // = false;
|
|
|
|
extern Hash_t g_aOpcodesHash[ NUM_OPCODES ]; // for faster mnemonic lookup, for the assembler
|
|
|
|
extern bool g_bAssemblerInput; // = false;
|
|
|
|
extern int g_nAssemblerAddress; // = 0;
|
|
|
|
|
|
|
|
extern const Opcodes_t *g_aOpcodes; // = NULL; // & g_aOpcodes65C02[ 0 ];
|
|
|
|
|
|
|
|
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 _______________________________________________________________
|
|
|
|
|
2014-08-28 23:52:41 +00:00
|
|
|
int _6502_GetOpmodeOpbyte( const int iAddress, int & iOpmode_, int & nOpbytes_, const DisasmData_t** pData = NULL );
|
2010-06-11 15:38:22 +00:00
|
|
|
void _6502_GetOpcodeOpmodeOpbyte( int & iOpcode_, int & iOpmode_, int & nOpbytes_ );
|
|
|
|
bool _6502_GetStackReturnAddress( WORD & nAddress_ );
|
2019-12-09 20:42:16 +00:00
|
|
|
bool _6502_GetTargets( WORD nAddress, int *pTargetPartial_, int *pTargetPartial2_, int *pTargetPointer_, int * pBytes_,
|
|
|
|
bool bIgnoreBranch = true, bool bIncludeNextOpcodeAddress = true );
|
2010-06-11 15:38:22 +00:00
|
|
|
bool _6502_GetTargetAddress( const WORD & nAddress, WORD & nTarget_ );
|
|
|
|
bool _6502_IsOpcodeBranch( int nOpcode );
|
|
|
|
bool _6502_IsOpcodeValid( int nOpcode );
|
|
|
|
|
2020-10-11 16:14:03 +00:00
|
|
|
Hash_t AssemblerHashMnemonic ( const TCHAR * pMnemonic );
|
2014-08-14 19:29:01 +00:00
|
|
|
// bool AssemblerGetAddressingMode ( int iArg, int nArgs, WORD nAddress, std::vector<int> & vOpcodes );
|
2010-06-11 15:38:22 +00:00
|
|
|
void _CmdAssembleHashDump ();
|
|
|
|
|
|
|
|
int AssemblerDelayedTargetsSize();
|
|
|
|
void AssemblerStartup ();
|
|
|
|
bool Assemble( int iArg, int nArgs, WORD nAddress );
|
|
|
|
|
|
|
|
void AssemblerOn ();
|
|
|
|
void AssemblerOff ();
|
|
|
|
|
|
|
|
#endif
|