1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.