add simple mingw32 script to compile
[fw/sdcc] / support / scripts / keil2sdcc.pl
1 #!/usr/bin/perl
2 # keil2sdcc.pl
3 # converts Keil compatible header files to sdcc-compatible format
4 # call (path)/keil2sdcc.pl keil_file_name sdcc_file_name
5 #
6 # Bela Torok - bela.torok@kssg.ch
7 # Version: June 2001
8 #
9 # Limitation: Keil-style sfr and sbit definitions should begin 
10 # in the first column! 
11 #
12
13 $keil_file = $ARGV[0];
14 $sdcc_file = $ARGV[1];
15
16 if (open (KEIL_FILE , "<" . $keil_file)) {  
17 #  printf("Opening file: %s for output!\n", $keil_file);
18 } else {
19   printf("Cannot open file: %s !\n", $keil_file);
20   exit (0);
21 }
22
23 if (open (SDCC_FILE ,">" . $sdcc_file)) {  
24 #  printf("Opening file: %s for output!\n", $sdcc_file);
25 } else {
26   printf("Cannot open file: %s !\n", $sdcc_file);
27   exit (0);
28 }
29
30 while ($input_buffer = <KEIL_FILE>) {
31
32   if( substr($input_buffer, 0, 3) eq 'sfr') 
33     {
34       &convert( substr($input_buffer, 4) );
35       print SDCC_FILE "sfr at", $value, " ", $name, ";", $comment;
36     }
37   elsif( substr($input_buffer, 0, 4) eq 'sbit') 
38     {
39       &convert( substr($input_buffer, 5) );
40       print SDCC_FILE "sbit at", $value, " ", $name, ";", $comment;
41     }
42   else {
43     print SDCC_FILE $input_buffer;
44   }
45
46 }
47
48 close (KEIL_FILE);
49 close (SDCC_FILE);
50 exit (0);
51
52 sub convert
53 {
54     local($arg) = @_;
55
56     ($command, $comment) = split(';' , $arg);
57
58     ($name, $value) = split('=' , $command);
59
60 }
61
62
63
64
65
66
67
68
69
70
71
72