::iterator iter = blockMap.begin(); iter != blockMap.end(); ++iter)
{
if (iter != blockMap.begin())
thisBlock += ", ";
if (iter->second != 1 && numMnemonicsInBlock > 1 && differingCounts)
{
thisBlock += NumString(iter->second);
thisBlock += " ";
}
thisBlock += iter->first;
}
const string fullDescription = thisBlock;
if (numMnemonicsInBlock > 4)
{
thisBlock = "(MISC)";
}
blocksOf256Summary.push_back(thisBlock);
blocksOf256FullDescription.push_back(fullDescription);
}
printf("\n");
StTag html("HTML", "lang=\"en-US\"", kIndent_No);
printf("\n");
{
StTag head("HEAD", "", kIndent_Yes);
{
StTagSpan title("TITLE");
if (generateAllBlocks)
printf("AVR instruction set - all opcodes");
else
printf("AVR instruction set - selected opcode blocks");
}
#if 0
printf(" \n");
#endif
}
printf("\n");
StTag body("BODY", "", kIndent_No);
{
StTagSpan summaryHeader("A", "id=\"Summary\"");
}
{
StTagSpan summaryHeader("H1");
printf("Summary - Blocks of 256 instructions\n");
}
{
StTag table("TABLE", "border=1 frame=void", kIndent_Yes);
{
StTag tableHeader("TR", "", kIndent_Yes);
for (int col = -1; col < 16; ++col)
{
if (col < 0)
{
StTagSpan data("TH", "width=\"6%\" align=\"center\" bgcolor=\"#333333\"");
}
else
{
StTagSpan data("TH", "width=\"6%\" align=\"center\" bgcolor=\"#cccccc\"");
printf("x%Xzz", col);
}
}
}
for (int row = 0; row < 16; ++row)
{
StTag tableRow("TR", "", kIndent_Yes);
{
StTagSpan rowLabel("TH", "width=\"4%\" align=\"center\" bgcolor=\"#cccccc\"");
printf("%Xxzz", row);
}
for (int col = 0; col < 16; )
{
const int block = row * 16 + col;
int lastCol = col + 1;
while (lastCol < 16 && blocksOf256FullDescription[row * 16 + lastCol] == blocksOf256FullDescription[block])
++lastCol;
const int span = lastCol - col;
string attributes = (span == 1) ? "" : ("colspan=" + NumString(span));
// if fullDescription != summary, do title="full"
if (blocksOf256Summary[block] != blocksOf256FullDescription[block])
{
attributes += " title=\"" + blocksOf256FullDescription[block] + "\"";
}
else
{
// describe the mnemonic(s) from gMnemonicDescriptionMap
string singleMnemonic = blocksOf256Summary[block];
attributes += " title=\"" + gMnemonicDescriptionMap[singleMnemonic] + "\"";
}
if (!attributes.empty())
attributes += " ";
attributes += "width=\"6%\" align=\"center\"";
// Yellow background = block contains some 2-word instructions
if (BlockContainsAnyTwoWordInstructions(block))
{
attributes += " bgcolor=yellow";
}
StTagSpan data("TD", attributes);
StTagSpan link("A", "href=\"#Block" + NumString(block) + "\"", gBlocksToGenerate[block]);
if (block == 0xF0 || block == 0xF4)
printf("Conditional Branches");
else
printf("%s", blocksOf256Summary[block].c_str());
col = lastCol;
}
}
} // end of TABLE
printf("[R] = Reserved
\n");
// printf("Hover to see mnemonic descriptions
\n");
printf("Yellow boxes contain some two-word instructions
\n");
printf("Number of reserved opcodes: %d (%.1f%%)
\n", gReserved, gReserved * 100.0 / 65536);
// Generate all the desired tables of 256 individual opcode words
for (int block = 0; block <= 0xFF; ++block)
{
if (gBlocksToGenerate[block])
DisplayBlock(block);
}
printf("
\n");
printf("Generated from avr-objdump version '%s'
\n", VersionOfAVRObjdump().c_str());
return 0;
}
//
// Generate a table for one block of 256 opcodes
//
void DisplayBlock(int block)
{
const int base = block * 256;
int numUndefined = 0;
int numTwoWord = 0;
int numReserved = 0;
int numXmega = 0;
vector mnemonicsInThisBlock;
{
string name = "id=\"Block" + NumString(block) + "\"";
StTagSpan anchor("A", name);
}
{
StTagSpan header("H1", "");
printf("Opcodes %02Xxx (0x%02X00 - 0x%02XFF)\n", block, block, block);
}
{
StTag table("TABLE", "border=1 frame=void", kIndent_Yes);
{
StTag tableHeader("TR", "", kIndent_Yes);
for (int col = -1; col < 16; ++col)
{
if (col < 0)
{
StTagSpan data("TH", "width=\"6%\" align=\"center\" bgcolor=\"#333333\"");
}
else
{
StTagSpan data("TH", "width=\"6%\" align=\"center\" bgcolor=\"#cccccc\"");
printf("%X", col);
}
}
}
for (int row = 0; row < 16; ++row)
{
StTag tableRow("TR", "", kIndent_Yes);
{
StTagSpan rowLabel("TH", "width=\"4%\" align=\"center\" bgcolor=\"#cccccc\"");
printf("%02X%Xx", block, row);
}
for (int col = 0; col < 16; )
{
const int instr = row * 16 + col;
const int opcode = base + instr;
int lastCol = col + 1;
while (lastCol < 16 && instrs[base + row * 16 + lastCol] == instrs[opcode])
++lastCol;
const int span = lastCol - col;
string attributes = (span == 1) ? "" : ("colspan=" + NumString(span));
if (TwoWordInstruction(opcode))
{
attributes += " bgcolor=\"yellow\"";
numTwoWord += span;
}
else if (NewForXmega(opcode))
{
attributes += " bgcolor=\"green\"";
numXmega += span;
}
else if (ReservedInstruction(opcode))
{
attributes += " bgcolor=\"#888888\"";
numReserved += span;
}
else if (strstr(instrs[opcode].c_str(), "undefined"))
{
attributes += " bgcolor=\"red\"";
numUndefined += span;
}
// Describe the mnemonic
{
attributes += " title=\"" + gMnemonicDescriptionMap[mnemonics[opcode]] + "\"";
}
if (!attributes.empty())
attributes += " ";
attributes += "width=\"6%\" align=\"center\"";
StTagSpan data("TD", attributes);
printf("%s", instrs[opcode].c_str());
if (find(mnemonicsInThisBlock.begin(), mnemonicsInThisBlock.end(), mnemonics[opcode]) == mnemonicsInThisBlock.end())
mnemonicsInThisBlock.push_back(mnemonics[opcode]);
col = lastCol;
}
}
} // end of TABLE
if (numUndefined + numTwoWord + numReserved + numXmega > 0)
{
StTag indent("BLOCKQUOTE", "", kIndent_Yes);
StTag paragraph("P", "", kIndent_Yes);
if (numXmega > 0)
printf("Green = opcode newly defined for ATxmega (%d)
\n", numXmega);
if (numUndefined > 0)
printf("Red = instruction has undefined behavior (%d)
\n", numUndefined);
if (numTwoWord > 0)
printf("Yellow = two-word instruction (%d)
\n", numTwoWord);
if (numReserved > 0)
printf("[R] = Reserved (%d)
\n", numReserved);
}
// Give definitions of all the mnenoics used in the table
sort(mnemonicsInThisBlock.begin(), mnemonicsInThisBlock.end());
{
StTag indent("BLOCKQUOTE", "", kIndent_Yes);
{
StTag t("TABLE", "", kIndent_Yes);
for (vector::iterator iter = mnemonicsInThisBlock.begin(); iter != mnemonicsInThisBlock.end(); ++iter)
{
if (*iter == "[R]") // don't show [R] in the table (we already displayed the count, above)
continue;
StTag row("TR", "", kIndent_Yes);
{
StTagSpan td("TD");
StTagSpan italics("I");
printf("%s", iter->c_str());
}
{
StTagSpan td("TD");
printf(" - %s", gMnemonicDescriptionMap[*iter].c_str());
}
}
}
}
// '^ summary' link
{
StTagSpan link("A", "href=\"#Summary\"");
printf("^ summary");
}
}