Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
shift opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
gcolvin authored and axic committed Oct 3, 2017
1 parent 81ade70 commit 2021c21
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions libevm/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,13 @@ void VM::interpretCases()
{
ON_OP();
updateIOGas();

// boost insists shift argument must be built-in int type
const uint64_t shift = 0x100000000;
while (m_SP[0] > shift)
if (m_SP[0] >= 256)
m_SPP[0] = 0;
else
{
m_SP[1] <<= shift;
m_SP[0] -= shift;
m_SPP[0] = m_SP[1] << uint64_t(m_SP[0]);
}
m_SPP[0] = m_SP[1] << uint64_t(m_SP[0]);
}
NEXT

Expand All @@ -643,14 +641,12 @@ void VM::interpretCases()
ON_OP();
updateIOGas();

// boost insists shift argument must be built-in int type
const uint64_t shift = 0x100000000;
while (m_SP[0] > shift)
if (m_SP[0] >= 256)
m_SPP[0] = 0;
else
{
m_SP[1] >>= shift;
m_SP[0] -= shift;
m_SPP[0] = m_SP[1] >> uint64_t(m_SP[0]);
}
m_SPP[0] = m_SP[1] >> uint64_t(m_SP[0]);
}
NEXT

Expand All @@ -659,18 +655,16 @@ void VM::interpretCases()
ON_OP();
updateIOGas();

throwBadInstruction();

// boost insists shift argument must be built-in int type
const uint64_t shift = 0x100000000;
s256 temp = m_SP[1];
while (m_SP[0] > shift)
s256 shiftee = m_SP[1];
if (m_SP[0] >= 256)
{
if (shiftee < 0)
m_SPP[0] = u256(-1);
}
else
{
temp >>= shift;
m_SP[0] -= shift;
m_SPP[0] = u256(shiftee >> uint64_t(m_SP[0]));
}
temp >>= uint64_t(m_SP[0]);;
m_SPP[0] = u256(temp);
}
NEXT
#endif
Expand Down

0 comments on commit 2021c21

Please sign in to comment.