mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-08 16:29:39 +00:00
Debugger: Fixup _6502_FindStackReturnAddress() return stack depth
This commit is contained in:
parent
17c9d029e2
commit
f8bdedccf7
|
@ -2362,10 +2362,10 @@ Update_t CmdStepOver (int nArgs)
|
|||
// <Ctrl>-<Space>
|
||||
// MSVC:
|
||||
// Change regs.sp to one of 3 cases:
|
||||
// Case Addr On Stack Top of Stack Diagnostic R SP
|
||||
// 0 No No ERROR nStackOffset = 0 regs.sp = 0x1F3
|
||||
// 1 Yes Yes INFO nStackOffset = 1 regs.sp = 0x1F2
|
||||
// 2 Yes No WARN nStackOffset > 1 regs.sp = 0x1F1
|
||||
// Case Addr On Stack Top of Stack Diagnostic nStackOffset R SP Continue in emulator
|
||||
// 0 No No ERROR -1 regs.sp = 0x1F3
|
||||
// 1 Yes Yes INFO O regs.sp = 0x1F2 R PC FCB3
|
||||
// 2 Yes No WARN +1 regs.sp = 0x1F1 R S F1
|
||||
/**/ if (nStackOffset < 0) ConsolePrintFormat( CHC_ERROR "ERROR" CHC_ARG_SEP ":" CHC_ERROR " Didn't step over JSR! " CHC_ARG_SEP "(" CHC_DEFAULT "RTS address not found!" CHC_ARG_SEP ")" ); // Case 0
|
||||
else if (nStackOffset == 0) ConsolePrintFormat( CHC_INFO "INFO" CHC_ARG_SEP ":" CHC_INFO " Didn't step over JSR! " CHC_ARG_SEP "(" CHC_DEFAULT "RTS on top of stack." CHC_ARG_SEP ")" ); // Case 1
|
||||
else /* */ ConsolePrintFormat( CHC_WARNING "WARN" CHC_ARG_SEP ":" CHC_WARNING " Didn't step over JSR! " CHC_ARG_SEP "(" CHC_DEFAULT "Stack has RTS address but needs fixup: " CHC_ARG_SEP "$" CHC_NUM_HEX "%02X" CHC_DEFAULT " bytes" CHC_ARG_SEP ")", nStackOffset & 0xFF ); // Case 2
|
||||
|
|
|
@ -464,11 +464,12 @@ bool _6502_CalcRelativeOffset ( int nOpcode, int nBaseAddress, int nTargetAddres
|
|||
return false;
|
||||
}
|
||||
|
||||
// Return stack offset if the address is on stack, else 0 if not found
|
||||
// Return stack offset if the address is on stack, else -1 if not found
|
||||
//===========================================================================
|
||||
int _6502_FindStackReturnAddress (const WORD & nAddress)
|
||||
{
|
||||
WORD nStack = regs.sp;
|
||||
int nDepth = -1; // not found
|
||||
nStack++;
|
||||
|
||||
while (nStack <= (_6502_STACK_END - 1))
|
||||
|
@ -480,10 +481,13 @@ int _6502_FindStackReturnAddress (const WORD & nAddress)
|
|||
nReturnAddress++;
|
||||
|
||||
if (nReturnAddress == nAddress)
|
||||
return (nStack-1 - regs.sp);
|
||||
{
|
||||
nDepth = (nStack - 2 - regs.sp);
|
||||
return nDepth;
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // not found
|
||||
return nDepth;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
Loading…
Reference in New Issue
Block a user