about summary refs log tree commit diff stats
path: root/miasm2/core
diff options
context:
space:
mode:
authorserpilliere <fabrice.desclaux@cea.fr>2015-10-28 19:02:08 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2015-10-29 21:40:20 +0100
commitf849393c93fbf0289f4242bc6bc04b062487c461 (patch)
tree0f36a6ed789f7b2b32ddf275fc4ef4da2281267e /miasm2/core
parent00daaf5d0d0abe87a889bce92e49556cbbc07d0f (diff)
downloadmiasm-f849393c93fbf0289f4242bc6bc04b062487c461.tar.gz
miasm-f849393c93fbf0289f4242bc6bc04b062487c461.zip
Core/Parse_asm: fix state define
Diffstat (limited to 'miasm2/core')
-rw-r--r--miasm2/core/parse_asm.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/miasm2/core/parse_asm.py b/miasm2/core/parse_asm.py
index d12e606d..178d0002 100644
--- a/miasm2/core/parse_asm.py
+++ b/miasm2/core/parse_asm.py
@@ -77,6 +77,10 @@ def replace_orphan_labels(instr, symbol_pool):
         instr.args[i] = instr.args[i].replace_expr(replace_id)
 
 
+
+STATE_NO_BLOC = 0
+STATE_IN_BLOC = 1
+
 def parse_txt(mnemo, attrib, txt, symbol_pool=None):
     """Parse an assembly listing. Returns a couple (blocks, symbol_pool), where
     blocks is a list of asm_bloc and symbol_pool the associated asm_symbol_pool
@@ -208,14 +212,14 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
 
     block_num = 0
     cur_block = None
-    state = 0
+    state = STATE_NO_BLOC
     i = 0
     blocks = []
     block_to_nlink = None
     block_may_link = False
     while i < len(lines):
         # no current block
-        if state == 0:
+        if state == STATE_NO_BLOC:
             if not isinstance(lines[i], asmbloc.asm_label):
                 label = guess_next_new_label(symbol_pool)
                 lines[i:i] = [label]
@@ -225,7 +229,7 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
                 cur_block.block_num = block_num
                 block_num += 1
                 blocks.append(cur_block)
-                state = 1
+                state = STATE_IN_BLOC
                 i += 1
                 if block_to_nlink:
                     block_to_nlink.addto(
@@ -234,14 +238,14 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
                     block_to_nlink = None
 
         # in block
-        elif state == 1:
+        elif state == STATE_IN_BLOC:
             if isinstance(lines[i], asmbloc.asm_raw):
                 if hasattr(lines[i], 'split'):
-                    state = 0
+                    state = STATE_NO_BLOC
                     block_may_link = False
                     i += 1
                 else:
-                    state = 1
+                    state = STATE_IN_BLOC
                     block_may_link = True
                     cur_block.addline(lines[i])
                     i += 1
@@ -254,7 +258,7 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
                     cur_block.addto(
                         asmbloc.asm_constraint(lines[i], C_NEXT))
                     block_may_link = False
-                state = 0
+                state = STATE_NO_BLOC
             # instruction
             else:
                 cur_block.addline(lines[i])
@@ -273,7 +277,7 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
                             label = guess_next_new_label(symbol_pool)
                             lines[i + 1:i + 1] = [label]
                     else:
-                        state = 0
+                        state = STATE_NO_BLOC
 
                     if lines[i].splitflow():
                         block_to_nlink = cur_block