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

Commit

Permalink
Implement shift opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Apr 23, 2017
1 parent 391e553 commit 648cced
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions libevm/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,47 @@ void VM::interpretCases()
}
NEXT

#ifdef EVM_USE_BITSHIFT
CASE(SHL)
{
ON_OP();
updateIOGas();

/// TODO: confirm shift >= 256 results in 0
m_SPP[0] = m_SP[0] << m_SP[1];
}
NEXT

CASE(SHR)
{
ON_OP();
updateIOGas();

/// TODO: confirm shift >= 256 results in 0
m_SPP[0] = m_SP[0] >> m_SP[1];
}
NEXT

CASE(SAR)
{
ON_OP();
updateIOGas();

s256 value = u2s(m_SP[0]);
u256 shift = m_SP[1];
if (shift >= 256)
{
if (value >= 0)
m_SPP[0] = 0;
else
m_SPP[0] = s2u(-1);
}
else
m_SPP[0] = s2u(divWorkaround(value, exp256(2, shift)));
}
NEXT
#endif

CASE(ADDMOD)
{
ON_OP();
Expand Down

0 comments on commit 648cced

Please sign in to comment.