protected long copyWordsToMemoryGasCost(
      final MessageFrame frame,
      final long baseGasCost,
      final long wordGasCost,
      final long offset,
      final long length) {
    final long copyCost =
        clampedAdd(clampedMultiply(wordGasCost, numWords(clampedToInt(length))), baseGasCost);
    final long memoryCost = memoryExpansionGasCost(frame, offset, length);

    return clampedAdd(copyCost, memoryCost);
  }
Copy words to memory gas cost.

@param frame the frame
@param baseGasCost the base gas cost
@param wordGasCost the word gas cost
@param offset the offset
@param length the length
@return the cost
evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java