static std::string help_string = colors(R"( usage: fxos<> [library<>|info<>|disasm<>|analyze<>] fxos is a reverse-engineering tool that disassembles and analyzes SuperH programs and OS dumps for CASIO calculators of the fx-9860G and fx-CG 50 families, using an editable database of platform, syscall, and OS knowledge. General options: -3<>, --sh3<> Assume SH3 OS and platform (default: SH4) -4<>, --sh4<> Assume SH4 OS and platform (default: SH4) -v<>, --verbose<> Print logs about what's happening fxos library<> [-t<>] [-a<>] Prints out the contents of the library. If an option is set, the results are printed in a simple easily-parsable form without header. Selectors: -t<>, --targets<> Print all targets -a<>, --asm<> Print all assembler instruction sets fxos info<> <

TARGET<>> Print adentification and basic information about an OS image: version, platform, date, checksums... Target specification: <

TARGET-NAME<>> Named target in library (eg. "fx@3.10") -f<> <

FILE<>> Arbitrary file which is loaded as ROM fxos disasm<> <

TARGET<>> <

LOCATION<>> [options...] Disassemble and annotate code with relative address targets, syscalls, control flow, propagated constants and hints about memory structure. Location specifiers: <

ADDRESS<>> Start disassembling at this address (hexa) <

ADDRESS<>>:<

LEN<>> Disassemble exactly the specified region.

len<> is an hexadecimal number optionally followed by k, M, or G. %<

SYSCALL-ID<>> Start disassembling at this syscall's address (hexa) <

SYMBOL<>> Disassemble this library symbol (typically syscall name). A name which is valid hexadecimal is treated as

ADDRESS<>. Disassembly options: -p<> <

PASSES<>> Execute the specified comma-separated list of passes Available passes: cfg Build the control flow graph (always required) pcrel Resolve PC-relative references as their target address cstprop Propagate constants by abstract interpretation syscall Annotate code with reverse syscalls The default sequence of passes is cfg,pcrel,cstprop,syscall<>. When disassembling a function (ie. no size specified on the command-line), the cfg pass is always executed to obtain the code of the function. )"+1); int main_disassembly(int argc, char **argv) { std::vector passes { "cfg", "pcrel", "constprop", "syscall", "print" }; if(passes.back() != "print") passes.push_back("print"); try { int rc = disassembly(lib, space, ref, passes); if(log_getminlevel() <= LEVEL_LOG) malloc_stats(); return rc; } catch(LangError &e) { log(ERR "%08x: %s", e.addr(), e.what()); return 1; } catch(AddressError &e) { log(ERR "%08x[%d]: %s", e.addr(), e.size(), e.what()); return 1; } }