about summary refs log tree commit diff stats
path: root/miasm2
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-08-12 14:02:07 +0200
committerserpilliere <devnull@localhost>2014-08-12 14:02:07 +0200
commit78ff130268616a02e55eb4890baf2087fc5bc780 (patch)
treedde790b07a3a712e4f8591cacf245b3871f7a9c9 /miasm2
parent0b526f3725bfa78444c2f2d8f6167793de579029 (diff)
downloadmiasm-78ff130268616a02e55eb4890baf2087fc5bc780.tar.gz
miasm-78ff130268616a02e55eb4890baf2087fc5bc780.zip
x86: add les/lds. Fix call/ret far
Diffstat (limited to 'miasm2')
-rw-r--r--miasm2/arch/x86/arch.py7
-rw-r--r--miasm2/arch/x86/sem.py25
2 files changed, 26 insertions, 6 deletions
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py
index 2d49135a..657ba679 100644
--- a/miasm2/arch/x86/arch.py
+++ b/miasm2/arch/x86/arch.py
@@ -3533,8 +3533,13 @@ addop("jmpf", [bs8(0xff), stk] + rmmod(d5))
 addop("lahf", [bs8(0x9f)])
 addop("lar", [bs8(0x0f), bs8(0x02)] + rmmod(rmreg))
 
-# XXX TODO LDS LES ...
 addop("lea", [bs8(0x8d)] + rmmod(rmreg))
+addop("les", [bs8(0xc4)] + rmmod(rmreg))
+addop("lds", [bs8(0xc5)] + rmmod(rmreg))
+addop("lss", [bs8(0x0f), bs8(0xb2)] + rmmod(rmreg))
+addop("lfs", [bs8(0x0f), bs8(0xb4)] + rmmod(rmreg))
+addop("lgs", [bs8(0x0f), bs8(0xb5)] + rmmod(rmreg))
+
 addop("leave", [bs8(0xc9)])
 
 addop("lodsb", [bs8(0xac)])
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index dd0d9e11..c78c9c36 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -1036,8 +1036,6 @@ def retf(ir, instr, a=None):
 
     a = a.zeroExtend(s)
 
-    e.append(ExprAff(myesp, (myesp + (ExprInt_fromsize(s, (s / 8)) + a))))
-
     c = myesp
     if ir.do_stk_segm:
         c = ExprOp('segm', SS, c)
@@ -1048,6 +1046,7 @@ def retf(ir, instr, a=None):
         c = ExprOp('segm', SS, c)
     e.append(ExprAff(CS, ExprMem(c, size=16)))
 
+    e.append(ExprAff(myesp, (myesp + (ExprInt_fromsize(s, (2*s) / 8) + a))))
     return meip, e, []
 
 
@@ -2622,7 +2621,7 @@ def cmpxchg(ir, instr, a, b):
 def lds(ir, instr, a, b):
     e = []
     e.append(ExprAff(a, ExprMem(b.arg, size=a.size)))
-    e.append(ExprAff(ds, ExprMem(b.arg + ExprInt_from(a, 2),
+    e.append(ExprAff(DS, ExprMem(b.arg + ExprInt_from(b.arg, a.size/8),
                                  size=16)))
     return None, e, []
 
@@ -2630,7 +2629,7 @@ def lds(ir, instr, a, b):
 def les(ir, instr, a, b):
     e = []
     e.append(ExprAff(a, ExprMem(b.arg, size=a.size)))
-    e.append(ExprAff(es, ExprMem(b.arg + ExprInt_from(a, 2),
+    e.append(ExprAff(ES, ExprMem(b.arg + ExprInt_from(b.arg, a.size/8),
                                  size=16)))
     return None, e, []
 
@@ -2638,7 +2637,21 @@ def les(ir, instr, a, b):
 def lss(ir, instr, a, b):
     e = []
     e.append(ExprAff(a, ExprMem(b.arg, size=a.size)))
-    e.append(ExprAff(ss, ExprMem(b.arg + ExprInt_from(a, 2),
+    e.append(ExprAff(SS, ExprMem(b.arg + ExprInt_from(b.arg, a.size/8),
+                                 size=16)))
+    return None, e, []
+
+def lfs(ir, instr, a, b):
+    e = []
+    e.append(ExprAff(a, ExprMem(b.arg, size=a.size)))
+    e.append(ExprAff(FS, ExprMem(b.arg + ExprInt_from(b.arg, a.size/8),
+                                 size=16)))
+    return None, e, []
+
+def lgs(ir, instr, a, b):
+    e = []
+    e.append(ExprAff(a, ExprMem(b.arg, size=a.size)))
+    e.append(ExprAff(GS, ExprMem(b.arg + ExprInt_from(b.arg, a.size/8),
                                  size=16)))
     return None, e, []
 
@@ -3085,6 +3098,8 @@ mnemo_func = {'mov': mov,
               "lds": lds,
               "les": les,
               "lss": lss,
+              "lfs": lfs,
+              "lgs": lgs,
               "lahf": lahf,
               "sahf": sahf,
               "lar": lar,