# Learn EVM Opcodes IV

We are continuing to progress in opcode business. In this lesson you will learn many new opcodes. These are MOD, EXP, LT,GT, EQ, ISZERO, SHL,SHR and BYTE

## MOD Opcode

It gives the remaining value in the division operation on the stack. First we enter the value **2** and then the value **7**. With the help of the **MOD** opcode, we learn the result of the 7%2 operation.

## ADDMOD Opcode

It is an opcode used with 3 values. The first and second values are summed and the mode of the total result is taken according to the third value.

Like (10+12)%7

## MULMOD Opcode

It is an opcode used with 3 values. The first and second values are multiplied and the mode of the total result is taken according to the third value.

Like (10+12)%7

## EXP Opcode

The exponential function is one of the most important functions in mathematics. We can use function thanks to the EXP opcode.

The **7² (7** to the second power) operation was performed and the result was represented on the stack as hexadecimal(**31**).

## LT Opcode

Returns **1** if the **last value on the stack is less than the previous value**, 0 otherwise.

PUSH1 5

PUSH1 4

LT

## GT Opcode

Returns **1** if the **last value on the stack is more than the previous value**, 0 otherwise.

## EQ Opcode

Returns 1 if the last value on the stack is equal to the previous value, 0 otherwise.

## ISZERO Opcode

Returns 1 if the last value on the stack is equal to 0, 0 otherwise.

## BYTE Opcode

Consider the data on the stack as an **array**. With this opcode, we can **get data from any point of the array**.

We wrote 32 byte sized value.

This is: 0x**CC**FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDD*EE*

The **first byte** of this data (you must call it 0) is CC.

The **last byte** of this data (you must call it 31) is EE.

We called byte 27. in this example. This is **AA**.

Would you like to read more ? Let’s get more practice.

PUSH2 0xCCFF

PUSH1 **30**

BYTE

We wrote a 2 byte sized value : 0xCCFF

Let’s ask it to return whatever is in the **30th byte** on this data.

The answer is **CC**.

Why **CC**, because values are written starting from the far right of each 32 byte slot.

It’s like this;

**0x000000000000000000000000000000000000000000000000000000000000 CCFF**

## SHL Opcode

We use it to shift the value to the left in “**Bits**”.

We wrote 32 byte sized value.

0xCCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDDEE

When we shift this data **4 BITS** to the left, the first letter “**C**” representing the **first 4 bits** *disappears* and is replaced by “**0**” at **the end (right)** of the data.

We need to understand this opcode.

We wrote 32 byte sized value.

0xCCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDDEE

When we shift this data 8** BITS** to the left, the first two letter “**CC**” representing the **first 8 bits** *disappears* and is replaced by “**00**” at **the end (right)** of the data.

## SHR Opcode

We use it to shift the value to the right in “**Bits**”.

We wrote 32 byte sized value.

0xCCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDDEE

When we shift this data **4 BITS** to the right, the last letter “**E**” representing the **last 4 bits** *disappears* and is replaced by “**0**” at **the start (left)** of the data.

You can’t see “**0**” in the start (left) of the data but there is “**0**” in the start.

We wrote 32 byte sized value.

0xCCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDDEE

When we shift this data 8** BITS** to the right, the last two letters “**EE**” representing the **last 8 bits** *disappears* and is replaced by “**00**” at **the start (left)** of the data.