From 57bb9c2f7afba9f5dfbcc3d3e09eb5a5fcc31160 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 25 Jul 2013 22:29:59 -0500 Subject: [PATCH] Better disassembly of FLOP instructions. - Annotate FLOP instructions with the name of the floating point operation indicated by the C field. --- src/zscript/vmdisasm.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/zscript/vmdisasm.cpp b/src/zscript/vmdisasm.cpp index d2e87956d..3cfcd821d 100644 --- a/src/zscript/vmdisasm.cpp +++ b/src/zscript/vmdisasm.cpp @@ -97,6 +97,27 @@ const VMOpInfo OpInfo[NUM_OPS] = #include "vmops.h" }; +static const char *const FlopNames[] = +{ + "abs", + "neg", + "acos", + "asin", + "atan", + "cos", + "cosh", + "exp", + "log", + "log10", + "sin", + "sinh", + "tan", + "tanh", + "sqrt", + "ceil", + "floor" +}; + static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const VMScriptFunction *func); static int printf_wrapper(FILE *f, const char *fmt, ...) @@ -263,6 +284,14 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction } break; + case OP_FLOP: + col = printf_wrapper(out, "f%d,f%d,%d", code[i].a, code[i].b, code[i].c); + if (code[i].c < countof(FlopNames)) + { + col +=printf_wrapper(out, " [%s]", FlopNames[code[i].c]); + } + break; + default: if ((mode & MODE_BCTYPE) == MODE_BCCAST) {