diff --git a/toolbox/sane.cpp b/toolbox/sane.cpp index f45f524..8d7e5cf 100644 --- a/toolbox/sane.cpp +++ b/toolbox/sane.cpp @@ -238,7 +238,7 @@ namespace SANE } - template + template uint16_t fadd(const char *name) { // faddi, etc. @@ -251,8 +251,8 @@ namespace SANE Log(" %s(%08x, %08x, %04x)\n", name, src, dest, op); - SRCTYPE s = readnum(src); - extended d = readnum(dest); + SrcType s = readnum(src); + DestType d = readnum(dest); if (ToolBox::Trace) { @@ -263,7 +263,32 @@ namespace SANE d = d + s; - writenum((extended)d, dest); + writenum(d, dest); + return 0; + } + + template + uint16_t fconvert(const char *name) + { + // type conversion. + uint16_t op; + uint32_t dest; + uint32_t src; + + StackFrame<10>(src, dest, op); + + Log(" %s(%08x, %08x, %04x)\n", name, src, dest, op); + + SrcType s = readnum(src); + + if (ToolBox::Trace) + { + std::string tmp1 = std::to_string(s); + Log(" %s\n", tmp1.c_str()); + } + + writenum((DestType)s, dest); + return 0; } @@ -280,17 +305,57 @@ namespace SANE if (op == 0x0006) return fdivx(); if (op == 0x000b) return fx2dec(); - if (op == 0x280e) return fl2x(); if (op == 0x0004) return fmulx(); switch(op) { + // fadd... + case 0x0000: // faddx + return fadd("FADDX"); + break; case 0x2000: // faddi return fadd("FADDI"); break; + // conversion + case 0x000e: // 2 versions for completeness. + case 0x0010: + return fconvert("FX2X"); + break; + + case 0x0810: + return fconvert("FX2D"); + break; + + case 0x1010: + return fconvert("FX2S"); + break; + + // 0x3010 - x to comp + case 0x2010: + return fconvert("FX2I"); + break; + + case 0x2810: + return fconvert("FX2L"); + break; + + case 0x080e: + return fconvert("FD2X"); + break; + case 0x100e: + return fconvert("FS2X"); + break; + // 0x300e - comp to x + case 0x200e: + return fconvert("FI2X"); + break; + case 0x280e: + return fconvert("FL2X"); + break; + }