2

I am trying to use a conditional (like an if statement) in assembly. The only assembly reference site I have ever been able to find says the opcode JUMPI is the way to do this.

Using solc 0.7.0, the latest version.

I wasn't sure how to specify the destination parameter for JUMPI, so I just put the word destination in there as a placeholder to test a compilation.

assembly
{
    jumpi (destination, eq (b_test, 1))
    mstore (t_byte, 1)
}

It didn't recognize the JUMPI command.

Error: Function not found.
     |
 165 |          jumpi (destination, eq (b_test, 1))
     |          ^^^^^

How can I implement conditional assembly code using solc 0.7.0?

Also, if anyone knows of any better assembly reference sites, I would be interested in knowing about them.

Zephyrus
  • 350
  • 3
  • 11

1 Answers1

0

you can use if statements like this:

if eq(1, 1) { ... } // true
if eq(1, 2) { ... } // false
davidhass
  • 121
  • 4