diff options
author | stefan <stefan@s00.xyz> | 2023-05-24 22:29:46 -0400 |
---|---|---|
committer | stefan <stefan@s00.xyz> | 2023-05-24 22:29:46 -0400 |
commit | 20621e073562ee5d423b636fae8b6aa8e38275fa (patch) | |
tree | 4a81bde039e58602e44a213cfb8d91a65f1dadd9 /vm/memory.go | |
parent | ba2b9c8a1bb1876b6eb4c9783fde798b19de4418 (diff) | |
download | evm-20621e073562ee5d423b636fae8b6aa8e38275fa.tar.gz |
readme and cleanup
Diffstat (limited to 'vm/memory.go')
-rw-r--r-- | vm/memory.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/vm/memory.go b/vm/memory.go index 0a9dd2c..a0c610a 100644 --- a/vm/memory.go +++ b/vm/memory.go @@ -26,14 +26,18 @@ func (m *Memory) sb(ost uint64, val byte) { (*m)[ost] = val } -// loads 256b word fron offset in memory -func (m *Memory) ld(ost uint64) []byte { - if ost + 32 > uint64(len(*m)) { +func (m *Memory) ld(ost uint64, n uint64) []byte { + if ost + n > uint64(len(*m)) { log.Fatal("trying to load out of memory") } - r := make([]byte, 32) - copy(r, (*m)[ost:ost+32]) + r := make([]byte, n) + copy(r, (*m)[ost:ost+n]) + return r +} + +func (m *Memory) lw(ost uint64) []byte { + r := m.ld(ost, 32) return r } |