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

Function FormatNopcodeBytes

source/Debugger/Debugger_Disassembler.cpp:516–655  ·  view source on GitHub ↗

Formats Target string with bytes,words, string, etc... ===========================================================================

Source from the content-addressed store, hash-verified

514// Formats Target string with bytes,words, string, etc...
515//===========================================================================
516void FormatNopcodeBytes(WORD nBaseAddress, DisasmLine_t& line_)
517{
518 // TODO: One day, line_.sTarget should become a std::string and things would be much simpler.
519 char* pDst = line_.sTarget;
520 const char* const pEnd = pDst + sizeof(line_.sTarget);
521 const uint32_t nStartAddress = line_.pDisasmData->nStartAddress;
522 const uint32_t nEndAddress = line_.pDisasmData->nEndAddress;
523 const int nDisplayLen = nEndAddress - nBaseAddress + 1; // *inclusive* KEEP IN SYNC: _CmdDefineByteRange() CmdDisasmDataList() _6502_GetOpmodeOpbyte() FormatNopcodeBytes()
524
525 for (int iByte = 0; iByte < line_.nOpbyte; )
526 {
527 BYTE nTarget8 = ReadByteFromMemory(nBaseAddress + iByte);
528 WORD nTarget16 = ReadWordFromMemory(nBaseAddress + iByte);
529
530 switch (line_.iNoptype)
531 {
532 case NOP_BYTE_1:
533 case NOP_BYTE_2:
534 case NOP_BYTE_4:
535 case NOP_BYTE_8:
536 if ((pDst + 2) < pEnd)
537 pDst = StrBufferAppendByteAsHex(pDst, nTarget8);
538 iByte++;
539 if (line_.iNoptype == NOP_BYTE_1)
540 {
541 if (iByte < line_.nOpbyte)
542 {
543 if ((pDst + 1) < pEnd)
544 *pDst++ = ',';
545 }
546 }
547 *pDst = '\0';
548 break;
549
550 case NOP_FAC:
551 {
552 FAC_t fac;
553 FAC_Unpack( nBaseAddress, fac );
554 const char aSign[2] = { '+', '-' };
555 if (fac.isZero)
556 {
557 // 2.9.1.21 Fixed: `df` showing zero was displaying 0 instead 0.0
558 // Format 0.0 so users know this is a floating point value
559 std::string sFac( "0.0" );
560 if ((pDst + 3) < pEnd)
561 {
562 memcpy(pDst, sFac.c_str(), sFac.length());
563 pDst += sFac.length();
564 }
565 // No room???
566 }
567 else
568 {
569 const double f = fac.mantissa * pow( 2.0, fac.exponent - 32 );
570 //std::string sFac = StrFormat( "s%1X m%08X e%02X", fac.negative, fac.mantissa, fac.exponent & 0xFF );
571 // 2.9.1.23: Show floating-point values in scientific notation.
572 std::string sFac = StrFormat( "%c%e", aSign[ fac.negative ], f );
573 if ((pDst + sFac.length()) < pEnd)

Callers 1

GetDisassemblyLineFunction · 0.85

Calls 7

ReadByteFromMemoryFunction · 0.85
ReadWordFromMemoryFunction · 0.85
StrBufferAppendByteAsHexFunction · 0.85
FAC_UnpackFunction · 0.85
StrFormatFunction · 0.85
StrBufferAppendWordAsHexFunction · 0.85
FormatCharCopyFunction · 0.85

Tested by

no test coverage detected