about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-01-11 15:53:46 +0100
committerAjax <commial@gmail.com>2016-01-11 15:59:25 +0100
commit6b09332775857805741be7ef6b1fc98e189f4d5b (patch)
tree9b41c5d411e1f39eb3d02082852fd668de3989f7
parent902f1968e834ae4f4719a17fe088c5258dd0e4e9 (diff)
downloadmiasm-6b09332775857805741be7ef6b1fc98e189f4d5b.tar.gz
miasm-6b09332775857805741be7ef6b1fc98e189f4d5b.zip
Mips32: fix delayslot (creds @serpilliere)
-rw-r--r--miasm2/arch/mips32/arch.py2
-rw-r--r--miasm2/core/parse_asm.py7
2 files changed, 3 insertions, 6 deletions
diff --git a/miasm2/arch/mips32/arch.py b/miasm2/arch/mips32/arch.py
index c9630d36..f64e09e5 100644
--- a/miasm2/arch/mips32/arch.py
+++ b/miasm2/arch/mips32/arch.py
@@ -189,7 +189,7 @@ class instruction_mips32(cpu.instruction):
 
 
 class mn_mips32(cpu.cls_mn):
-    delayslot = 0
+    delayslot = 1
     name = "mips32"
     regs = regs
     bintree = {}
diff --git a/miasm2/core/parse_asm.py b/miasm2/core/parse_asm.py
index 646ad445..840b88db 100644
--- a/miasm2/core/parse_asm.py
+++ b/miasm2/core/parse_asm.py
@@ -238,10 +238,9 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
     delayslot = 0
     while i < len(lines):
         if delayslot:
+            delayslot -= 1
             if delayslot == 0:
                 state = STATE_NO_BLOC
-            else:
-                delayslot -= 1
         line = lines[i]
         # no current block
         if state == STATE_NO_BLOC:
@@ -311,9 +310,7 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
                 if not line.splitflow():
                     block_to_nlink = None
 
-                delayslot = line.delayslot
-                if delayslot == 0:
-                    state = STATE_NO_BLOC
+                delayslot = line.delayslot + 1
             else:
                 raise RuntimeError("unknown class %s" % line.__class__)
         i += 1