Skip to content

Commit

Permalink
MLOAD and MSTORE.
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Nov 29, 2017
1 parent 4ea5d71 commit 1b34eb5
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions gas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1b34eb5

Please sign in to comment.