mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-01-01 12:31:59 +00:00
Debugger: Add: First pass of DF
This commit is contained in:
parent
32ee96fb8b
commit
182e48e82d
@ -509,6 +509,7 @@ int _6502_GetOpmodeOpbyte ( const int nBaseAddress, int & iOpmode_, int & nOpby
|
|||||||
case NOP_BYTE_2: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
case NOP_BYTE_2: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
||||||
case NOP_BYTE_4: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
case NOP_BYTE_4: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
||||||
case NOP_BYTE_8: nOpbyte_ = 8; iOpmode_ = AM_M; break;
|
case NOP_BYTE_8: nOpbyte_ = 8; iOpmode_ = AM_M; break;
|
||||||
|
case NOP_FAC : nOpbyte_ = 5; iOpmode_ = AM_M; break;
|
||||||
case NOP_WORD_1: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
case NOP_WORD_1: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
||||||
case NOP_WORD_2: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
case NOP_WORD_2: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
||||||
case NOP_WORD_4: nOpbyte_ = 8; iOpmode_ = AM_M; break;
|
case NOP_WORD_4: nOpbyte_ = 8; iOpmode_ = AM_M; break;
|
||||||
|
@ -100,6 +100,7 @@
|
|||||||
,NUM_ASM_W_DIRECTIVES
|
,NUM_ASM_W_DIRECTIVES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NOTE: Keep in sync! AsmCustomDirective_e g_aAssemblerDirectives
|
||||||
enum AsmCustomDirective_e
|
enum AsmCustomDirective_e
|
||||||
{
|
{
|
||||||
ASM_DEFINE_BYTE
|
ASM_DEFINE_BYTE
|
||||||
|
@ -140,7 +140,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
{TEXT("DW2") , CmdDisasmDataDefWord2 , CMD_DEFINE_DATA_WORD2, "Define address array, display 2 words/line" },
|
{TEXT("DW2") , CmdDisasmDataDefWord2 , CMD_DEFINE_DATA_WORD2, "Define address array, display 2 words/line" },
|
||||||
{TEXT("DW4") , CmdDisasmDataDefWord4 , CMD_DEFINE_DATA_WORD4, "Define address array, display 4 words/line" },
|
{TEXT("DW4") , CmdDisasmDataDefWord4 , CMD_DEFINE_DATA_WORD4, "Define address array, display 4 words/line" },
|
||||||
{TEXT("ASC") , CmdDisasmDataDefString , CMD_DEFINE_DATA_STR , "Define text string" }, // 2.7.0.26 Changed: DS to ASC because DS is used as "Define Space" assembler directive
|
{TEXT("ASC") , CmdDisasmDataDefString , CMD_DEFINE_DATA_STR , "Define text string" }, // 2.7.0.26 Changed: DS to ASC because DS is used as "Define Space" assembler directive
|
||||||
// {TEXT("DF") , CmdDisasmDataDefFloat , CMD_DEFINE_DATA_FLOAT, "Define AppleSoft (packed) Float" },
|
{TEXT("DF") , CmdDisasmDataDefFloat , CMD_DEFINE_DATA_FLOAT, "Define AppleSoft (packed) Float" },
|
||||||
// {TEXT("DFX") , CmdDisasmDataDefFloatUnpack , CMD_DEFINE_DATA_FLOAT2,"Define AppleSoft (unpacked) Float" },
|
// {TEXT("DFX") , CmdDisasmDataDefFloatUnpack , CMD_DEFINE_DATA_FLOAT2,"Define AppleSoft (unpacked) Float" },
|
||||||
// with symbol lookup
|
// with symbol lookup
|
||||||
// {TEXT("DA<>") , CmdDisasmDataDefAddress8HL , CMD_DEFINE_ADDR_8_HL , "Define split array of addresses, high byte section followed by low byte section" },
|
// {TEXT("DA<>") , CmdDisasmDataDefAddress8HL , CMD_DEFINE_ADDR_8_HL , "Define split array of addresses, high byte section followed by low byte section" },
|
||||||
|
@ -466,6 +466,45 @@ void FormatOpcodeBytes(WORD nBaseAddress, DisasmLine_t& line_)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FAC_t
|
||||||
|
{
|
||||||
|
uint8_t negative;
|
||||||
|
int8_t exponent;
|
||||||
|
uint32_t mantissa;
|
||||||
|
|
||||||
|
bool isZero;
|
||||||
|
};
|
||||||
|
|
||||||
|
void FAC_Unpack(WORD nAddress, FAC_t& fac_)
|
||||||
|
{
|
||||||
|
BYTE e0 = *(LPBYTE)(mem + nAddress + 0);
|
||||||
|
BYTE m1 = *(LPBYTE)(mem + nAddress + 1);
|
||||||
|
BYTE m2 = *(LPBYTE)(mem + nAddress + 2);
|
||||||
|
BYTE m3 = *(LPBYTE)(mem + nAddress + 3);
|
||||||
|
BYTE m4 = *(LPBYTE)(mem + nAddress + 4);
|
||||||
|
|
||||||
|
// sign
|
||||||
|
// EB82:A5 9D SIGN LDA FAC
|
||||||
|
// EB84:F0 09 BEQ SIGN3 ; zero
|
||||||
|
// EB86:A5 A2 SIGN1 LDA FAC.SIGN
|
||||||
|
// EB88:2A SIGN2 ROL
|
||||||
|
// EB89:A9 FF LDA #$FF ; negative
|
||||||
|
// EB8B:B0 02 BCS SIGN3
|
||||||
|
// EB8D:A9 01 LDA #$01 ; positive
|
||||||
|
// EB8F:60 SIGN3
|
||||||
|
|
||||||
|
fac_.exponent = e0 - 0x80;
|
||||||
|
fac_.negative =(m1 & 0x80) >> 7; // EBAF:46 A2 ABS LSR FAC.SIGN
|
||||||
|
fac_.mantissa = 0
|
||||||
|
| ((m1 | 0x80) << 24) // implicit 1.0, EB12: ORA #$80, STA FAC+1
|
||||||
|
| ((m2 ) << 16)
|
||||||
|
| ((m3 ) << 8)
|
||||||
|
| ((m4 ) << 0);
|
||||||
|
|
||||||
|
fac_.isZero = (fac_.exponent == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Formats Target string with bytes,words, string, etc...
|
// Formats Target string with bytes,words, string, etc...
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void FormatNopcodeBytes(WORD nBaseAddress, DisasmLine_t& line_)
|
void FormatNopcodeBytes(WORD nBaseAddress, DisasmLine_t& line_)
|
||||||
@ -499,6 +538,23 @@ void FormatNopcodeBytes(WORD nBaseAddress, DisasmLine_t& line_)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NOP_FAC:
|
||||||
|
{
|
||||||
|
FAC_t fac;
|
||||||
|
FAC_Unpack( nBaseAddress, fac );
|
||||||
|
const char aSign[2] = { '+', '-' };
|
||||||
|
if (fac.isZero)
|
||||||
|
sprintf( pDst, "0" );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double f = fac.mantissa * pow( 2.0, fac.exponent - 32 );
|
||||||
|
//sprintf( "s%1X m%04X e%02X", fac.negative, fac.mantissa, fac.exponent );
|
||||||
|
sprintf( pDst, "%c%f", aSign[ fac.negative ], f );
|
||||||
|
}
|
||||||
|
iByte += 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case NOP_WORD_1:
|
case NOP_WORD_1:
|
||||||
case NOP_WORD_2:
|
case NOP_WORD_2:
|
||||||
case NOP_WORD_4:
|
case NOP_WORD_4:
|
||||||
|
@ -40,6 +40,9 @@ void _GetAutoSymbolName ( const Nopcode_e &nopcode, const WORD nStartAddress, ch
|
|||||||
sprintf( pSymbolName, "A_%04X", nStartAddress ); // DA range
|
sprintf( pSymbolName, "A_%04X", nStartAddress ); // DA range
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NOP_FAC:
|
||||||
|
sprintf( pSymbolName, "F_%04X", nStartAddress ); // DF range
|
||||||
|
|
||||||
case NOP_STRING_ASCII:
|
case NOP_STRING_ASCII:
|
||||||
case NOP_STRING_APPLE:
|
case NOP_STRING_APPLE:
|
||||||
sprintf( pSymbolName, "T_%04X", nStartAddress ); // ASC range
|
sprintf( pSymbolName, "T_%04X", nStartAddress ); // ASC range
|
||||||
@ -159,10 +162,12 @@ WORD _CmdDefineByteRange(int nArgs,int iArg,DisasmData_t & tData_)
|
|||||||
// Old name: auto define D_# DB $XX
|
// Old name: auto define D_# DB $XX
|
||||||
// Example 'DB' or 'DW' with 1 arg
|
// Example 'DB' or 'DW' with 1 arg
|
||||||
// DB 801
|
// DB 801
|
||||||
if( bAutoDefineName )
|
|
||||||
{
|
|
||||||
Nopcode_e nopcode = NOP_BYTE_1;
|
Nopcode_e nopcode = NOP_BYTE_1;
|
||||||
|
|
||||||
|
bool isFloat = (g_iCommand == CMD_DEFINE_DATA_FLOAT);
|
||||||
|
if( isFloat )
|
||||||
|
nopcode = NOP_FAC;
|
||||||
|
|
||||||
bool isString = (g_iCommand == CMD_DEFINE_DATA_STR);
|
bool isString = (g_iCommand == CMD_DEFINE_DATA_STR);
|
||||||
if( isString )
|
if( isString )
|
||||||
nopcode = NOP_STRING_ASCII;
|
nopcode = NOP_STRING_ASCII;
|
||||||
@ -175,6 +180,8 @@ WORD _CmdDefineByteRange(int nArgs,int iArg,DisasmData_t & tData_)
|
|||||||
if( isAddr )
|
if( isAddr )
|
||||||
nopcode = NOP_ADDRESS;
|
nopcode = NOP_ADDRESS;
|
||||||
|
|
||||||
|
if( bAutoDefineName )
|
||||||
|
{
|
||||||
_GetAutoSymbolName( nopcode, tData_.nStartAddress , aSymbolName );
|
_GetAutoSymbolName( nopcode, tData_.nStartAddress , aSymbolName );
|
||||||
pSymbolName = aSymbolName;
|
pSymbolName = aSymbolName;
|
||||||
}
|
}
|
||||||
@ -184,6 +191,10 @@ WORD _CmdDefineByteRange(int nArgs,int iArg,DisasmData_t & tData_)
|
|||||||
SymbolUpdate( eSymbolTable, pSymbolName, nAddress, false, true );
|
SymbolUpdate( eSymbolTable, pSymbolName, nAddress, false, true );
|
||||||
|
|
||||||
// TODO: Note: need to call ConsoleUpdate(), as may print symbol has been updated
|
// TODO: Note: need to call ConsoleUpdate(), as may print symbol has been updated
|
||||||
|
|
||||||
|
// NOTE: We don't set the type here
|
||||||
|
// tData_.eElementType = nopcode;
|
||||||
|
// As that is done by the caller.
|
||||||
|
|
||||||
strcpy_s( tData_.sSymbol, sizeof(tData_.sSymbol), pSymbolName );
|
strcpy_s( tData_.sSymbol, sizeof(tData_.sSymbol), pSymbolName );
|
||||||
|
|
||||||
@ -359,6 +370,11 @@ Update_t CmdDisasmDataList (int nArgs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Common code
|
// Common code
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: merge _CmdDisasmDataDefByteX() and _CmdDisasmDataDefWordX
|
||||||
|
// add params( iDirective, iOpcode ) to allow ASM_DEFINE_FLOAT, NOP_FAC
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
Update_t _CmdDisasmDataDefByteX (int nArgs)
|
Update_t _CmdDisasmDataDefByteX (int nArgs)
|
||||||
{
|
{
|
||||||
@ -528,6 +544,14 @@ Update_t CmdDisasmDataDefByte8 ( int nArgs )
|
|||||||
return _CmdDisasmDataDefByteX( nArgs );
|
return _CmdDisasmDataDefByteX( nArgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DF
|
||||||
|
Update_t CmdDisasmDataDefFloat(int nArgs)
|
||||||
|
{
|
||||||
|
g_aArgs[0].nValue = NOP_FAC;
|
||||||
|
return _CmdDisasmDataDefByteX( nArgs );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// DW
|
// DW
|
||||||
Update_t CmdDisasmDataDefWord1 ( int nArgs )
|
Update_t CmdDisasmDataDefWord1 ( int nArgs )
|
||||||
{
|
{
|
||||||
|
@ -398,6 +398,7 @@
|
|||||||
, CMD_DEFINE_DATA_WORD2
|
, CMD_DEFINE_DATA_WORD2
|
||||||
, CMD_DEFINE_DATA_WORD4
|
, CMD_DEFINE_DATA_WORD4
|
||||||
, CMD_DEFINE_DATA_STR
|
, CMD_DEFINE_DATA_STR
|
||||||
|
, CMD_DEFINE_DATA_FLOAT// FAC Packed
|
||||||
// , CMD_DEFINE_DATA_FACP // FAC Packed
|
// , CMD_DEFINE_DATA_FACP // FAC Packed
|
||||||
// , CMD_DEFINE_DATA_FACU // FAC Unpacked
|
// , CMD_DEFINE_DATA_FACU // FAC Unpacked
|
||||||
// , CMD_DATA_DEFINE_ADDR_BYTE_L // DB< address symbol
|
// , CMD_DATA_DEFINE_ADDR_BYTE_L // DB< address symbol
|
||||||
@ -590,6 +591,8 @@
|
|||||||
Update_t CmdDisasmDataDefByte4 (int nArgs);
|
Update_t CmdDisasmDataDefByte4 (int nArgs);
|
||||||
Update_t CmdDisasmDataDefByte8 (int nArgs);
|
Update_t CmdDisasmDataDefByte8 (int nArgs);
|
||||||
|
|
||||||
|
Update_t CmdDisasmDataDefFloat (int nArgs);
|
||||||
|
|
||||||
Update_t CmdDisasmDataDefWord1 (int nArgs);
|
Update_t CmdDisasmDataDefWord1 (int nArgs);
|
||||||
Update_t CmdDisasmDataDefWord2 (int nArgs);
|
Update_t CmdDisasmDataDefWord2 (int nArgs);
|
||||||
Update_t CmdDisasmDataDefWord4 (int nArgs);
|
Update_t CmdDisasmDataDefWord4 (int nArgs);
|
||||||
@ -877,7 +880,7 @@
|
|||||||
char sSymbol[ MAX_SYMBOLS_LEN+1 ];
|
char sSymbol[ MAX_SYMBOLS_LEN+1 ];
|
||||||
|
|
||||||
Nopcode_e eElementType ; // eElementType -> iNoptype
|
Nopcode_e eElementType ; // eElementType -> iNoptype
|
||||||
int iDirective ; // iDirective -> iNopcode
|
int iDirective ; // iDirective -> iNopcode ASC DA DB DF DW etc.
|
||||||
|
|
||||||
WORD nStartAddress; // link to block [start,end)
|
WORD nStartAddress; // link to block [start,end)
|
||||||
WORD nEndAddress ;
|
WORD nEndAddress ;
|
||||||
|
Loading…
Reference in New Issue
Block a user