10#pragma optimize("gst", on)
11#pragma auto_inline(on)
13#pragma GCC optimize("O3,inline")
22#define PROFILING_ENABLED 0
107#define FOLLOWED_BY(x) x
109#define ANY_CHAR R"((?:.|\n))"
110#define WHITESPACE R"((?:[ \t]++))"
111#define NEWLINE R"([\n])"
112#define WS_OR_NL R"((?:)" WHITESPACE "|" NEWLINE R"()+)"
113#define SEPARATOR R"([\s,\=\+\-\*\/\:\~\[\]])"
116 "AAA|AAD|AAM|AAS|ADC|ADCX|ADD|ADDPD|ADDPS|ADDSD|ADDSS|ADDSUBPD|ADDSUBPS|" \
117 "ADOX|AESDEC|AESDECLAST|AESENC|AESENCLAST|AESIMC|AESKEYGENASSIST|AND|ANDN|" \
118 "ANDNPD|ANDNPS|ANDPD|ANDPS|ARPL|BEXTR|BLENDPD|BLENDPS|BLENDVPD|BLENDVPS|" \
119 "BLSI|BLSMSK|BLSR|BNDCL|BNDCN|BNDCU|BNDLDX|BNDMK|BNDMOV|BNDSTX|BOUND|BSF|" \
120 "BSR|BSWAP|BT|BTC|BTR|BTS|BZHI|CALL|CBW|CDQ|CDQE|CLAC|CLC|CLD|CLDEMOTE|" \
121 "CLFLUSH|CLFLUSHOPT|CLI|CLTS|CLWB|CMC|CMOVcc|CMP|CMPPD|CMPPS|CMPS|CMPSB|" \
122 "CMPSD|CMPSQ|CMPSS|CMPSW|CMPXCHG|CMPXCHG16B|CMPXCHG8B|COMISD|COMISS|CPUID|" \
123 "CQO|CRC32|CVTDQ2PD|CVTDQ2PS|CVTPD2DQ|CVTPD2PI|CVTPD2PS|CVTPI2PD|CVTPI2PS|" \
124 "CVTPS2DQ|CVTPS2PD|CVTPS2PI|CVTSD2SI|CVTSD2SS|CVTSI2SD|CVTSI2SS|CVTSS2SD|" \
125 "CVTSS2SI|CVTTPD2DQ|CVTTPD2PI|CVTTPS2DQ|CVTTPS2PI|CVTTSD2SI|CVTTSS2SI|CWD|" \
126 "CWDE|DAA|DAS|DEC|DIV|DIVPD|DIVPS|DIVSD|DIVSS|DPPD|DPPS|EMMS|ENTER|" \
127 "EXTRACTPS|F2XM1|FABS|FADD|FADDP|FBLD|FBSTP|FCHS|FCLEX|FCMOVcc|FCOM|FCOMI|" \
128 "FCOMIP|FCOMP|FCOMPP|FCOS|FDECSTP|FDIV|FDIVP|FDIVR|FDIVRP|FFREE|FIADD|" \
129 "FICOM|FICOMP|FIDIV|FIDIVR|FILD|FIMUL|FINCSTP|FINIT|FIST|FISTP|FISTTP|" \
130 "FISUB|FISUBR|FLD|FLD1|FLDCW|FLDENV|FLDL2E|FLDL2T|FLDLG2|FLDLN2|FLDPI|" \
131 "FLDZ|FMUL|FMULP|FNCLEX|FNINIT|FNOP|FNSAVE|FNSTCW|FNSTENV|FNSTSW|FPATAN|" \
132 "FPREM|FPREM1|FPTAN|FRNDINT|FRSTOR|FSAVE|FSCALE|FSIN|FSINCOS|FSQRT|FST|" \
133 "FSTCW|FSTENV|FSTP|FSTSW|FSUB|FSUBP|FSUBR|FSUBRP|FTST|FUCOM|FUCOMI|" \
134 "FUCOMIP|FUCOMP|FUCOMPP|FWAIT|FXAM|FXCH|FXRSTOR|FXSAVE|FXTRACT|FYL2X|" \
135 "FYL2XP1|GF2P8AFFINEINVQB|GF2P8AFFINEQB|GF2P8MULB|HADDPD|HADDPS|HLT|" \
136 "HSUBPD|HSUBPS|IDIV|IMUL|IN|INC|INS|INSB|INSD|INSERTPS|INSW|INT|INT1|INT3|" \
137 "INTO|INVD|INVLPG|INVPCID|IRET|IRETD|JMP|Jcc|KADDB|KADDD|KADDQ|KADDW|" \
138 "KANDB|KANDD|KANDNB|KANDND|KANDNQ|KANDNW|KANDQ|KANDW|KMOVB|KMOVD|KMOVQ|" \
139 "KMOVW|KNOTB|KNOTD|KNOTQ|KNOTW|KORB|KORD|KORQ|KORTESTB|KORTESTD|KORTESTQ|" \
140 "KORTESTW|KORW|KSHIFTLB|KSHIFTLD|KSHIFTLQ|KSHIFTLW|KSHIFTRB|KSHIFTRD|" \
141 "KS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132PS|" \
183 "VFMADD132SD|VFMADD132SS|VFMADD213PD|VFMADD213PS|VFMADD213SD|VFMADD213SS|" \
184 "VFMADD231PD|VFMADD231PS|VFMADD231SD|VFMADD231SS|VFMADDSUB132PD|" \
185 "VFMADDSUB132PS|VFMADDSUB213PD|VFMADDSUB213PS|VFMADDSUB231PD|" \
186 "VFMADDSUB231PS|VFMSUB132PD|VFMSUB132PS|VFMSUB132SD|VFMSUB132SS|" \
187 "VFMSUB213PD|VFMSUB213PS|VFMSUB213SD|VFMSUB213SS|VFMSUB231PD|VFMSUB231PS|" \
188 "VFMSUB231SD|VFMSUB231SS|VFMSUBADD132PD|VFMSUBADD132PS|VFMSUBADD213PD|" \
189 "VFMSUBADD213PS|VFMSUBADD231PD|VFMSUBADD231PS|VFNMADD132PD|VFNMADD132PS|" \
190 "VFNMADD132SD|VFNMADD132SS|VFNMADD213PD|VFNMADD213PS|VFNMADD213SD|" \
191 "VFNMADD213SS|VFNMADD231PD|VFNMADD231PS|VFNMADD231SD|VFNMADD231SS|" \
192 "VFNMSUB132PD|VFNMSUB132PS|VFNMSUB132SD|VFNMSUB132SS|VFNMSUB213PD|" \
193 "VFNMSUB213PS|VFNMSUB213SD|VFNMSUB213SS|VFNMSUB231PD|VFNMSUB231PS|" \
194 "VFNMSUB231SD|VFNMSUB231SS|VFPCLASSPD|VFPCLASSPS|VFPCLASSSD|VFPCLASSSS|" \
195 "VGATHERDPD|VGATHERDPS|VGATHERQPD|VGATHERQPS|VGETEXPPD|VGETEXPPS|VGETEXPSD|" \
196 "VGETEXPSS|VGETMANTPD|VGETMANTPS|VGETMANTSD|VGETMANTSS|VINSERTF128|" \
197 "VINSERTF32x4|VINSERTF32x8|VINSERTF64x2|VINSERTF64x4|VINSERTI128|" \
198 "VINSERTI32x4|VINSERTI32x8|VINSERTI64x2|VINSERTI64x4|VMASKMOV|VMOVDQA32|" \
199 "VMOVDQA64|VMOVDQU16|VMOVDQU32|VMOVDQU64|VMOVDQU8|VPBLENDD|VPBLENDMB|" \
200 "VPBLENDMD|VPBLENDMQ|VPBLENDMW|VPBROADCAST|VPBROADCASTB|VPBROADCASTD|" \
201 "VPBROADCASTM|VPBROADCASTQ|VPBROADCASTW|VPCMPB|VPCMPD|VPCMPQ|VPCMPUB|" \
202 "VPCMPUD|VPCMPUQ|VPCMPUW|VPCMPW|VPCOMPRESSD|VPCOMPRESSQ|VPCONFLICTD|" \
203 "VPCONFLICTQ|VPERM2F128|VPERM2I128|VPERMB|VPERMD|VPERMI2B|VPERMI2D|" \
204 "VPERMI2PD|VPERMI2PS|VPERMI2Q|VPERMI2W|VPERMILPD|VPERMILPS|VPERMPD|VPERMPS|" \
205 "VPERMQ|VPERMT2B|VPERMT2D|VPERMT2PD|VPERMT2PS|VPERMT2Q|VPERMT2W|VPERMW|" \
206 "VPEXPANDD|VPEXPANDQ|VPGATHERDD|VPGATHERDQ|VPGATHERQD|VPGATHERQQ|VPLZCNTD|" \
207 "VPLZCNTQ|VPMADD52HUQ|VPMADD52LUQ|VPMASKMOV|VPMOVB2M|VPMOVD2M|VPMOVDB|" \
208 "VPMOVDW|VPMOVM2B|VPMOVM2D|VPMOVM2Q|VPMOVM2W|VPMOVQ2M|VPMOVQB|VPMOVQD|" \
209 "VPMOVQW|VPMOVSDB|VPMOVSDW|VPMOVSQB|VPMOVSQD|VPMOVSQW|VPMOVSWB|VPMOVUSDB|" \
210 "VPMOVUSDW|VPMOVUSQB|VPMOVUSQD|VPMOVUSQW|VPMOVUSWB|VPMOVW2M|VPMOVWB|" \
211 "VPMULTISHIFTQB|VPROLD|VPROLQ|VPROLVD|VPROLVQ|VPRORD|VPRORQ|VPRORVD|" \
212 "VPRORVQ|VPSCATTERDD|VPSCATTERDQ|VPSCATTERQD|VPSCATTERQQ|VPSLLVD|VPSLLVQ|" \
213 "VPSLLVW|VPSRAVD|VPSRAVQ|VPSRAVW|VPSRLVD|VPSRLVQ|VPSRLVW|VPTERNLOGD|" \
214 "VPTERNLOGQ|VPTESTMB|VPTESTMD|VPTESTMQ|VPTESTMW|VPTESTNMB|VPTESTNMD|" \
215 "VPTESTNMQ|VPTESTNMW|VRANGEPD|VRANGEPS|VRANGESD|VRANGESS|VRCP14PD|VRCP14PS|" \
216 "VRCP14SD|VRCP14SS|VREDUCEPD|VREDUCEPS|VREDUCESD|VREDUCESS|VRNDSCALEPD|" \
217 "VRNDSCALEPS|VRNDSCALESD|VRNDSCALESS|VRSQRT14PD|VRSQRT14PS|VRSQRT14SD|" \
218 "VRSQRT14SS|VSCALEFPD|VSCALEFPS|VSCALEFSD|VSCALEFSS|VSCATTERDPD|" \
219 "VSCATTERDPS|VSCATTERQPD|VSCATTERQPS|VSHUFF32x4|VSHUFF64x2|VSHUFI32x4|" \
220 "VSHUFI64x2|VTESTPD|VTESTPS|VZEROALL|VZEROUPPER|WAIT|WBINVD|WRFSBASE|" \
221 "WRGSBASE|WRMSR|WRPKRU|XABORT|XACQUIRE|XADD|XBEGIN|XCHG|XEND|XGETBV|XLAT|" \
222 "XLATB|XOR|XORPD|XORPS|XRELEASE|XRSTOR|XRSTORS|XSAVE|XSAVEC|XSAVEOPT|" \
223 "XSAVES|XSETBV|XTEST"
228 { TOKEN_TYPE::WhiteSpace, R
"(([ \t]+))" },
229 { TOKEN_TYPE::NewLine, R"((\n))" },
230 { TOKEN_TYPE::Comment, R"((;.*\n))" },
231 { TOKEN_TYPE::HexNumber, R"(([0-9][0-9a-f]*h))" FOLLOWED_BY(R"([\s\n\+\-\*\/,=!\]\(\)])") },
232 { TOKEN_TYPE::DecNumber, R"(([0-9]+))" FOLLOWED_BY(R"([\s\n\+\-\*\/,=!\]\(\)])") },
233 { TOKEN_TYPE::String, R"((\".*\"))" },
235 { TOKEN_TYPE::BraceOpen, R"((\())"},
236 { TOKEN_TYPE::BraceClose, R"((\)))"},
237 { TOKEN_TYPE::MemRefStart, R"((\[))"},
238 { TOKEN_TYPE::MemRefEnd, R"((\]))"},
239 { TOKEN_TYPE::Colon, R"((\:))"},
240 { TOKEN_TYPE::Operator, R"(([,\+\-\*\/\:]))"},
241 { TOKEN_TYPE::StringDef, R"((<.+>))" },
243 { TOKEN_TYPE::KW_include, R"((include))" FOLLOWED_BY(R"([\s])") },
244 { TOKEN_TYPE::KW_const, R"((\.const))" FOLLOWED_BY(R"([\s])") },
245 { TOKEN_TYPE::KW_code, R"((\.code))" FOLLOWED_BY(R"([\s])") },
246 { TOKEN_TYPE::KW_endprolog, R"((\.endprolog))" FOLLOWED_BY(R"([\s])") },
247 { TOKEN_TYPE::KW_ALIGN, R"((ALIGN))" FOLLOWED_BY(R"([\s])") },
248 { TOKEN_TYPE::KW_EXTERN, R"((EXTERN))" FOLLOWED_BY(R"([\s])") },
249 { TOKEN_TYPE::KW_EXTERN, R"((EXTRN))" FOLLOWED_BY(R"([\s])") },
250 { TOKEN_TYPE::KW_PUBLIC, R"((PUBLIC))" FOLLOWED_BY(R"([\s])") },
251 { TOKEN_TYPE::KW_ENDM, R"((ENDM))" FOLLOWED_BY(R"([\s\;])") },
252 { TOKEN_TYPE::KW_END, R"((END))" FOLLOWED_BY(R"([\s])") },
253 { TOKEN_TYPE::KW_if, R"((if))" FOLLOWED_BY(R"([\s])") },
254 { TOKEN_TYPE::KW_ifdef, R"((ifdef))" FOLLOWED_BY(R"([\s])")},
255 { TOKEN_TYPE::KW_ifndef, R"((ifndef))" FOLLOWED_BY(R"([\s])")},
256 { TOKEN_TYPE::KW_else, R"((else))" FOLLOWED_BY(R"([\s])")},
257 { TOKEN_TYPE::KW_endif, R"((endif))" FOLLOWED_BY(R"([\s])")},
259 { TOKEN_TYPE::KW_allocstack, R"((.allocstack))" FOLLOWED_BY(R"([\s])") },
260 { TOKEN_TYPE::KW_savereg, R"((.savereg))" FOLLOWED_BY(R"([\s])") },
261 { TOKEN_TYPE::KW_savexmm128, R"((.savexmm128))" FOLLOWED_BY(R"([\s])") },
263 { TOKEN_TYPE::KW_DB, R"((DB))" FOLLOWED_BY(R"([\s])") },
264 { TOKEN_TYPE::KW_DW, R"((DW))" FOLLOWED_BY(R"([\s])") },
265 { TOKEN_TYPE::KW_DD, R"((DD))" FOLLOWED_BY(R"([\s])") },
266 { TOKEN_TYPE::KW_DQ, R"((DQ))" FOLLOWED_BY(R"([\s])") },
267 { TOKEN_TYPE::KW_EQU, R"((EQU))" FOLLOWED_BY(R"([\s])") },
268 { TOKEN_TYPE::KW_TEXTEQU, R"((TEXTEQU))" FOLLOWED_BY(R"([\s])") },
269 { TOKEN_TYPE::KW_MACRO, R"((MACRO))" FOLLOWED_BY(R"([\s\;])") },
270 { TOKEN_TYPE::KW_PROC, R"((PROC))" FOLLOWED_BY(R"([\s\;])") },
271 { TOKEN_TYPE::KW_FRAME, R"((FRAME))" FOLLOWED_BY(R"([\s\;])") },
272 { TOKEN_TYPE::KW_ENDP, R"((ENDP))" FOLLOWED_BY(R"([\s\;])") },
273 { TOKEN_TYPE::KW_RECORD, R"((RECORD))" FOLLOWED_BY(R"([\s\;])") },
274 { TOKEN_TYPE::KW_MASK, R"((MASK))" FOLLOWED_BY(R"([\s\;])")},
275 { TOKEN_TYPE::KW_ERRDEF, R"((\.ERRDEF))" FOLLOWED_BY(R"([\s\;])")},
277 { TOKEN_TYPE::Filename, R"(([a-z_][a-z0-9_]*\.inc))" FOLLOWED_BY(R"([\s])") },
279 { TOKEN_TYPE::Reg8, R"((al|ah|bl|bh|cl|ch|dl|dh|sil|dil|bpl|spl|r8b|r9b|r10b|r11b|r12b|r13b|r14b|r15b))" FOLLOWED_BY(R"([\s\,])") },
280 { TOKEN_TYPE::Reg16, R"((ax|bx|cx|dx|si|di|bp|sp|r8w|r9w|r10w|r11w|r12w|r13w|r14w|r15w))" FOLLOWED_BY(R"([\s\,])") },
281 { TOKEN_TYPE::Reg32, R"((eax|ebx|ecx|edx|esi|edi|ebp|esp|r8d|r9d|r10d|r11d|r12d|r13d|r14d|r15d))" FOLLOWED_BY(R"([\s\,])") },
282 { TOKEN_TYPE::Reg64, R"((rax|rbx|rcx|rdx|rsi|rdi|rbp|rsp|r8|r9|r10|r11|r12|r13|r14|r15))" FOLLOWED_BY(R"([\s\,])") },
283 { TOKEN_TYPE::RegXmm, R"((xmm0|xmm1|xmm2|xmm3|xmm4|xmm5|xmm6|xmm7|xmm8|xmm9|xmm10|xmm11|xmm12|xmm13|xmm14|xmm15))" FOLLOWED_BY(R"([\s\,])") },
284 { TOKEN_TYPE::BYTE_PTR, R"((BYTE[\s]+PTR))" FOLLOWED_BY(R"([\s\[])") },
285 { TOKEN_TYPE::WORD_PTR, R"((WORD[\s]+PTR))" FOLLOWED_BY(R"([\s\[])") },
286 { TOKEN_TYPE::DWORD_PTR, R"((DWORD[\s]+PTR))" FOLLOWED_BY(R"([\s\[])") },
287 { TOKEN_TYPE::QWORD_PTR, R"((QWORD[\s]+PTR))" FOLLOWED_BY(R"([\s\[])") },
288 { TOKEN_TYPE::XMMWORD_PTR, R"((XMMWORD[\s]+PTR))" FOLLOWED_BY(R"([\s\[])") },
340 if (identifier.Name == tok.
str())
352 size_t sz =
a.size();
355 for (
unsigned int i = 0;
i < sz; ++
i)
364 if (tok.type() !=
type)
366 throw "Not white space after identifier!\n";
375 if (
type != TOKEN_TYPE::WhiteSpace)
377 throw "Not white space after identifier!\n";
386 if ((
type != TOKEN_TYPE::WhiteSpace) &&
387 (
type != TOKEN_TYPE::NewLine))
389 throw "Not white space after identifier!\n";
397 for (
string &
s :
list)
414 case TOKEN_TYPE::Comment:
418 case TOKEN_TYPE::DecNumber:
420 unsigned long long num = stoull(tok.
str(),
nullptr, 10);
425 case TOKEN_TYPE::HexNumber:
432 case TOKEN_TYPE::Identifier:
441 case TOKEN_TYPE::BYTE_PTR:
442 case TOKEN_TYPE::WORD_PTR:
443 case TOKEN_TYPE::DWORD_PTR:
444 case TOKEN_TYPE::QWORD_PTR:
445 case TOKEN_TYPE::XMMWORD_PTR:
448 case TOKEN_TYPE::Reg8:
449 case TOKEN_TYPE::Reg16:
450 case TOKEN_TYPE::Reg32:
451 case TOKEN_TYPE::Reg64:
452 case TOKEN_TYPE::RegXmm:
453 case TOKEN_TYPE::Instruction:
455 case TOKEN_TYPE::WhiteSpace:
456 case TOKEN_TYPE::NewLine:
457 case TOKEN_TYPE::Operator:
475 if ((tok.
type() == TOKEN_TYPE::NewLine) ||
476 (tok.
type() == TOKEN_TYPE::Comment))
493 case TOKEN_TYPE::NewLine:
494 case TOKEN_TYPE::Comment:
497 case TOKEN_TYPE::KW_MASK:
502 case TOKEN_TYPE::Instruction:
525 throw "Invalid expression";
529 case TOKEN_TYPE::Operator:
530 if (tok.
str() ==
",")
534 case TOKEN_TYPE::WhiteSpace:
535 case TOKEN_TYPE::BraceOpen:
536 case TOKEN_TYPE::BraceClose:
537 case TOKEN_TYPE::DecNumber:
538 case TOKEN_TYPE::HexNumber:
539 case TOKEN_TYPE::Identifier:
557 if ((tok.
type() == TOKEN_TYPE::DecNumber) ||
558 (tok.
type() == TOKEN_TYPE::HexNumber))
570 if (tok.
type() == TOKEN_TYPE::MemRefEnd)
580 throw "Failed to translate memory ref";
588 case TOKEN_TYPE::BYTE_PTR:
589 case TOKEN_TYPE::WORD_PTR:
590 case TOKEN_TYPE::DWORD_PTR:
591 case TOKEN_TYPE::QWORD_PTR:
592 case TOKEN_TYPE::XMMWORD_PTR:
596 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
607 case TOKEN_TYPE::MemRefStart:
610 case TOKEN_TYPE::NewLine:
611 case TOKEN_TYPE::Comment:
614 case TOKEN_TYPE::Operator:
615 if (tok.
str() ==
",")
619 case TOKEN_TYPE::Identifier:
641 const char* inst_list[] = {
642 "jmp",
"call",
"ja",
"jae",
"jb",
"jbe",
"jc",
"jcxz",
"je",
"jecxz",
"jg",
"jge",
643 "jl",
"jle",
"jna",
"jnae",
"jnb",
"jnbe",
"jnc",
"jne",
"jng",
"jnge",
"jnl",
"jnle",
644 "jno",
"jnp",
"jns",
"jnz",
"jo",
"jp",
"jpe",
"jpo",
"jrcxz",
"js",
"jz",
"loop",
"loope",
645 "loopne",
"loopnz",
"loopz"
648 for (
const char* inst : inst_list)
674 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
683 case TOKEN_TYPE::Comment:
684 case TOKEN_TYPE::NewLine:
688 case TOKEN_TYPE::WhiteSpace:
689 case TOKEN_TYPE::Operator:
707 case TOKEN_TYPE::DecNumber:
708 case TOKEN_TYPE::HexNumber:
709 case TOKEN_TYPE::String:
710 case TOKEN_TYPE::WhiteSpace:
714 throw "Failed to translate item";
726 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
732 if ((tokens[
index].
type() == TOKEN_TYPE::Comment) ||
733 (tokens[
index].
type() == TOKEN_TYPE::NewLine))
739 if ((tokens[
index].
type() != TOKEN_TYPE::Operator) ||
742 throw "Unexpected end of list";
746 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
752 throw "Failed to translate list";
761 string directive,
need, have =
"";
765 case TOKEN_TYPE::KW_DB:
769 case TOKEN_TYPE::KW_DW:
770 directive =
".short";
773 case TOKEN_TYPE::KW_DD:
777 case TOKEN_TYPE::KW_DQ:
801 else if (have !=
need)
816 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
822 if ((tokens[
index].
type() == TOKEN_TYPE::Comment) ||
823 (tokens[
index].
type() == TOKEN_TYPE::NewLine))
829 if ((tokens[
index].
type() != TOKEN_TYPE::Operator) ||
832 throw "Unexpected end of list";
837 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
843 throw "Failed to translate list";
860 unsigned int bits, bitpos = 0;
861 unsigned long long oldmask = 0,
mask = 0;
869 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
876 throw "Unexpected token";
879 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
885 if ((tok_bits.
type() != TOKEN_TYPE::DecNumber) &&
886 (tok_bits.
type() != TOKEN_TYPE::HexNumber))
888 throw "Unexpected token";
891 bits = stoi(tok_bits.
str(),
nullptr, 0);
893 printf(
"%s = %u\n", tok_member.
str().c_str(), bitpos);
895 oldmask = (1ULL << bitpos) - 1;
897 mask = (1ULL << bitpos) - 1 - oldmask;
898 printf(
"MASK_%s = 0x%llx\n", tok_member.
str().c_str(),
mask);
900 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
905 if ((tokens[
index].
type() == TOKEN_TYPE::NewLine) ||
906 (tokens[
index].
type() == TOKEN_TYPE::Comment))
913 throw "unexpected token";
917 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
922 if ((tokens[
index].
type() == TOKEN_TYPE::NewLine) ||
923 (tokens[
index].
type() == TOKEN_TYPE::Comment))
928 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
943 if (tok1.
type() == TOKEN_TYPE::Colon)
945 if (tok.
str() ==
"@@")
962 case TOKEN_TYPE::KW_MACRO:
963 throw "Cannot have a nested macro!";
965 case TOKEN_TYPE::KW_DB:
966 case TOKEN_TYPE::KW_DW:
967 case TOKEN_TYPE::KW_DD:
968 case TOKEN_TYPE::KW_DQ:
973 case TOKEN_TYPE::KW_EQU:
975 printf(
"#define %s ", tok.
str().c_str());
979 case TOKEN_TYPE::KW_TEXTEQU:
984 string textdef = tok4.
str();
990 case TOKEN_TYPE::KW_PROC:
996 if ((tokens[
index].
type() == TOKEN_TYPE::WhiteSpace) &&
997 (tokens[
index + 1].
type() == TOKEN_TYPE::KW_FRAME))
1000 printf(
"\n.seh_proc %s\n", tok.
str().c_str());
1002 printf(
"\n.cfi_startproc\n");
1010 case TOKEN_TYPE::KW_ENDP:
1012 printf(
".seh_endproc\n.endfunc");
1017 case TOKEN_TYPE::KW_RECORD:
1037 case TOKEN_TYPE::WhiteSpace:
1038 case TOKEN_TYPE::NewLine:
1039 case TOKEN_TYPE::Comment:
1042 case TOKEN_TYPE::Identifier:
1045 case TOKEN_TYPE::KW_ALIGN:
1049 case TOKEN_TYPE::KW_allocstack:
1053 case TOKEN_TYPE::KW_code:
1059 printf(
" .intel_syntax noprefix");
1063 case TOKEN_TYPE::KW_const:
1064 printf(
".section .rdata");
1068 case TOKEN_TYPE::KW_DB:
1069 case TOKEN_TYPE::KW_DW:
1070 case TOKEN_TYPE::KW_DD:
1071 case TOKEN_TYPE::KW_DQ:
1074 case TOKEN_TYPE::KW_END:
1076 return tokens.
size();
1078 case TOKEN_TYPE::KW_endprolog:
1079 printf(
".seh_endprologue");
1083 case TOKEN_TYPE::KW_EXTERN:
1092 case TOKEN_TYPE::KW_if:
1093 case TOKEN_TYPE::KW_ifdef:
1094 case TOKEN_TYPE::KW_ifndef:
1095 case TOKEN_TYPE::KW_else:
1096 case TOKEN_TYPE::KW_endif:
1101 case TOKEN_TYPE::KW_include:
1106 printf(
"#include \"%s.h\"", tok2.
str().c_str());
1111 case TOKEN_TYPE::KW_PUBLIC:
1115 case TOKEN_TYPE::KW_savereg:
1119 case TOKEN_TYPE::KW_savexmm128:
1123 case TOKEN_TYPE::Instruction:
1127 case TOKEN_TYPE::KW_ERRDEF:
1132 throw "failed to translate construct";
1136 if (tokens[
index].
type() == TOKEN_TYPE::WhiteSpace)
1143 if ((
end.type() != TOKEN_TYPE::Comment) &&
1144 (
end.type() != TOKEN_TYPE::NewLine))
1146 throw "unexpected tokens";
1166 case TOKEN_TYPE::NewLine:
1167 case TOKEN_TYPE::Comment:
1171 case TOKEN_TYPE::Identifier:
1177 case TOKEN_TYPE::WhiteSpace:
1178 case TOKEN_TYPE::Operator:
1192 case TOKEN_TYPE::KW_ENDM:
1201 throw "Failed to translate macro";
1215 if ((tokens[
index].
type() == TOKEN_TYPE::Identifier) &&
1216 (tokens[
index + 1].
type() == TOKEN_TYPE::WhiteSpace) &&
1217 (tokens[
index + 2].
type() == TOKEN_TYPE::KW_MACRO))
1236#if PROFILING_ENABLED
1264#if PROFILING_ENABLED
void add_mem_id(Token &tok)
size_t translate_list(TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_data_def(TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_construct(TokenList &tokens, size_t index, const vector< string > ¯o_params)
static void add_identifier(Token &tok, IDTYPE type)
size_t translate_item(TokenList &tokens, size_t index, const vector< string > ¯o_params)
vector< TOKEN_DEF > g_TokenList
void translate(TokenList &tokens)
size_t translate_token(TokenList &tokens, size_t index, const vector< string > ¯o_params)
Token get_ws_or_nl(Token &&tok)
static bool is_jmp_or_call(const Token &tok)
bool is_mem_id(Token &tok)
int fake_printf(const char *format,...)
size_t complete_line(TokenList &tokens, size_t index, const vector< string > ¯o_params)
unsigned int g_label_number
bool is_string_in_list(vector< string > list, string str)
size_t translate_expression(TokenList &tokens, size_t index, const vector< string > ¯o_params)
Token get_expected_token(Token &&tok, TOKEN_TYPE type)
vector< IDENTIFIER > g_identifiers
bool iequals(const string &a, const string &b)
Token get_ws(Token &&tok)
size_t translate_identifier_construct(TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_construct_one_param(string translated, TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_record(TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_macro(TokenList &tokens, size_t index)
size_t translate_instruction(TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_mem_ref(TokenList &tokens, size_t index, const vector< string > ¯o_params)
size_t translate_instruction_param(TokenList &tokens, size_t index, const vector< string > ¯o_params)
_Self substr(size_type __pos=0, size_type __n=npos) const
const _CharT * c_str() const
GLuint GLuint GLsizei GLenum type
GLboolean GLboolean GLboolean b
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static unsigned int number
static UINT PSTR DWORD UINT * need
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))