3 # Copyright (c) 2002 Kevin L. Pauba
8 # SDCC is licensed under the GNU Public license (GPL) v2. Note that
9 # this license covers the code to the compiler and other executables,
10 # but explicitly does not cover any code or objects generated by sdcc.
11 # We have not yet decided on a license for the run time libraries, but
12 # it will not put any requirements on code linked against it. See:
14 # http://www.gnu.org/copyleft/gpl.html
16 # See http://sdcc.sourceforge.net/ for the latest information on sdcc.
20 ($junk, $file, $version, $date, $time, $programmer, $status)
21 = split(/\s+/, $rcsid);
22 ($programName) = ($file =~ /(\S+),v/);
29 # Read the symbols at the end of this file.
34 if (/^alias\s+(\S+)\s+(\S+)/) {
36 # Set an alias for a special function register.
37 # Some MPASM include files are not entirely consistent
41 } elsif (/^address\s+(\S+)\s+(\S+)/) {
43 # Set a default address for a special function register.
44 # Some MPASM include files don't specify the address
51 foreach $key (split) {
52 eval "\$type{'$key'} = $type;";
62 // This header file was automatically generated by:
64 //\t$programName V$version
69 #define BIT_AT(base,bitno) bit at ((base<<3)+bitno)
78 $defaultType = 'other';
80 if (/^;-* (\S+) Bits/i) {
81 if (defined($alias{$1})) {
82 $defaultType = "bits $alias{$1}";
84 $defaultType = "bits $1";
88 } elsif (/^;-* Register Files/i) {
98 # Convert ASM comments to C style.
101 } elsif (/^\s*IFNDEF __(\S+)/) {
107 } elsif (/^\s*(\S+)\s+EQU\s+H'(.+)'/) {
109 # Useful bit of information.
117 if (defined($type{"$name"})) {
118 $type = $type{"$name"};
120 $type = $defaultType;
123 if ($type eq 'sfr') {
125 # A special function register.
127 printf("sfr at 0x%s %s;$rest\n", $value, $name);
128 $addr{"$name"} = "0x$value";
129 } elsif ($type eq 'volatile') {
131 # A location that can change without
132 # direct program manipulation.
134 printf("data at 0x%s volatile char %s;$rest\n", $value, $name);
135 } elsif ($type =~ /^bits/) {
136 ($junk, $register) = split(/\s/, $type);
138 $addr = $addr{"$register"};
139 printf("BIT_AT($addr,$bit) $name;$rest\n");
142 # Other registers, bits and/or configurations.
144 if ($type eq 'other') {
148 printf("#define %-20s 0x%s$rest\n", $name, $value);
151 # A symbol that isn't defined in the data
152 # section at the end of the file. Let's
153 # add a comment so that we can add it later.
155 printf("#define %-20s 0x%s$rest\n",
166 # Anything else we'll just comment out.
175 inc2h.pl - A utility to convert MPASM include files to header files
176 suitable for the SDCC compiler.
178 License: Copyright (c) 2002 Kevin L. Pauba
180 SDCC is licensed under the GNU Public license (GPL) v2; see
181 http://www.gnu.org/copyleft/gpl.html See http://sdcc.sourceforge.net/
182 for the latest information on sdcc.
184 Usage: $programName [file]
188 file A MPASM include file name. If none is supplied, the
189 standard input will be used.
191 The header file will be written to the standard output.
200 alias OPTION_REG OPTION
201 address OPTION_REG 0x0081