-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinlineLoop.sol
More file actions
36 lines (27 loc) · 746 Bytes
/
inlineLoop.sol
File metadata and controls
36 lines (27 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
pragma solidity ^0.4.18;
contract Assembly {
function nativeLoops() public returns (uint _r ) {
for (uint i = 0; i<10; i++){
_r++;
}
}
function asemblysmLoops() public returns (uint _r) {
assembly {
let i := 10
loop:
i := add(i,1)
_r := add(_r,1)
jumpi(loop, lt(i,10))
}
}
function nativeConditional(uint _v ) public returns (uint ){
if (5== _v){
return 55;
} else if( 6 == _v){
return 66;
}
return 11;
}
}
//lt = 1 if a is less then b, 0 otherwise
//jumpi(label, condition) – jump to label if condition is nonzero