Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix with post scripts #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions post/adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
b = 8
Expand Down
3 changes: 3 additions & 0 deletions post/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
b = 8
Expand Down
3 changes: 3 additions & 0 deletions post/andor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
s = "b"
Expand Down
3 changes: 3 additions & 0 deletions post/cmpxchgxchg.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down
3 changes: 3 additions & 0 deletions post/mov32.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down
3 changes: 3 additions & 0 deletions post/pushpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down
25 changes: 25 additions & 0 deletions post/rand.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def o_adc(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
b = 8
Expand Down Expand Up @@ -86,6 +89,9 @@ def o_add(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
b = 8
Expand Down Expand Up @@ -132,6 +138,9 @@ def o_andor(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
s = "b"
Expand All @@ -156,6 +165,9 @@ def o_rrrrr(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
b = 8
Expand Down Expand Up @@ -195,6 +207,9 @@ def o_sbb(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
s = "b"
Expand Down Expand Up @@ -237,6 +252,9 @@ def o_sub(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
s = "b"
Expand Down Expand Up @@ -269,6 +287,9 @@ def o_xadd(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
b = 8
Expand Down Expand Up @@ -320,6 +341,10 @@ def o_xadd(f, l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down
6 changes: 6 additions & 0 deletions post/rereg.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def genreg(l):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if "TR0" in source:
source = source.replace("TR0", "r%d" % r0)
Expand Down Expand Up @@ -124,6 +127,9 @@ def rereg(l, asm, i):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

source_regs = re.findall(r'r\d+_', source)
for r in source_regs:
Expand Down
11 changes: 11 additions & 0 deletions post/risc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def decompose(term):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down Expand Up @@ -120,6 +123,10 @@ def decompose(term):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


if l.startswith("movb"):
s = "b"
Expand Down Expand Up @@ -192,6 +199,10 @@ def decompose(term):
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


# warning: ebp used in a previous pass to load immediates. it's
# okay since it was loading 32 bit values, and won't be translated
Expand Down
7 changes: 7 additions & 0 deletions post/rrrrr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down Expand Up @@ -72,6 +75,10 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


if l.startswith("movb"):
b = 8
Expand Down
4 changes: 4 additions & 0 deletions post/sbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


if l.startswith("movb"):
s = "b"
Expand Down
6 changes: 6 additions & 0 deletions post/shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ def can_swap(l1, l2):
tok1 = l1.find(",")
source1 = l1[l1.index(" "):tok1].strip()
dest1 = l1[tok1+1:].strip()
end = dest1.find(" ")
if end != -1:
dest1 = dest1[:end]

tok2 = l2.find(",", l2.find(")"))
if tok2 == -1:
tok2 = l2.find(",")
source2 = l2[l2.index(" "):tok2].strip()
dest2 = l2[tok2+1:].strip()
end = dest2.find(" ")
if end != -1:
dest2 = dest2[:end]

# assumes compiler outputs () around all memory references

Expand Down
4 changes: 4 additions & 0 deletions post/sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


if l.startswith("movb"):
s = "b"
Expand Down
8 changes: 8 additions & 0 deletions post/xadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


# NOTE: requires M/o/Vfuscator to only produce dword constants
if source.startswith("$"):
Expand Down Expand Up @@ -68,6 +72,10 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]


if l.startswith("movb"):
b = 8
Expand Down
3 changes: 3 additions & 0 deletions post/xor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
tok = l.find(",")
source = l[l.index(" "):tok].strip()
dest = l[tok+1:].strip()
end = dest.find(" ")
if end != -1:
dest = dest[:end]

if l.startswith("movb"):
s = "b"
Expand Down