Questions tagged [assembly]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
57
votes
2answers
20k views

What OPCODES are available for the Ethereum EVM?

The Ethereum virtual machine has a large number of operation codes and base level instruction sets. Is a complete listing available?
12
votes
2answers
3k views

isContract function using EVM assembly to get the address' code size

My problem is that I need to make sure my contract processes only the transactions coming from EOA (externally owned accounts). For this I need to determine the type of account I'm dealing with. In ...
8
votes
1answer
406 views

What is the cryptic part at the end of a solidity contract bytecode?

Given the following contract: pragma solidity ^0.4.11; contract Simple { bytes32 public v; function set(bytes32 _v) { v = _v; } } When disassembling, neither remix, solc or evm ...
18
votes
2answers
4k views

understanding mload assembly function

I am learning the inline assembly in solidity, i ve found the function mload(0x40) i am confused whith what this function does? did it reserve 4 Slot/word in memory or did it load the data stored in ...
4
votes
2answers
2k views

Concat two bytes arrays with Assembly

Does anyone know how to efficiently concat two bytes arrays with assembly language to save gas costs? Currently I have function mergeBytes(bytes param1, bytes param2) returns (bytes) { bytes ...
5
votes
3answers
894 views

Get address from public key in Solidity

The address is the last 20 bytes of sha3(publicKey) In Solidity, using assembly if needed, how could I splice the first 12 bytes from sha3(publicKey) and get the address? What I came up with runs out ...
1
vote
1answer
78 views

How to get access to the storage array through the solidity assembler?

If the array is located in memory, then all the elements are in sequence, for example: uint256 arrLength = arr.length; assembly{ let offset := sload(arrLength) res:= mload(...
12
votes
3answers
2k views

What are some examples of how inline assembly benefits smart contract development?

A lot of people have expressed excitement at the potential of using inline assembly in smart contracts. After seeing this comment on reddit I'm curious to see some basic (and more advanced, if you ...
7
votes
1answer
487 views

Difference between the assembly code generated for uint and uint32?

I wrote a simple contract with a single state variable with type uint and the generated assembly code is quite straight forward. But when I changed the type to uint32 the generated assembly becomes ...
11
votes
1answer
367 views

How to generate sugared assembly code from Solidity code?

In the Solidity documentation I see a sample assembly code: { mstore(0x40, 0x60) // store the "free memory pointer" // function dispatcher switch div(calldataload(0), exp(2, 226)) case ...
4
votes
1answer
703 views

How to return dynamic sized array's original address on the memory of Solidity?

On the following source code, memOffset returns local values such as 96, 128 as the address value. How could I make it return the original address that is located on the memory, is it possible? After ...
5
votes
2answers
2k views

How to convert bytes to uint in Solidity

Hey is there a way to convert bytes to uint in Solidity?
3
votes
2answers
443 views

Can the CALL opcode be used to create a contract?

The Yellow Paper Appendix H defines the CREATE and CALL opcodes. For CALL: the operand order is: gas, to, value, in offset, in size, out offset, out size. By setting the second operand (the "to"...
2
votes
1answer
618 views

Problem using created array from assembly

I've used the code from the solidity assembly tutorial here to create a single dimensional array in assembly. The code is as follows: contract C { function f(uint a, uint b) constant returns (uint[]) ...
1
vote
1answer
619 views

hexadecimal (bytes) to binary (uint) in a smart contract

What are some ways to convert from bytes8 hexadecimal to uint64 binary?