The situation is that I programmed an assembler and I'm using a std::unordered_multimap
container to store all the different instructions, where the actual mnemonic is my key into the map and the associated value is a custom structure with some additonal information about the parameters, etc.
Since I don't need to make any changes to this lookup during runtime I thought I'd declare it as static and const and put all the values manually in an initializer_list.
Altogether it looks like this:
typedef std::wstring STRING;
static const
std::unordered_multimap<STRING, ASM_INSTRUCTION> InstructionLookup = {
// { MNEMONIC, { Opcode1, Opcode2, Param1Type, Param2Type, Param3Type, NrBytes, Bt1, Bt2, Bt3, Bt4, NoRexW, InvalidIn64Bit, InvalidIn32Bit } },
{ L"AAA",{ ot_none, ot_none, par_noparam, par_noparam, par_noparam, 1, 0x37, 0x00, 0x00, 0x00, false, true, false } },
{ L"AAD",{ ot_none, ot_none, par_noparam, par_noparam, par_noparam, 2, 0xD5, 0x0A, 0x00, 0x00, false, true, false } },
{ L"AAD",{ ot_ib, ot_none, par_imm8, par_noparam, par_noparam, 1, 0xD5, 0x00, 0x00, 0x00, false, true, false } },
{ L"AAM",{ ot_none, ot_none, par_noparam, par_noparam, par_noparam, 2, 0xD4, 0x0A, 0x00, 0x00, false, true, false } },
...
My problem now is that there're a lot of instructions (currently 1,225 of them) implemented.
So when I run a code-analysis with Visual Studio, it tells me that the constructor function exceeds the stack with 98,000/16,384 bytes because the constructor first puts all those entries on the stack it seems, before processing them any further.
My question now is how to initialize all that space directly on the heap, preferably without having to rewrite much of it.