3 # converts Keil compatible header files to sdcc-compatible format
4 # call (path)/keil2sdcc.pl keil_file_name sdcc_file_name
6 # Bela Torok - bela.torok@kssg.ch
9 # Limitation: Keil-style sfr and sbit definitions should begin
10 # in the first column!
13 $keil_file = $ARGV[0];
14 $sdcc_file = $ARGV[1];
16 if (open (KEIL_FILE , "<" . $keil_file)) {
17 # printf("Opening file: %s for output!\n", $keil_file);
19 printf("Cannot open file: %s !\n", $keil_file);
23 if (open (SDCC_FILE ,">" . $sdcc_file)) {
24 # printf("Opening file: %s for output!\n", $sdcc_file);
26 printf("Cannot open file: %s !\n", $sdcc_file);
30 while ($input_buffer = <KEIL_FILE>) {
32 if( substr($input_buffer, 0, 3) eq 'sfr')
34 &convert( substr($input_buffer, 4) );
35 print SDCC_FILE "sfr at", $value, " ", $name, ";", $comment;
37 elsif( substr($input_buffer, 0, 4) eq 'sbit')
39 &convert( substr($input_buffer, 5) );
40 print SDCC_FILE "sbit at", $value, " ", $name, ";", $comment;
43 print SDCC_FILE $input_buffer;
56 ($command, $comment) = split(';' , $arg);
58 ($name, $value) = split('=' , $command);