Converts Keil-style header files to sdcc format
authorbela <bela@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Jun 2001 09:55:33 +0000 (09:55 +0000)
committerbela <bela@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Jun 2001 09:55:33 +0000 (09:55 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@885 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/scripts/keil2sdcc.pl [new file with mode: 0755]

diff --git a/support/scripts/keil2sdcc.pl b/support/scripts/keil2sdcc.pl
new file mode 100755 (executable)
index 0000000..6a8b327
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+# keil2sdcc.pl
+# converts Keil compatible header files to sdcc-compatible format
+# call (path)/keil2sdcc.pl keil_file_name sdcc_file_name
+#
+# Bela Torok - bela.torok@kssg.ch
+# Version: June 2001
+#
+# Limitation: Keil-style sfr and sbit definitions should begin 
+# in the first column! 
+#
+
+$keil_file = $ARGV[0];
+$sdcc_file = $ARGV[1];
+
+if (open (KEIL_FILE , "<" . $keil_file)) {  
+#  printf("Opening file: %s for output!\n", $keil_file);
+} else {
+  printf("Cannot open file: %s !\n", $keil_file);
+  exit (0);
+}
+
+if (open (SDCC_FILE ,">" . $sdcc_file)) {  
+#  printf("Opening file: %s for output!\n", $sdcc_file);
+} else {
+  printf("Cannot open file: %s !\n", $sdcc_file);
+  exit (0);
+}
+
+while ($input_buffer = <KEIL_FILE>) {
+
+  if( substr($input_buffer, 0, 3) eq 'sfr') 
+    {
+      &convert( substr($input_buffer, 4) );
+      print SDCC_FILE "sfr at", $value, " ", $name, ";", $comment;
+    }
+  elsif( substr($input_buffer, 0, 4) eq 'sbit') 
+    {
+      &convert( substr($input_buffer, 5) );
+      print SDCC_FILE "sbit at", $value, " ", $name, ";", $comment;
+    }
+  else {
+    print SDCC_FILE $input_buffer;
+  }
+
+}
+
+close (KEIL_FILE);
+close (SDCC_FILE);
+exit (0);
+
+sub convert
+{
+    local($arg) = @_;
+
+    ($command, $comment) = split(';' , $arg);
+
+    ($name, $value) = split('=' , $command);
+
+}
+
+
+
+
+
+
+
+
+
+
+
+