about summary refs log tree commit diff stats
path: root/miasm2/core/parse_asm.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2015-04-01 23:39:49 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2015-04-01 23:47:37 +0200
commitd91f03ed42035c05e485aa082af5b1c03865edb7 (patch)
tree236dc7cc409cf054037be902544eaa9ece85bece /miasm2/core/parse_asm.py
parent4da2fec809d32c357ec28d1d618cf7dc5f5f03b3 (diff)
downloadmiasm-d91f03ed42035c05e485aa082af5b1c03865edb7.tar.gz
miasm-d91f03ed42035c05e485aa082af5b1c03865edb7.zip
Asmbloc: refactor and clean asmbloc/parse_asm
Diffstat (limited to 'miasm2/core/parse_asm.py')
-rw-r--r--miasm2/core/parse_asm.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/miasm2/core/parse_asm.py b/miasm2/core/parse_asm.py
index 6bec9651..a56bcd9a 100644
--- a/miasm2/core/parse_asm.py
+++ b/miasm2/core/parse_asm.py
@@ -19,6 +19,11 @@ size2pck = {8: 'B',
             64: 'Q',
             }
 
+class directive_align:
+    def __init__(self, alignment=1):
+        self.alignment = alignment
+    def __str__(self):
+        return "alignment %s"%self.alignment
 
 def guess_next_new_label(symbol_pool, gen_label_index=0):
     i = 0
@@ -145,6 +150,10 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None, gen_label_index=0):
             if directive == 'dontsplit':  # custom command
                 lines.append(asmbloc.asm_raw())
                 continue
+            if directive == "align":
+                align_value = int(line[r.end():])
+                lines.append(directive_align(align_value))
+                continue
             if directive in ['file', 'intel_syntax', 'globl', 'local',
                              'type', 'size', 'align', 'ident', 'section']:
                 continue
@@ -195,7 +204,7 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None, gen_label_index=0):
                     lines[i:i] = [l]
                 else:
                     l = lines[i]
-                    b = asmbloc.asm_bloc(l)
+                    b = asmbloc.asm_bloc(l, alignment=mnemo.alignment)
                     b.bloc_num = bloc_num
                     bloc_num += 1
                     blocs.append(b)
@@ -218,6 +227,9 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None, gen_label_index=0):
                         block_may_link = True
                         b.addline(lines[i])
                         i += 1
+                elif isinstance(lines[i], directive_align):
+                    b.alignment = lines[i].alignment
+                    i += 1
                 # asmbloc.asm_label
                 elif isinstance(lines[i], asmbloc.asm_label):
                     if block_may_link: