Skip to content

Commit 593d767

Browse files
committed
Multiply and NonPayable
1 parent 37cabe1 commit 593d767

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

src/Multiply.huff

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,16 @@
3333

3434
multiplication:
3535
// Copy first argument in memory
36-
0x20
37-
0x04
38-
0x00
39-
calldatacopy
40-
41-
// Copy second argument in memory
42-
0x20
43-
0x24
44-
0x20
45-
calldatacopy
46-
47-
// load both argument a and check != 0
48-
0x00
49-
mload
36+
0x04 calldataload
5037
dup1
51-
0x00
52-
eq
38+
iszero
5339
zero_case
5440
jumpi
55-
56-
// load both argument b and check != 0
57-
0x20
58-
mload
41+
42+
// Copy second argument in memory
43+
0x24 calldataload
5944
dup1
60-
0x00
61-
eq
45+
iszero
6246
zero_case
6347
jumpi
6448

@@ -68,14 +52,12 @@
6852

6953
// load first argument (a) and divide result by it
7054
// c / a
71-
0x00
72-
mload
55+
0x04 calldataload
7356
swap1
7457
div
7558

7659
// b == c / a ?
77-
0x20
78-
mload
60+
0x24 calldataload
7961
eq
8062

8163
end

src/NonPayable.huff

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@
99
*/
1010

1111
#define macro MAIN() = takes(0) returns(0) {
12-
12+
0x00
13+
0x00
14+
callvalue
15+
iszero
16+
novalue jumpi
17+
revert
18+
novalue:
19+
return
1320
}

0 commit comments

Comments
 (0)