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

Function Assemble

source/Debugger/Debugger_Assembler.cpp:1546–1604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1544
1545
1546bool Assemble( int iArg, int nArgs, WORD nAddress )
1547{
1548 bool bGotArgs;
1549 bool bGotMode;
1550 bool bGotByte;
1551
1552 // Since, making 2-passes is not an option,
1553 // we need to buffer the target address fix-ups.
1554 AssemblerProcessDelayedSymols();
1555
1556 m_nAsmBaseAddress = nAddress;
1557
1558 char *pMnemonic = g_aArgs[ iArg ].sArg;
1559 Hash_t nMnemonicHash = AssemblerHashMnemonic( pMnemonic );
1560
1561#if DEBUG_ASSEMBLER
1562 ConsolePrintFormat( "%s%04X%s: %s%s%s -> %s%08X",
1563 CHC_ADDRESS, nAddress,
1564 CHC_DEFAULT,
1565 CHC_STRING, pMnemonic,
1566 CHC_DEFAULT,
1567 CHC_NUM_HEX, nMnemonicHash );
1568#endif
1569
1570 m_vAsmOpcodes.clear(); // Candiate opcodes
1571 int iOpcode;
1572
1573 // Ugh! Linear search.
1574 for ( iOpcode = 0; iOpcode < NUM_OPCODES; iOpcode++ )
1575 {
1576 if (nMnemonicHash == g_aOpcodesHash[ iOpcode ])
1577 {
1578 m_vAsmOpcodes.push_back( iOpcode );
1579 }
1580 }
1581
1582 const size_t nOpcodes = m_vAsmOpcodes.size();
1583 if (! nOpcodes)
1584 {
1585 // Check for assembler directive
1586
1587 ConsoleBufferPush( " Syntax Error: Invalid mnemonic" );
1588 return false;
1589 }
1590 else
1591 {
1592 bGotArgs = AssemblerGetArgs( iArg, nArgs, nAddress );
1593 if (bGotArgs)
1594 {
1595 bGotMode = AssemblerUpdateAddressingMode();
1596 if (bGotMode)
1597 {
1598 bGotByte = AssemblerPokeOpcodeAddress( nAddress );
1599 }
1600 }
1601 }
1602
1603 return true;

Callers 1

_CmdAssembleFunction · 0.85

Calls 8

AssemblerHashMnemonicFunction · 0.85
ConsolePrintFormatFunction · 0.85
AssemblerGetArgsFunction · 0.85
ConsoleBufferPushFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected