Description
When writing ASM blocks, developers are repeatedly running into a trap caused by the fact that aggregates and b256
and u256
values can be passed, apparently "by value" to ASM blocks, whereas what is actually passed is their memory address sonverted to u64
.
E.g., in this example, it looks like we are taking an 0th root of 0x64u256
. But what is actually passed to the ASM block is the address of the 0x64u256
instance in memory converted to u64.
mroodoes not operate on
u256but will accept the
u64` value.
asm(r1: 0x64u256, r2: 0x00u256, r3) {
mroo r3 r1 r2;
r3: u256
};
In the past, we got several questions on apparently correct code not working, and the reason was always the deceiving passing of values, where actually addresses are passed.
The proposal is to forbid passing aggregates and u256
and b256
to ASM blocks directly, but to force developers to take their addresses explicitly and pass them.
Rust follows the same approach.