aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-04-26 23:47:48 +0800
committerGitHub <noreply@github.com>2017-04-26 23:47:48 +0800
commit2c1fb46bc341d9e44074af23cd4eadd3a9f732c5 (patch)
tree58fba734d5ecf3330e8a62154ffa994bab8c551b /docs
parentc02bcaea043032107dd6343e5c68cc948a6a88c2 (diff)
parent2002447b10c23b5769f11f74c51e9a19c59241a3 (diff)
downloaddexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.tar
dexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.tar.gz
dexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.tar.bz2
dexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.tar.lz
dexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.tar.xz
dexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.tar.zst
dexon-solidity-2c1fb46bc341d9e44074af23cd4eadd3a9f732c5.zip
Merge pull request #1711 from ethereum/asmfunctions
Assembly: Analysis stage for functions.
Diffstat (limited to 'docs')
-rw-r--r--docs/assembly.rst17
1 files changed, 8 insertions, 9 deletions
diff --git a/docs/assembly.rst b/docs/assembly.rst
index 30f7fc01..eb1bf276 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -323,9 +323,12 @@ Access to External Variables and Functions
------------------------------------------
Solidity variables and other identifiers can be accessed by simply using their name.
-For storage and memory variables, this will push the address and not the value onto the
-stack. Also note that non-struct and non-array storage variable addresses occupy two slots
-on the stack: One for the address and one for the byte offset inside the storage slot.
+For memory variables, this will push the address and not the value onto the
+stack. Storage variables are different: Values in storage might not occupy a
+full storage slot, so 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
+used ``x_slot`` and to retrieve the byte-offset you used ``x_offset``.
+
In assignments (see below), we can even use local Solidity variables to assign to.
Functions external to inline assembly can also be accessed: The assembly will
@@ -340,17 +343,13 @@ changes during the call, and thus references to local variables will be wrong.
.. code::
- pragma solidity ^0.4.0;
+ pragma solidity ^0.4.11;
contract C {
uint b;
function f(uint x) returns (uint r) {
assembly {
- b pop // remove the offset, we know it is zero
- sload
- x
- mul
- =: r // assign to return variable r
+ r := mul(x, sload(b_slot)) // ignore the offset, we know it is zero
}
}
}