Commit efabb4c7 authored by George Hotz's avatar George Hotz

print 4004 in evm syscall

parent 9b8181a2
......@@ -7,6 +7,7 @@ import (
"log"
"os"
"strconv"
"strings"
"time"
)
......@@ -50,7 +51,7 @@ func main() {
steps = 1000000
}
if len(os.Args) > 1 {
if os.Args[1] == "../mipigeth/minigeth.bin" {
if strings.HasPrefix(os.Args[1], "../mipigeth/") {
debug, _ := strconv.Atoi(os.Getenv("DEBUG"))
RunMinigeth(os.Args[1], steps, debug)
} else if os.Args[1] == "unicorn" {
......
......@@ -84,6 +84,15 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
if ram[nret] == 0xC {
syscall := ram[0xc0000008]
os.Stderr.WriteString(fmt.Sprintf("syscall %d at %x (step %d)\n", syscall, nret, pcCount))
if syscall == 4004 {
len := int(ram[0xc0000018])
buf := make([]byte, len+3)
for i := 0; i < len; i += 4 {
binary.BigEndian.PutUint32(buf[i:i+4], ram[ram[0xc0000014]+uint32(i)])
}
WriteBytes(int(ram[0xc0000010]), buf[0:len])
//fmt.Printf("%x %x %x\n", ram[0xc0000010], ram[0xc0000014], ram[0xc0000018])
}
}
if (pcCount % 10000) == 0 {
steps_per_sec := float64(pcCount) * 1e9 / float64(time.Now().Sub(ministart).Nanoseconds())
......
......@@ -22,8 +22,14 @@ func check(err error) {
var steps int = 0
var heap_start uint64 = 0
func RegRead(u *uc.Unicorn, reg int) {
func WriteBytes(fd int, bytes []byte) {
printer := color.New(color.FgWhite).SprintFunc()
if fd == 1 {
printer = color.New(color.FgGreen).SprintFunc()
} else if fd == 2 {
printer = color.New(color.FgRed).SprintFunc()
}
os.Stderr.WriteString(printer(string(bytes)))
}
// reimplement simple.py in go
......@@ -51,14 +57,7 @@ func RunUnicorn(fn string, totalSteps int) {
buf, _ := mu.RegRead(uc.MIPS_REG_A1)
count, _ := mu.RegRead(uc.MIPS_REG_A2)
bytes, _ := mu.MemRead(buf, count)
printer := color.New(color.FgWhite).SprintFunc()
if fd == 1 {
printer = color.New(color.FgGreen).SprintFunc()
} else if fd == 2 {
printer = color.New(color.FgRed).SprintFunc()
}
os.Stderr.WriteString(printer(string(bytes)))
WriteBytes(int(fd), bytes)
} else if syscall_no == 4090 {
a0, _ := mu.RegRead(uc.MIPS_REG_A0)
sz, _ := mu.RegRead(uc.MIPS_REG_A1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment