Skip to content

Instantly share code, notes, and snippets.

@Nekotekina
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nekotekina/0fd8e112b5b71a043f0c to your computer and use it in GitHub Desktop.
Save Nekotekina/0fd8e112b5b71a043f0c to your computer and use it in GitHub Desktop.
CgBinaryDisasm::FormatDisAsm attempt
std::string CgBinaryDisasm::FormatDisAsm(const std::string& code)
{
const std::pair<std::string, std::function<std::string()>> repl_list[] =
{
{ "$$", [this]{ return "$"; } }, // may require std::string("$")
{ "$0", [this]{ return GetSrcDisAsm<SRC0>(src0); } },
{ "$1", [this]{ return GetSrcDisAsm<SRC1>(src1); } },
{ "$2", [this]{ return GetSrcDisAsm<SRC2>(src2); } },
{ "$t", [this]{ return AddTexDisAsm(); } },
{ "$m", [this]{ return GetMask(); } },
{ "$cond", [this]{ return GetCondDisAsm(); } },
{ "$c", [this]{ return AddConstDisAsm(); } },
};
return fmt::replace_all(code, repl_list);
}
std::string CgBinaryDisasm::FormatDisasm(const std::string& code)
{
const std::pair<std::string, std::function<std::string()>> repl_list[] =
{
{ "$$", [this]{ return "$"; } }, // may require std::string("$")
{ "$0", [this]{ return GetSRCDisasm(0); } },
{ "$1", [this]{ return GetSRCDisasm(1); } },
{ "$2", [this]{ return GetSRCDisasm(2); } },
{ "$s", [this]{ return GetSRCDisasm(2); } },
{ "$am", [this]{ return AddAddrMaskDisasm(); } },
{ "$a", [this]{ return AddAddrRegDisasm(); } },
{ "$t", [this]{ return GetTexDisasm(); } },
{ "$fa", [this]{ return std::to_string(GetAddrDisasm()); } },
{ "$ifcond ", [this]
{
std::string cond = GetCondDisasm();
if (cond == "true") cond.clear();
return cond;
}
},
{ "$cond", [this]{ return GetCondDisasm(); } },
};
return fmt::replace_all(code, repl_list);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment