diff options
author | Gav Wood <i@gavwood.com> | 2014-06-10 23:49:54 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2014-06-10 23:49:54 +0800 |
commit | 5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201 (patch) | |
tree | 5b3999034664054119596dab8e4ae9b6d3f99cd4 | |
parent | bbc7bd19e529cd1a64708b45b8f8193b60d5fb59 (diff) | |
download | dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.tar dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.tar.gz dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.tar.bz2 dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.tar.lz dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.tar.xz dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.tar.zst dexon-solidity-5ea7efd593aa4576df6ac0c2b3c334e0f4ec6201.zip |
Fix signed instructions.
-rw-r--r-- | Assembly.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Assembly.cpp b/Assembly.cpp index 4b7d9834..0de16982 100644 --- a/Assembly.cpp +++ b/Assembly.cpp @@ -195,14 +195,14 @@ void Assembly::optimise() { { Instruction::SUB, [](u256 a, u256 b)->u256{return a - b;} }, { Instruction::DIV, [](u256 a, u256 b)->u256{return a / b;} }, - { Instruction::SDIV, [](u256 a, u256 b)->u256{u256 r; (s256&)r = (s256&)a / (s256&)b; return r;} }, + { Instruction::SDIV, [](u256 a, u256 b)->u256{return s2u(u2s(a) / u2s(b));} }, { Instruction::MOD, [](u256 a, u256 b)->u256{return a % b;} }, - { Instruction::SMOD, [](u256 a, u256 b)->u256{u256 r; (s256&)r = (s256&)a % (s256&)b; return r;} }, + { Instruction::SMOD, [](u256 a, u256 b)->u256{return s2u(u2s(a) % u2s(b));} }, { Instruction::EXP, [](u256 a, u256 b)->u256{return boost::multiprecision::pow(a, (unsigned)b);} }, { Instruction::LT, [](u256 a, u256 b)->u256{return a < b ? 1 : 0;} }, { Instruction::GT, [](u256 a, u256 b)->u256{return a > b ? 1 : 0;} }, - { Instruction::SLT, [](u256 a, u256 b)->u256{return *(s256*)&a < *(s256*)&b ? 1 : 0;} }, - { Instruction::SGT, [](u256 a, u256 b)->u256{return *(s256*)&a > *(s256*)&b ? 1 : 0;} }, + { Instruction::SLT, [](u256 a, u256 b)->u256{return u2s(a) < u2s(b) ? 1 : 0;} }, + { Instruction::SGT, [](u256 a, u256 b)->u256{return u2s(a) > u2s(b) ? 1 : 0;} }, { Instruction::EQ, [](u256 a, u256 b)->u256{return a == b ? 1 : 0;} }, }; map<Instruction, function<u256(u256, u256)>> c_associative = |