diff python/zcc.py @ 246:f254b87258e6

Added hexfile to zcc
author Windel Bouwman
date Thu, 25 Jul 2013 08:11:30 +0200
parents 63bb40758066
children e41e4109addd
line wrap: on
line diff
--- a/python/zcc.py	Wed Jul 24 22:40:29 2013 +0200
+++ b/python/zcc.py	Thu Jul 25 08:11:30 2013 +0200
@@ -5,6 +5,7 @@
 import codegenarm
 from transform import CleanPass, SameImmLoadDeletePass
 import outstream
+import hexfile
 
 # Parse arguments:
 parser = argparse.ArgumentParser(description='lcfos Compiler')
@@ -12,6 +13,7 @@
   help='the source file to build')
 parser.add_argument('-d', '--dumpir', action='store_true', help="Dump IR-code")
 parser.add_argument('-o', '--output', help='Output file', metavar='filename')
+parser.add_argument('--hexfile', help='Output hexfile', type=argparse.FileType('w'))
 
 def main(args):
     # Front end:
@@ -55,6 +57,11 @@
     with open(output_filename, 'wb') as f:
         f.write(code_bytes)
 
+    if args.hexfile:
+        hf = hexfile.HexFile()
+        hf.addRegion(0x08000000, code_bytes)
+        hf.save(args.hexfile)
+
 if __name__ == '__main__':
     arguments = parser.parse_args()
     main(arguments)