diff python/target/armtoken.py @ 341:4d204f6f7d4e devel

Rewrite of assembler parts
author Windel Bouwman
date Fri, 28 Feb 2014 18:07:14 +0100
parents c7cc54c0dfdf
children
line wrap: on
line diff
--- a/python/target/armtoken.py	Sun Feb 23 16:24:01 2014 +0100
+++ b/python/target/armtoken.py	Fri Feb 28 18:07:14 2014 +0100
@@ -1,3 +1,8 @@
+
+import struct
+
+def u16(h):
+    return struct.pack('<H', h)
 
 def val2bit(v, bits):
     b = []
@@ -14,10 +19,7 @@
     return property(getter, setter)
 
 
-class ThumbToken:
-    def __init__(self):
-        self.bit_value = 0
-
+class Token:
     def set_bit(self, i, value):
         value = bool(value)
         assert i in range(0, 16)
@@ -42,12 +44,18 @@
         else:
             raise KeyError()
 
+class ThumbToken(Token):
+    def __init__(self):
+        self.bit_value = 0
+
+
     rd = bit_range(0, 3)
 
     def encode(self):
         return u16(self.bit_value)
 
 
-class ArmToken:
-    pass
+class ArmToken(Token):
+    def __init__(self):
+        self.bit_value = 0