Skip to content

Commit fe4646c

Browse files
committed
Debug arithmetic functions
1 parent 47410f1 commit fe4646c

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

packages/evm/src/opcodes/functions.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,11 +1005,18 @@ export const handlers: Map<number, OpHandler> = new Map([
10051005
[
10061006
0xc1,
10071007
function (runState, _common) {
1008+
console.log('dbg900')
10081009
const [dest, source, count] = runState.stack.popN(3)
10091010
const copySize = Number(count) * runState.evmmaxState.getActive()?.getElemSize()
10101011
const destBuf = new Uint8Array(copySize)
10111012
runState.evmmaxState.getActive()?.load(destBuf, Number(source), Number(count))
1013+
console.log(copySize)
1014+
console.log(count)
1015+
console.log(runState.evmmaxState.getActive()?.getElemSize())
1016+
console.log(destBuf)
1017+
console.log(runState.memory._store)
10121018
runState.memory.write(Number(dest), copySize, destBuf)
1019+
console.log(runState.memory._store)
10131020
},
10141021
],
10151022
// 0xc2: STOREX
@@ -1035,47 +1042,54 @@ export const handlers: Map<number, OpHandler> = new Map([
10351042
[
10361043
0xc3,
10371044
function (runState, _common) {
1045+
console.log('dbg100')
10381046
console.log(runState.code)
10391047
const [out, outStride, x, xStride, y, yStride, count] = extractEVMMAXImmediateInputs(
1040-
runState.programCounter,
1048+
runState.programCounter - 1,
10411049
runState.code,
10421050
)
10431051
runState.programCounter += 7
1044-
console.log('dbg500')
1045-
console.log(out)
1046-
console.log(outStride)
1047-
console.log(x)
1048-
console.log(xStride)
1049-
console.log(y)
1050-
console.log(yStride)
1051-
console.log(count)
1052-
console.log(runState.evmmaxState.getActive().scratchSpace)
1052+
// console.log('dbg500')
1053+
// console.log(out)
1054+
// console.log(outStride)
1055+
// console.log(x)
1056+
// console.log(xStride)
1057+
// console.log(y)
1058+
// console.log(yStride)
1059+
// console.log(count)
1060+
// console.log(runState.evmmaxState.getActive().scratchSpace)
10531061
runState.evmmaxState.getActive().addM(out, outStride, x, xStride, y, yStride, count)
1054-
console.log(runState.evmmaxState.getActive().scratchSpace)
1062+
// console.log(runState.evmmaxState.getActive().scratchSpace)
10551063
},
10561064
],
10571065
// 0xc4: SUBMODX
10581066
[
10591067
0xc4,
10601068
function (runState, _common) {
10611069
const [out, outStride, x, xStride, y, yStride, count] = extractEVMMAXImmediateInputs(
1062-
runState.programCounter,
1070+
runState.programCounter - 1,
10631071
runState.code,
10641072
)
10651073
runState.programCounter += 7
1074+
console.log('dbg701')
1075+
console.log(runState.evmmaxState.getActive().scratchSpace)
10661076
runState.evmmaxState.getActive().subM(out, outStride, x, xStride, y, yStride, count)
1077+
console.log(runState.evmmaxState.getActive().scratchSpace)
10671078
},
10681079
],
10691080
// 0xc5: MULMODX
10701081
[
10711082
0xc5,
10721083
function (runState, _common) {
10731084
const [out, outStride, x, xStride, y, yStride, count] = extractEVMMAXImmediateInputs(
1074-
runState.programCounter,
1085+
runState.programCounter - 1,
10751086
runState.code,
10761087
)
10771088
runState.programCounter += 7
1089+
console.log('dbg700')
1090+
console.log(runState.evmmaxState.getActive().scratchSpace)
10781091
runState.evmmaxState.getActive().mulM(out, outStride, x, xStride, y, yStride, count)
1092+
console.log(runState.evmmaxState.getActive().scratchSpace)
10791093
},
10801094
],
10811095
// 0xd0: DATALOAD

0 commit comments

Comments
 (0)