cmd/evm, core/asm: add EVM assembler (#3686)

The evm compile command implements a simple assembly language that compiles to
EVM bytecode.
This commit is contained in:
Jeffrey Wilcke
2017-03-01 01:11:24 +01:00
committed by Felix Lange
parent 7ff75ac2f2
commit 230cf2ec91
8 changed files with 852 additions and 133 deletions

View File

@ -17,10 +17,10 @@
package vm
import (
"encoding/hex"
"fmt"
"math/big"
"os"
"unicode"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
@ -184,24 +184,8 @@ func StdErrFormat(logs []StructLog) {
fmt.Fprintf(os.Stderr, "%04d: %x\n", len(log.Stack)-i-1, math.PaddedBigBytes(log.Stack[i], 32))
}
const maxMem = 10
addr := 0
fmt.Fprintln(os.Stderr, "MEM =", len(log.Memory))
for i := 0; i+16 <= len(log.Memory) && addr < maxMem; i += 16 {
data := log.Memory[i : i+16]
str := fmt.Sprintf("%04d: % x ", addr*16, data)
for _, r := range data {
if r == 0 {
str += "."
} else if unicode.IsPrint(rune(r)) {
str += fmt.Sprintf("%s", string(r))
} else {
str += "?"
}
}
addr++
fmt.Fprintln(os.Stderr, str)
}
fmt.Fprintln(os.Stderr, hex.Dump(log.Memory))
fmt.Fprintln(os.Stderr, "STORAGE =", len(log.Storage))
for h, item := range log.Storage {