From 1b34eb5e505f3d0a2c26e8f6bf5904a7d35ee8a4 Mon Sep 17 00:00:00 2001 From: Virgil Serbanuta Date: Wed, 29 Nov 2017 09:51:00 +0200 Subject: [PATCH] MLOAD and MSTORE. --- gas.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gas.md b/gas.md index 5c8ad106c..c8c43cfeb 100644 --- a/gas.md +++ b/gas.md @@ -711,6 +711,15 @@ of the logged registers. computationCost(MLOAD rREG wINDEX) = mLoadCost + mloadWordCost * memoryCellSize(value wIndex) estimatedResultSize(MLOAD rREG wINDEX) = memoryCellSize(value wIndex) ``` +* `MLOADN` + TODO: Check that I understood the semantics. What happens when index2 does + not point inside LM[index1]? + ```hs + computationCost(MLOADN rREG, wINDEX1, wINDEX2, wWIDTH) = + mLoadNCost + mLoadWordCost * wWIDTH + memoryDelta(MLOADN rREG, wINDEX1, wINDEX2, wWIDTH) = + wWIDTH - registerSize rREG + ``` * `MSTORE` when we store a new value over an old one, we compute the difference in size between the two values. Similar to changes to registers, this difference is used to update the current memory requirements, and, if it increases, it might update the top @@ -722,6 +731,21 @@ of the logged registers. memoryCost(MSTORE wINDEX wVALUE) = (registerSize wVALUE - storeCellSize(value wIndex)) ``` +* `MSTOREN` + + TODO: This assumes that mstoren inserts stuff at index2. If so, what happens + when INDEX2 does not point into the current memory value? Does the unused + space get filled with 0? + TODO: Check that I understood the semantics. + + ```hs + -- TODO: Are memory indexes 0-based? + computationCost(MSTOREN wINDEX1 wINDEX2 wVALUE wWIDTH) = + mStoreNCost + mStoreWordCost * wWIDTH + + mMoveWordCost * (storeCellSize(value wIINDEX1) - wINDEX2) + memoryDelta(MSTOREN wINDEX1 wINDEX2 wVALUE wWIDTH) = + wWIDTH + ``` #### Register manipulations * `MOVE` copies a value from one register to another @@ -847,14 +871,13 @@ Definitions * Check that GMP can give number of limbs in constant time or update costs accordingly * Check that all background costs are accounted for (e.g. updating a register's) metadata after an assignment. +* Check that memory deltas are used properly everywhere (e.g. MLOAD). ### TODOS: Instructions to add * EXTCODESIZE * CREATE * SELFDESTRUCT -* MLOADN -* MSTOREN * COPYCREATE ### TODOS: Instructions to consider if they should be added