Basic Operations

Math Operations

function add(uint x, uint y) external pure returns (uint256) {
        uint ret; 
        assembly {
            ret := add(x,y)
        }
        return ret; 
    }

    function subtract(uint x, uint y) external pure returns (uint256) {
        uint ret; 
        assembly {
            ret := sub(x,y)
        }
        return ret; 
    }

    function multiply(uint x, uint y) external pure returns (uint256) {
        uint ret; 
        assembly {
            ret := mul(x,y)
        }
        return ret; 
    }

		// Note: division rounds down 
    function divide(uint x, uint y) external pure returns (uint256) {
        uint ret; 
        assembly {
            ret := div(x,y)
        }
        return ret; 
   } 

For Loops

  • There are no else statements in Yul

Comparisons

Last updated