zink/asm/ext.rs
1//! Assembly FFI.
2
3use crate::primitives::U256;
4
5#[link(wasm_import_module = "ext")]
6#[allow(improper_ctypes)]
7extern "C" {
8 /// Addition operation for addresses
9 pub fn u256_add(this: U256, other: U256) -> U256;
10
11 /// Subtraction operation for addresses
12 pub fn u256_sub(this: U256, other: U256) -> U256;
13
14 /// Division operation for addresses
15 pub fn u256_div(this: U256, other: U256) -> U256;
16
17 /// Less than operation for addresses
18 pub fn u256_lt(this: U256, other: U256) -> bool;
19
20 /// Returns the maximum U256 value
21 pub fn u256_max() -> U256;
22
23 /// Addmod operation for addresses
24 pub fn u256_addmod(this: U256, other: U256, modulus: U256) -> U256;
25
26 /// Mulmod operation for addresses
27 pub fn u256_mulmod(this: U256, other: U256, modulus: U256) -> U256;
28
29 /// Push a 8-bit signed integer to the stack.
30 pub fn push_i8(val: i8);
31
32 /// Push a 8-bit unsigned integer to the stack.
33 pub fn push_u8(val: u8);
34
35 /// Push a 16-bit signed integer to the stack.
36 pub fn push_i16(val: i16);
37
38 /// Push a 16-bit unsigned integer to the stack.
39 pub fn push_u16(val: u16);
40
41 /// Push a 32-bit signed integer to the stack.
42 pub fn push_i32(val: i32);
43
44 /// Push a 32-bit unsigned integer to the stack.
45 pub fn push_u32(val: u32);
46
47 /// Push a 64-bit signed integer to the stack.
48 pub fn push_i64(val: i64);
49
50 /// Push a 64-bit unsigned integer to the stack.
51 pub fn push_u64(val: u64);
52
53 /// Emit opcode ADDMOD
54 pub fn addmod_i8(a: i8, b: i8, n: i8) -> i8;
55
56 /// Emit opcode ADDMOD
57 pub fn mulmod_i8(a: i8, b: i8, n: i8) -> i8;
58
59 /// Emit opcode ADDMOD
60 pub fn addmod_i16(a: i16, b: i16, n: i16) -> i16;
61
62 /// Emit opcode ADDMOD
63 pub fn mulmod_i16(a: i16, b: i16, n: i16) -> i16;
64
65 /// Emit opcode ADDMOD
66 pub fn addmod_i32(a: i32, b: i32, n: i32) -> i32;
67
68 /// Emit opcode ADDMOD
69 pub fn mulmod_i32(a: i32, b: i32, n: i32) -> i32;
70
71 /// Emit opcode ADDMOD
72 pub fn addmod_i64(a: i64, b: i64, n: i64) -> i64;
73
74 /// Emit opcode ADDMOD
75 pub fn mulmod_i64(a: i64, b: i64, n: i64) -> i64;
76
77 /// Emit opcode ADDMOD
78 pub fn addmod_u8(a: u8, b: u8, n: u8) -> u8;
79
80 /// Emit opcode ADDMOD
81 pub fn mulmod_u8(a: u8, b: u8, n: u8) -> u8;
82
83 /// Emit opcode ADDMOD
84 pub fn addmod_u16(a: u16, b: u16, n: u16) -> u16;
85
86 /// Emit opcode ADDMOD
87 pub fn mulmod_u16(a: u16, b: u16, n: u16) -> u16;
88
89 /// Emit opcode ADDMOD
90 pub fn addmod_u32(a: u32, b: u32, n: u32) -> u32;
91
92 /// Emit opcode ADDMOD
93 pub fn mulmod_u32(a: u32, b: u32, n: u32) -> u32;
94
95 /// Emit opcode ADDMOD
96 pub fn addmod_u64(a: u64, b: u64, n: u64) -> u64;
97
98 /// Emit opcode ADDMOD
99 pub fn mulmod_u64(a: u64, b: u64, n: u64) -> u64;
100
101 /// Revert with message in 32 bytes
102 pub fn revert1(message: &'static str);
103
104 /// Revert with message in 64 bytes
105 pub fn revert2(message: &'static str);
106
107 /// Revert with message in 96 bytes
108 pub fn revert3(message: &'static str);
109
110 /// Revert with message in 128 bytes
111 pub fn revert4(message: &'static str);
112
113 /// Load a 8-bit signed integer from the storage.
114 pub fn sload_i8() -> i8;
115
116 /// Load a 8-bit unsigned integer from the storage.
117 pub fn sload_u8() -> u8;
118
119 /// Load a 16-bit signed integer from the storage.
120 pub fn sload_i16() -> i16;
121
122 /// Load a 16-bit unsigned integer from the storage.
123 pub fn sload_u16() -> u16;
124
125 /// Load a 32-bit signed integer from the storage.
126 pub fn sload_i32() -> i32;
127
128 /// Load a 32-bit unsigned integer from the storage.
129 pub fn sload_u32() -> u32;
130
131 /// Load a 64-bit signed integer from the storage.
132 pub fn sload_i64() -> i64;
133
134 /// Load a 64-bit unsigned integer from the storage.
135 pub fn sload_u64() -> u64;
136
137 /// Load a 8-bit signed integer from the transient storage.
138 pub fn tload_i8() -> i8;
139
140 /// Load a 8-bit unsigned integer from the transient storage.
141 pub fn tload_u8() -> u8;
142
143 /// Load a 16-bit signed integer from the transient storage.
144 pub fn tload_i16() -> i16;
145
146 /// Load a 16-bit unsigned integer from the transient storage.
147 pub fn tload_u16() -> u16;
148
149 /// Load a 32-bit signed integer from the transient storage.
150 pub fn tload_i32() -> i32;
151
152 /// Load a 32-bit unsigned integer from the transient storage.
153 pub fn tload_u32() -> u32;
154
155 /// Load a 64-bit signed integer from the transient storage.
156 pub fn tload_i64() -> i64;
157
158 /// Load a 64-bit unsigned integer from the transient storage.
159 pub fn tload_u64() -> u64;
160
161 /// Store a 8-bit signed integer to the transient storage.
162 pub fn tstore_i8(val: i8);
163
164 /// Store a 8-bit unsigned integer to the transient storage.
165 pub fn tstore_u8(val: u8);
166
167 /// Store a 16-bit signed integer to the transient storage.
168 pub fn tstore_i16(val: i16);
169
170 /// Store a 16-bit unsigned integer to the transient storage.
171 pub fn tstore_u16(val: u16);
172
173 /// Store a 32-bit signed integer to the transient storage.
174 pub fn tstore_i32(val: i32);
175
176 /// Store a 32-bit unsigned integer to the transient storage.
177 pub fn tstore_u32(val: u32);
178
179 /// Store a 64-bit signed integer to the transient storage.
180 pub fn tstore_i64(val: i64);
181
182 /// Store a 64-bit unsigned integer to the transient storage.
183 pub fn tstore_u64(val: u64);
184}