Template Class bitwise_operations#

Class Documentation#

template<class params>
class bitwise_operations#

The bitwise operations class. Contains the next operations 10s: Bitwise Logic Operations:

  • AND

  • OR

  • XOR

  • NOT

  • BYTE

  • SHL

  • SHR

  • SAR

Public Types

typedef arith_env_t<params> arith_t#

The arithmetical environment used by the arbitrary length integer library.

typedef arith_t::bn_t bn_t#

The arbitrary length integer type.

typedef stack_t<params> stack_t#

The stackk class.

Public Static Functions

static inline __host__ __device__ __forceinline__ void operation_AND (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The AND operation implementation. Takes two values from the stack, performs a bitwise AND operation and pushes the result back to the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_OR (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The OR operation implementation. Takes two values from the stack, performs a bitwise OR operation and pushes the result back to the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_XOR (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The XOR operation implementation. Takes two values from the stack, performs a bitwise XOR operation and pushes the result back to the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_NOT (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The NOT operation implementation. Takes a value from the stack, performs a bitwise NOT operation and pushes the result back to the stack. Similar operation with XOR with only ones.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[out] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_BYTE (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The BYTE operation implementation. Takes two values from the stack. The first value is the index of the byte to be extracted from the second value. The operation pushes the byte back to the stack. If the index is out of range, the operation pushes 0 to the stack. The most significat byte has index 0.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[out] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_SHL (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The SHL operation implementation. Takes two values from the stack. The first value is the number of bits to shift the second value to the left. The operation pushes the result back to the stack. If the number of bits is out of range, the operation pushes 0 to the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[out] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_SHR (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The SHR operation implementation. Takes two values from the stack. The first value is the number of bits to shift the second value to the right. The operation pushes the result back to the stack. If the number of bits is out of range, the operation pushes 0 to the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[out] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_SAR (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The SAR operation implementation. Takes two values from the stack. The first value is the number of bits to arithmetic shift the second value to the right. The operation pushes the result back to the stack. If the number of bits is out of range, the operations arithmetic shift with the maximum number of bits. The first value is considered unsigned and the second value is considered signed.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[out] The program counter.

  • stack[inout] The stack.