@@ -385,12 +385,12 @@ opEXTCODECOPY:
385385 $ => D :MLOAD(SP+1); [offset => D]
386386 $ => E :MLOAD(SP); [size => E]
387387
388- ; store lastMemOffset for memory expansion gas cost
389- C :MSTORE(lastMemOffset)
388+ ; store lastMemOffset for memory expansion gas cost, we store also at B to recover later
389+ C => B :MSTORE(lastMemOffset)
390390
391- ; store lastMemLength for memory expansion gas cost
391+ ; store lastMemLength for memory expansion gas cost, we store also at RCX to recover later
392392 ; compute memory expansion gas cost
393- E :MSTORE(lastMemLength), CALL(saveMem); in: [lastMemOffset, lastMemLength]
393+ E => RCX :MSTORE(lastMemLength), CALL(saveMem); in: [lastMemOffset, lastMemLength]
394394
395395 ; check out-of-gas
396396 ;${3*((E+31)/32)}
@@ -401,6 +401,8 @@ opEXTCODECOPY:
401401 ; 3*((E+31)/32)
402402 ; check out-of-gas
403403 GAS - 3 * E => GAS :JMPN(outOfGas)
404+ RCX => E
405+ B => C
404406 ; if offset is above data len, length => offset
405407 D => A
406408 $ => B :MLOAD(tmpContractLength)
@@ -504,8 +506,8 @@ opRETURNDATACOPY:
504506 $ => C :MLOAD(SP); [size => C]
505507 ; store lastMemOffset for memory expansion gas cost
506508 D :MSTORE(lastMemOffset)
507- ; store lastMemLength for memory expansion gas cost
508- C :MSTORE(lastMemLength), CALL(saveMem); in: [lastMemOffset, lastMemLength]
509+ ; store lastMemLength for memory expansion gas cost, we store also at RCX to recover later
510+ C => RCX :MSTORE(lastMemLength), CALL(saveMem); in: [lastMemOffset, lastMemLength]
509511 ; if retDataCTX is 0, end opcode execution
510512 $ => B :MLOAD(retDataCTX), JMPZ(opRETURNDATACOPYEmpty)
511513 ; Load ret data length from last ctx
@@ -527,6 +529,7 @@ opRETURNDATACOPY:
527529 ; C is secured to be less than 32 bits after calling saveMem
528530 ;(C+31)/32
529531 C + 31 => A :CALL(offsetUtil); in: [A: offset] out: [E: offset/32, C: offset%32]
532+ RCX => C
530533 ; 3*((C+31)/32)
531534 ; check out-of-gas
532535 GAS - 3 * E => GAS :JMPN(outOfGas)
0 commit comments