aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/disasm.go
blob: 2bfea5cbda650273b7812082d4a635fadf07f4c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package vm

import "fmt"

func Disasm(code []byte) []string {
    var out []string
    for pc := uint64(0); pc < uint64(len(code)); pc++ {
        op := OpCode(code[pc])
        out = append(out, op.String())

        switch op {
        case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
            a := uint64(op) - uint64(PUSH1) + 1
            out = append(out, fmt.Sprintf("0x%x", code[pc+1:pc+1+a]))

            pc += a
        }
    }

    return out
}
ágyi2017-08-255-116/+26 |\ | * consensus, core, tests: implement Metropolis EIP 649Péter Szilágyi2017-08-245-116/+26 * | core/state: revert metro suicide map addition (#15024)Péter Szilágyi2017-08-241-1/+0 |/ * Merge pull request #15014 from rjl493456442/metropolis-eip658Péter Szilágyi2017-08-233-4/+5 |\ | * tests: pull in new test suite, enable most block testsPéter Szilágyi2017-08-222-3/+4 | * core: implement Metropolis EIP 658, receipt status byterjl4934564422017-08-221-1/+1 * | tests: enable Byzantium state tests for CIPéter Szilágyi2017-08-221-2/+2 |/ * Merge pull request #14983 from karalabe/metropolis-revertPéter Szilágyi2017-08-211-0/+3 |\ | * tests: skip the bad tests from colliding account touchesPéter Szilágyi2017-08-171-0/+3 * | core, light: send chain events using event.Feed (#14865)Miya Chen2017-08-181-2/+1 |/ * tests: pull in latest tests from upstreamPéter Szilágyi2017-08-161-0/+0 * tests: update tests, use blockchain test "network" fieldFelix Lange2017-08-116-84/+110 * tests: update tests and implement general state tests (#14734)Felix Lange2017-07-11895-2505399/+1466 * params: remove redundant consts, disable metro on AllProtocolChangesPéter Szilágyi2017-07-042-25/+25 * core/state: access trie through Database interface, track errors (#14589)Felix Lange2017-06-273-41/+18 * accounts/keystore, crypto: enforce 256 bit keys on importPéter Szilágyi2017-05-231-3/+2 * consensus, core: drop all the legacy custom core error typesPéter Szilágyi2017-04-061-1/+1 * core, consensus: pluggable consensus engines (#3817)Péter Szilágyi2017-04-051-2/+2 * all: swap out the C++ ethash to the pure Go one (mining todo)Péter Szilágyi2017-03-091-2/+2 * all: unify big.Int zero checks, use common/math in more places (#3716)Felix Lange2017-02-281-1/+1 * all: disable log message colors outside of gethFelix Lange2017-02-271-1/+1 * common: move big integer math to common/math (#3699)Felix Lange2017-02-274-18/+22 * all: blidly swap out glog to our log15, logs need reworkPéter Szilágyi2017-02-235-16/+16 * core, core/state, core/vm: remove exported account getters (#3618)Jeffrey Wilcke2017-02-233-18/+19 * tests: cleanup tester blockchain after test run (#3692)Péter Szilágyi2017-02-201-0/+1 * params: core, core/vm, miner: 64bit gas instructionsJeffrey Wilcke2017-02-143-5/+5 * Revert "params: core, core/vm, miner: 64bit gas instructions (#3514)"Jeffrey Wilcke2017-02-134-6/+6 * params: core, core/vm, miner: 64bit gas instructions (#3514)Jeffrey Wilcke2017-02-023-5/+5 * cmd/geth, core: add support for recording SHA3 preimages (#3543)Nick Johnson2017-01-171-1/+2 * tests: unskip testJeffrey Wilcke2017-01-121-1/+1 * all: fix spelling errorsPéter Szilágyi2017-01-074-6/+6 * all: fix issues reported by honnef.co/go/simple/cmd/gosimpleFelix Lange2017-01-074-10/+4 * core/vm: move Log to core/typesFelix Lange2017-01-063-7/+8 * core/vm: improved EVM run loop & instruction calling (#3378)Jeffrey Wilcke2017-01-055-20/+19 * core, core/vm: implemented a generic environment (#3348)Jeffrey Wilcke2016-12-063-164/+63 * tests: update from github.com/ethereum/tests @ f21c49dc816eFelix Lange2016-11-2531-1065/+1799 * core, core/state: fixed consensus issue added touch revertJeffrey Wilcke2016-11-253-29/+119 * core/types: turn off nonce checking for Call messagesZsolt Felfoldi2016-11-141-1/+1 * tests: updatedJeffrey Wilcke2016-11-14155-56656/+55466 * core/types, params: EIP#155Jeffrey Wilcke2016-11-134-34/+12 * tests: added new EIP158 testsJeffrey Wilcke2016-11-13731-1158/+84508 * core, core/state, trie: EIP158, reprice & skip empty account writeJeffrey Wilcke2016-11-136-204/+215 * core, core/vm: added gas price variance tableJeffrey Wilcke2016-10-1527-42/+76970 * Merge pull request #3094 from fjl/tests-updateFelix Lange2016-10-06745-65640/+188442 |\ | * tests: update test files from github.com/ethereum/tests @ 45bc1d21d3c1Felix Lange2016-10-06745-65640/+188442 * | core/state: implement reverts by journaling all changesFelix Lange2016-10-06