133 - Assembly Access
Inline Assembly Access to External Variables, Functions and Libraries:
-
You can access Solidity variables and other identifiers by using their name.
-
Local variables of value type are directly usable in inline assembly
-
Local variables that refer to memory/calldata evaluate to the address of the variable in memory/calldata and not the value itself
-
For local storage variables or state variables, a single Yul identifier is not sufficient, since they do not necessarily occupy a single full storage slot. Therefore, their “address” is composed of a slot and a byte-offset inside that slot. To retrieve the slot pointed to by the variable x, you use x.slot, and to retrieve the byte-offset you use x.offset. Using x itself will result in an error.
-
Local Solidity variables are available for assignments
-
Assignments are possible to assembly-local variables and to function-local variables. Take care that when you assign to variables that point to memory or storage, you will only change the pointer and not the data.
-
You can assign to the .slot part of a local storage variable pointer. For these (structs, arrays or mappings), the .offset part is always zero. It is not possible to assign to the .slot or .offset part of a state variable, though
- External Variables, Functions & Libraries
- Local Vars -> Value Type
- Value vs. Addr
- Storage Vars -> Slots
*.slot
&*.offset
- Assignments Possible
- Rules & Restrictions