Skip to content

Commit

Permalink
Merge branch 'main' into pmakhnev/better-div-decompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 authored Jan 17, 2025
2 parents c3c5eb6 + a2939ea commit 5597aaf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
48 changes: 24 additions & 24 deletions src/decompiler/__snapshots__/decompileAll.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
SUB
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down Expand Up @@ -752,14 +752,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
ADD
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down Expand Up @@ -817,7 +817,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
<{
1 RSHIFT
s0 s2 XCHG
-1 ADD
DEC
s0 s2 XCHG
}> PUSHCONT
IF
Expand Down Expand Up @@ -858,7 +858,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
AND
<{
s0 s1 XCHG
-1 MULCONST
NEGATE
}> PUSHCONT
REPEAT
}>
Expand All @@ -883,7 +883,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
?fun_ref_1b1ae470b4614553 PROCREF:<{
s0 PUSH
UBITSIZE
-1 ADD
DEC
8 PUSHPOW2DEC
s1 PUSH
SUB
Expand Down Expand Up @@ -1001,7 +1001,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
s1 s3 XCHG
SUB
s0 s2 XCHG
-2 ADD
-2 ADDCONST
}> PUSHCONT
REPEAT
s0 POP
Expand Down Expand Up @@ -1350,14 +1350,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
ADD
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down Expand Up @@ -1417,14 +1417,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
ADD
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down Expand Up @@ -1482,14 +1482,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
ADD
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand All @@ -1513,7 +1513,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
DIVR
s1 PUSH
1 LSHIFT
5 ADD
5 ADDCONST
250 LSHIFT
s0 PUSH
251 PUSHPOW2
Expand Down Expand Up @@ -1588,7 +1588,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
<{
2 1 BLKDROP2
0 EQINT
-1 MULCONST
NEGATE
}> PUSHCONT
IFJMP
?fun_ref_2051d9d821c3f770 INLINECALLDICT
Expand Down Expand Up @@ -1734,7 +1734,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
AND
<{
s0 s1 XCHG
-1 MULCONST
NEGATE
}> PUSHCONT
IF
DIVR
Expand All @@ -1752,14 +1752,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
SUB
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down Expand Up @@ -1853,14 +1853,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
ADD
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down Expand Up @@ -1995,7 +1995,7 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
1 PUSHINT
AND
<{
-1 MULCONST
NEGATE
s0 s1 XCHG
}> PUSHCONT
IF
Expand Down Expand Up @@ -2064,14 +2064,14 @@ exports[`decompileAll should decompile mathlib.fc 1`] = `
255 PUSHPOW2
ADD
s3 PUSH
-1 ADD
DEC
<{
s2 s1 PUXC
DIVR
s1 s1 PUXC
SUB
s3 PUSH
-1 ADD
DEC
s4 s4 XCPU
DIVR
s1 PUSH
Expand Down
9 changes: 8 additions & 1 deletion src/printer/AssemblerWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,15 @@ export class AssemblerWriter {
if (firstArg === 1) {
return 'INC';
}
if (firstArg === -1) {
return 'DEC';
}
}

return `${firstArg} ADD`;
if (node.opcode === 'MULCONST') {
if (firstArg === -1) {
return 'NEGATE';
}
}

// Debug
Expand Down

0 comments on commit 5597aaf

Please sign in to comment.