MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / AssemblerProcessDelayedSymols

Function AssemblerProcessDelayedSymols

source/Debugger/Debugger_Assembler.cpp:1484–1543  ·  view source on GitHub ↗

The Assembler was terminated, with Symbol(s) declared, but not (yet) defined. i.e. A 300 BNE $DONE ===========================================================================

Source from the content-addressed store, hash-verified

1482// <enter>
1483//===========================================================================
1484void AssemblerProcessDelayedSymols()
1485{
1486 m_bDelayedTargetsDirty = false; // assembler set signal if new symbol was added
1487
1488 bool bModified = false;
1489 while (! bModified)
1490 {
1491 bModified = false;
1492
1493 std::vector<DelayedTarget_t>::iterator iSymbol;
1494 for ( iSymbol = m_vDelayedTargets.begin(); iSymbol != m_vDelayedTargets.end(); ++iSymbol )
1495 {
1496 DelayedTarget_t *pTarget = & (*iSymbol); // m_vDelayedTargets.at( iSymbol );
1497
1498 WORD nTargetAddress;
1499 bool bExists = FindAddressFromSymbol( pTarget->m_sAddress, & nTargetAddress );
1500 if (bExists)
1501 {
1502 // TODO: need to handle #<symbol, #>symbol, symbol+n, symbol-n
1503
1504 bModified = true;
1505
1506 int nOpcode = pTarget->m_nOpcode;
1507 int nOpmode = g_aOpcodes[ nOpcode ].nAddressMode;
1508// int nOpbytes = g_aOpmodes[ nOpmode ].m_nBytes;
1509
1510 // 300: D0 7E BNE $380
1511 // ^ ^ ^
1512 // | | TargetAddress
1513 // | TargetValue
1514 // BaseAddress
1515 WORD nTargetValue = nTargetAddress;
1516
1517 if (_6502_CalcRelativeOffset( nOpcode, pTarget->m_nBaseAddress, nTargetAddress, & nTargetValue ))
1518 {
1519 if (m_iAsmAddressMode == NUM_OPMODES)
1520 {
1521 nTargetValue = 0;
1522 bModified = false;
1523 }
1524 }
1525
1526 if (bModified)
1527 {
1528 AssemblerPokeAddress( nOpcode, nOpmode, pTarget->m_nBaseAddress, nTargetValue );
1529 *(memdirty + (pTarget->m_nBaseAddress >> 8)) |= 1;
1530
1531 m_vDelayedTargets.erase( iSymbol );
1532
1533 // iterators are invalid after the point of deletion
1534 // need to restart enumeration
1535 break;
1536 }
1537 }
1538 }
1539
1540 if (! bModified)
1541 break;

Callers 1

AssembleFunction · 0.85

Calls 3

_6502_CalcRelativeOffsetFunction · 0.85
AssemblerPokeAddressFunction · 0.85
FindAddressFromSymbolFunction · 0.70

Tested by

no test coverage detected