├── COPYING ├── LICENSE ├── Makefile ├── README ├── Readme.md ├── doc ├── Makefile ├── fbcc.doc ├── fbcc.md ├── fbcc1.tex ├── fbcc_slides.dvi ├── fbcc_slides.log ├── fbcc_slides.pdf ├── fbcc_slides.ps └── fbcc_slides.tex ├── fbas ├── Makefile ├── dump ├── fbMakefile ├── fbas.y └── fbas_lex.l ├── fbcc ├── Makefile ├── fbMakefile ├── fbcc.c ├── fbcc.h ├── fbconst.c ├── fberror.c ├── fbgen.c ├── fblex.l ├── fblist.c ├── fbobj.c ├── fbparse.y ├── fbsym.c └── fbtype.c ├── fbvm ├── Makefile ├── fbvm.c ├── fbvminstr.h ├── fbvmspec_i386.h └── fbvmspec_sun4.h ├── lib ├── Makefile ├── fblib.c ├── getopt.c ├── getopt.h ├── getopt1.c ├── startup.ss ├── stdarg.h ├── stdio.h ├── stdlib.h └── string.h └── test2 ├── Makefile ├── dijkstra.c ├── test1.c ├── testopt.c └── vm /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 675 Mass Ave, Cambridge, MA 02139, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 19yy 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) 19yy name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Library General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DIRS = fbvm fbcc fbas lib test2 2 | 3 | all: 4 | for i in $(DIRS); \ 5 | do \ 6 | $(MAKE) -C $$i all || exit 1 ; \ 7 | done 8 | 9 | clean: 10 | for i in $(DIRS); \ 11 | do \ 12 | $(MAKE) -C $$i clean || exit 1 ; \ 13 | done 14 | 15 | tar: 16 | tar zcvf fbcc.tar.gz -C .. fbcc/COPYING fbcc/README \ 17 | fbcc/Makefile \ 18 | fbcc/fbcc fbcc/fbas fbcc/fbvm fbcc/lib fbcc/test2 fbcc/doc 19 | 20 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | This is the distribution of FBCC which stands for the "Fabrice Bellard's 3 | C Compiler" :-) 4 | 5 | I have programmed this C compiler as a little project the 'Majeure 6 | Informatique' at the Ecole Polytechnique (in France). It is fairly limited 7 | but is able to completly compile itself, which was my main goal. 8 | 9 | It may be used as a didactic example to show how should be (or should not be 10 | !) programmed a complete compiler. It is given 'as is'. If you want to 11 | improve it, please send me the patches you made. 12 | 13 | Overview : 14 | -------- 15 | 16 | * 'fbcc' takes a preprocessed Ansi C source as input and produces an 17 | assembler source for a stack based virtual machine. 18 | 19 | * 'fbas' assembles and links the assembler sources. The linking is done by 20 | simply concatening all the sources. It generates a binary in pseudo code 21 | for the virtual machine interpreter. 22 | 23 | * 'fbvm' executes the pseudo code. It contains a few predefined functions 24 | for the standard C libraries. 25 | 26 | Files : 27 | ----- 28 | 29 | * fbcc/lib contains the source code for the standard C librairies. Some 30 | sources comes from the Linux kernel, and other from the GNU C library. 31 | 32 | * fbcc/doc contains the slides (in French) I made for the oral exam where I 33 | had to present the project. 34 | 35 | * fbcc/test2 contains some examples for testing fbcc. 36 | 37 | * 'fbMakefile's are used to bootstrap (i.e. to compile fbcc/fbas with 38 | itself). Then you can try to compile the compiled-by-itself FBCC and see 39 | that the two pseudo binaries are the same ! (You can use "make -f 40 | fbMakefile" to use directly this alternate Makefile - be careful to build 41 | before all libraries). 42 | 43 | 44 | Portability : 45 | ----------- 46 | 47 | * Although fbcc and fbas are in ANSI C, the pseudo code they generate is 48 | machine dependant. In particular, the pseudo code is endianess dependant. 49 | The main limitation up to now is that the compiler supposes that pointers 50 | and integers have the same size, which is usually false on the new 64 bits 51 | processors (e.g. the Digital Alpha). 52 | 53 | * I have given two examples of configuration files for Intel and Sparc 54 | platforms. You must make the right symbolic link to fbcc/fbvm/fbvmspec.h 55 | 56 | * FBCC does not implement all the ANSI C standard - It is only a student 57 | project ! You can check in fbcc/doc to see what is not implemented. 58 | 59 | Changes : 60 | ------- 61 | 62 | (26/10/2008) small fixes to make it compile on Recent Linux distributions. 63 | 64 | Notes : 65 | ----- 66 | 67 | * Many comments in the C sources are in French... It was easier for me :) 68 | 69 | * I have used bison and flex - Maybe yacc and lex can work too. 70 | 71 | * Many optimisations should be done - the more obvious and easier should 72 | be constant propagation. 73 | 74 | * Be careful : when an error occurs, the incomplete .s file is not deleted. 75 | You should delete it before lauching make another time. 76 | 77 | * The examples in fbcc/test2 can be launched with the command 'vm 78 | file_name'. 79 | 80 | * Good luck ! 81 | 82 | 83 | Fabrice Bellard (http://bellard.org) 84 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # FBCC: Fabrice Bellard's C Compiler 2 | 3 | This is a modified copy of Fabrice Bellard's C compiler which is available 4 | at [https://bellard.org/fbcc/](https://bellard.org/fbcc/). All I've 5 | done is fix it up so that it runs on Ubuntu 18.04 LTS. 6 | 7 | The compiler no longer compiles itself because of the interesting 8 | type definitions in the headers of current `flex` and/or `bison`. 9 | 10 | I've also translated the French documentation into [English](doc/fbcc.md). 11 | 12 | 13 | ## Original README 14 | 15 | ``` 16 | This is the distribution of FBCC which stands for the "Fabrice Bellard's 17 | C Compiler" :-) 18 | 19 | I have programmed this C compiler as a little project the 'Majeure 20 | Informatique' at the Ecole Polytechnique (in France). It is fairly limited 21 | but is able to completly compile itself, which was my main goal. 22 | 23 | It may be used as a didactic example to show how should be (or should not be 24 | !) programmed a complete compiler. It is given 'as is'. If you want to 25 | improve it, please send me the patches you made. 26 | 27 | Overview : 28 | -------- 29 | 30 | * 'fbcc' takes a preprocessed Ansi C source as input and produces an 31 | assembler source for a stack based virtual machine. 32 | 33 | * 'fbas' assembles and links the assembler sources. The linking is done by 34 | simply concatening all the sources. It generates a binary in pseudo code 35 | for the virtual machine interpreter. 36 | 37 | * 'fbvm' executes the pseudo code. It contains a few predefined functions 38 | for the standard C libraries. 39 | 40 | Files : 41 | ----- 42 | 43 | * fbcc/lib contains the source code for the standard C librairies. Some 44 | sources comes from the Linux kernel, and other from the GNU C library. 45 | 46 | * fbcc/doc contains the slides (in French) I made for the oral exam where I 47 | had to present the project. 48 | 49 | * fbcc/test2 contains some examples for testing fbcc. 50 | 51 | * 'fbMakefile's are used to bootstrap (i.e. to compile fbcc/fbas with 52 | itself). Then you can try to compile the compiled-by-itself FBCC and see 53 | that the two pseudo binaries are the same ! (You can use "make -f 54 | fbMakefile" to use directly this alternate Makefile - be careful to build 55 | before all libraries). 56 | 57 | 58 | Portability : 59 | ----------- 60 | 61 | * Although fbcc and fbas are in ANSI C, the pseudo code they generate is 62 | machine dependant. In particular, the pseudo code is endianess dependant. 63 | The main limitation up to now is that the compiler supposes that pointers 64 | and integers have the same size, which is usually false on the new 64 bits 65 | processors (e.g. the Digital Alpha). 66 | 67 | * I have given two examples of configuration files for Intel and Sparc 68 | platforms. You must make the right symbolic link to fbcc/fbvm/fbvmspec.h 69 | 70 | * FBCC does not implement all the ANSI C standard - It is only a student 71 | project ! You can check in fbcc/doc to see what is not implemented. 72 | 73 | Changes : 74 | ------- 75 | 76 | (26/10/2008) small fixes to make it compile on Recent Linux distributions. 77 | 78 | Notes : 79 | ----- 80 | 81 | * Many comments in the C sources are in French... It was easier for me :) 82 | 83 | * I have used bison and flex - Maybe yacc and lex can work too. 84 | 85 | * Many optimisations should be done - the more obvious and easier should 86 | be constant propagation. 87 | 88 | * Be careful : when an error occurs, the incomplete .s file is not deleted. 89 | You should delete it before lauching make another time. 90 | 91 | * The examples in fbcc/test2 can be launched with the command 'vm 92 | file_name'. 93 | 94 | * Good luck ! 95 | 96 | Fabrice Bellard (http://bellard.org) 97 | ``` 98 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | TEX_FILE = fbcc_slides 2 | 3 | 4 | all: $(TEX_FILE).dvi 5 | 6 | clean: 7 | rm *~ 8 | 9 | $(TEX_FILE).dvi: $(TEX_FILE).tex fbcc1.tex 10 | slitex $(TEX_FILE).tex 11 | rcp $(TEX_FILE).dvi poly:. 12 | 13 | 14 | -------------------------------------------------------------------------------- /doc/fbcc.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/doc/fbcc.doc -------------------------------------------------------------------------------- /doc/fbcc.md: -------------------------------------------------------------------------------- 1 | # Construction of a C Compiler: Fabrice Bellard 2 | 3 | Goal of the project: 4 | make the compiler able to compile itself to demonstrate that the compiler 5 | actually works. 6 | 7 | + The choices 8 | + The global architecture 9 | + The C compiler 10 | + The assembler 11 | + The virtual machine 12 | + The results 13 | 14 | ## The Choices 15 | 16 | We considered the compilation of two types of language: 17 | 18 | + CAML 19 | + C 20 | 21 | We chose C for personal taste and to test the 22 | compiler on a wide range of sources. 23 | 24 | The big choices: 25 | 26 | + No preprocessor: we use `gcc -E` 27 | + No floats 28 | + No error recovery 29 | + Use `flex (lex)` and `bison (yacc)` for the *parser*. 30 | So the compiler must be able to accept the code generated by these 2 31 | utilities. 32 | + Management of separate modules, so a link editing system is 33 | necessary. 34 | + As far as possible, we stay in compliance with *ANSI C*. 35 | + Using a stack machine. Simple, but prevents the evolution of the 36 | compiler. 37 | + On the question of performance, we are dependent on the *hardware*: 38 | pointer size, data alignment, and its *endianness*. 39 | + We finally impose the constraint of depending on a minimum set of 40 | functions in the standard libraries: we recompile part of the code 41 | for `stdlib.h`, `stdio.h`, `stdarg.h` and `string.h`. 42 | 43 | ## General Architecture 44 | 45 | Compiler C (`fbcc`): (4700 lines) 46 | 47 | + *Lexer* 48 | + *Parser* 49 | + Declaration Management 50 | + Data production for static variables 51 | + Typing expressions 52 | + Propagation of constants 53 | + Assembly code generation 54 | 55 | Assembler (`fbas`): tiny (700 lines) 56 | 57 | + *Lexer* - *Parser* 58 | + Management of exported, global, or private symbols 59 | + Generations of a relocatable executable with relocation table 60 | 61 | Virtual Machine (`fbvm`): (900 lines) 62 | 63 | + Loading the executable and relocation 64 | + Emulation of instructions 65 | + Calling some functions of the standard C library thanks to 66 | *traps* 67 | 68 | Libraries (`startup.s`, `fblib.c`): (900 lines) 69 | 70 | + Code for *startup* 71 | + Compile functions `printf` and `stdarg.h` 72 | + Compiling the functions of `string.h` 73 | 74 | 75 | ## The Compiler 76 | 77 | ANSI features not implemented: 78 | 79 | + Types `long`, `float` and `double` 80 | + `const` and `volatile` type qualifiers 81 | + Structure assignments, value passing and structure return 82 | + Characters of type `wchar_t` 83 | + Parsing constants of type `unsigned int` 84 | + Some forms of static initializations 85 | + Some type checks in expressions and control structures. 86 | 87 | Examples of implemented features: 88 | 89 | + Old and new feature prototypes, with `...` 90 | to indicate a function with a number of variable parameters 91 | + Blocks in functions 92 | + Multidimensional tables, `struct`, `union`, `enum`, 93 | pointers on functions 94 | + Complete management of `typedef` 95 | + All control instructions, including `goto` 96 | + Separate symbol tables for `struct` tags 97 | `union`, and `enum`, the structure fields, the labels of `goto` 98 | + Static and Dynamic Initializations Allowed 99 | + Typing fully ANSI compliant for almost all operators 100 | 101 | 102 | ## Implementation Details 103 | 104 | + There is no intermediate representation for code other than 105 | that of expressions. The compiler could be seen as a first step 106 | to an intermediate code generator 107 | + All symbol tables are managed with hash tables 108 | + Virtually all data is stored in lists. This 109 | simplifies memory management and avoids having to manage a large 110 | number of data structures. 111 | + The stack model is the same as the standard C model. We use a 112 | dynamic link and we also save the size of arguments passed in 113 | parameters. 114 | 115 | The syntax of declarations requires the construction of an 116 | intermediate representation for types. We use almost the same 117 | representation for the definitive type. 118 | 119 | ## Types 120 | 121 | ``` 122 | type: == (base_type) 123 | | (TYPE_POINTER) + type 124 | | (TYPE_ARRAY dim) + type 125 | | (TYPE_STRUCT sym) | (TYPE_UNION sym) | (TYPE_ENUM sym) 126 | | (TYPE_FUNC func_type var_list) + type 127 | 128 | base_type: == TYPE_CHAR | TYPE_UCHAR 129 | | TYPE_SHORT | TYPE_USHORT 130 | | TYPE_INT | TYPE_UINT 131 | 132 | func_type: == FUNC_ELLIPSIS | FUNC_OLD | FUNC_NEW 133 | 134 | var_list: == var1 + ... + varN 135 | 136 | var: == ((name) var_storage type var_init) 137 | 138 | var_storage: == STORAGE_DEFAULT | STORAGE_AUTO | STORAGE_REGISTER 139 | | STORAGE_STATIC | STORAGE_EXTERN 140 | 141 | var_init: == (INIT_EXPR expr) | (INIT_LIST var_init1 ... var_initN) 142 | ``` 143 | 144 | ## The Symbol Table 145 | 146 | ``` 147 | var_location: == VAR_STACK | VAR_DATA 148 | 149 | sym_var: == (SYM_VAR var_storage type (var_location var_offset)) 150 | 151 | sym_field_struct: == (offset type) 152 | 153 | sym_typedef: == (SYM_TYPEDEF type) 154 | 155 | sym_struct: == (TYPE_STRUCT -1) / *if not defined */ 156 | | (TYPE_STRUCT symbol_table size align) 157 | 158 | sym_enum_const: == (SYM_ENUM_CONST val) 159 | ``` 160 | 161 | ## Expressions 162 | 163 | ``` 164 | expr: == (type tag expr1 ... exprN) 165 | 166 | expr_ident: == (type EXPR_IDENT sym) 167 | 168 | expr_call: == (type EXPR_CALL expr_func n param1 paramN) 169 | 170 | expr_int: == (type EXPR_INT n) 171 | 172 | expr_str: == (type EXPR_STR str1 ... strN) 173 | 174 | cast_expr: == (type EXPR_CAST expr) 175 | ``` 176 | etc. 177 | 178 | ## The Assembler 179 | 180 | + Generate code and data in 2 segments `.text` and `.data` 181 | + Data: `.byte` *num*, `.short` *num*, `.int` *expr*, 182 | `.align` *num*, `.zero` *num* 183 | + Tags: `.equ` *sym*, *num*, *sym:*, `.globl` *sym* 184 | + Expressions of the form: *sym*, *num*, *sym* + *num* 185 | + Start of a new module: `.module` 186 | 187 | For simplicity, the assembler is used as a linker. A symbol can be external 188 | (not defined at present), global (thanks to the directive `.globl`) or private. 189 | 190 | The `.module` directive clears all private symbols. 191 | 192 | The generated executable contains a relocation table because we want the 193 | pointers of the virtual machine to be compatible with real pointers. 194 | 195 | ## The Virtual Machine 196 | 197 | It is a stack-based machine. The `fbvmspec.h` file gives the relevant information 198 | on the architecture (*endianness*, alignment, size of the base types , 199 | the stack model). It has been assumed that the size of pointers are 200 | the same size as `int`. 201 | 202 | ## The VM Instructions 203 | 204 | ``` 205 | reading mem: ld_b, ld_ub, ld_w, ld_uw, ld_i 206 | mem writing: st_b, st_w, st_i 207 | arithmetic: add_i, sub_i, mul_i, mul_ui, div_i, 208 | div_ui, mod_i, mod_ui, NEG_I 209 | comparisons: cmplt_i, cmple_i, cmpge_i, cmpgt_i, cmpeq_i, 210 | cmpne_i, cmplt_ui, cmple_ui, cmpge_ui, cmpgt_ui 211 | logical: and_i, or_i, xor_i, not_i, 212 | shl_i, SHR_I, shr_ui 213 | conversions: cvt_i_b, cvt_i_ub, cvt_i_w, cvt_i_uw 214 | constants: li_i n, libp_i n 215 | jumps: jeq_i n, jne_i n, switch_i, jmp n 216 | functions: jsr n, rts 217 | stack management: dup, pop, addsp n 218 | system: libcall n 219 | ``` 220 | 221 | ## Conclusion 222 | 223 | + The compiler compiles itself, and the compiled version recompiles itself 224 | giving the same code. The speed is reasonable. To get to this point, it 225 | required not just the working compiler, but also the creation of the 226 | whole compilation and execution environment. 227 | + Types in C are extremely complex. Surprisingly, the compiler for 228 | such a complex langauge can be quite simple. 229 | + The choice of a stack-based virtual machine was not optimal. We did not 230 | think we had the time to generate intermediate code and then assembly code 231 | for a register0based machine. With hindsight, if such a choice 232 | had been done from the beginning, we could have completed this task. 233 | This would have allowed more work on the optimization of the generated code. 234 | + You should rather see this project as an intermediate code generator 235 | for the C language and not as a complete compiler. 236 | -------------------------------------------------------------------------------- /doc/fbcc1.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/doc/fbcc1.tex -------------------------------------------------------------------------------- /doc/fbcc_slides.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/doc/fbcc_slides.dvi -------------------------------------------------------------------------------- /doc/fbcc_slides.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/doc/fbcc_slides.log -------------------------------------------------------------------------------- /doc/fbcc_slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/doc/fbcc_slides.pdf -------------------------------------------------------------------------------- /doc/fbcc_slides.ps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 2 | %%Creator: dvipsk 5.58c Copyright 1986, 1994 Radical Eye Software 3 | %%Title: fbcc_slides.dvi 4 | %%Pages: 13 5 | %%PageOrder: Ascend 6 | %%BoundingBox: 0 0 596 842 7 | %%EndComments 8 | %DVIPSCommandLine: dvips fbcc_slides.dvi -o fbcc_slides.ps 9 | %DVIPSParameters: dpi=300, compressed, comments removed 10 | %DVIPSSource: TeX output 1996.04.10:2145 11 | %%BeginProcSet: texc.pro 12 | /TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N 13 | /X{S N}B /TR{translate}N /isls false N /vsize 11 72 mul N /hsize 8.5 72 14 | mul N /landplus90{false}def /@rigin{isls{[0 landplus90{1 -1}{-1 1} 15 | ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale 16 | isls{landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div 17 | hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul 18 | TR matrix currentmatrix dup dup 4 get round 4 exch put dup dup 5 get 19 | round 5 exch put setmatrix}N /@landscape{/isls true N}B /@manualfeed{ 20 | statusdict /manualfeed true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0 21 | 0]N /FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{/nn 8 dict N nn 22 | begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N string /base X 23 | array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N end dup{/foo 24 | setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{/sf 1 N /fntrx 25 | FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]N df-tail}B /E{ 26 | pop nn dup definefont setfont}B /ch-width{ch-data dup length 5 sub get} 27 | B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{128 ch-data dup 28 | length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub get 127 sub}B 29 | /ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data dup type 30 | /stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N /rc 0 N /gp 31 | 0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup /base get 2 32 | index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 ch-xoff 33 | ch-yoff ch-height sub ch-xoff ch-width add ch-yoff setcachedevice 34 | ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]/id 35 | ch-image N /rw ch-width 7 add 8 idiv string N /rc 0 N /gp 0 N /cp 0 N{ 36 | rc 0 ne{rc 1 sub /rc X rw}{G}ifelse}imagemask restore}B /G{{id gp get 37 | /gp gp 1 add N dup 18 mod S 18 idiv pl S get exec}loop}B /adv{cp add /cp 38 | X}B /chg{rw cp id gp 4 index getinterval putinterval dup gp add /gp X 39 | adv}B /nd{/cp 0 N rw exit}B /lsh{rw cp 2 copy get dup 0 eq{pop 1}{dup 40 | 255 eq{pop 254}{dup dup add 255 and S 1 and or}ifelse}ifelse put 1 adv} 41 | B /rsh{rw cp 2 copy get dup 0 eq{pop 128}{dup 255 eq{pop 127}{dup 2 idiv 42 | S 128 and or}ifelse}ifelse put 1 adv}B /clr{rw cp 2 index string 43 | putinterval adv}B /set{rw cp fillstr 0 4 index getinterval putinterval 44 | adv}B /fillstr 18 string 0 1 17{2 copy 255 put pop}for N /pl[{adv 1 chg} 45 | {adv 1 chg nd}{1 add chg}{1 add chg nd}{adv lsh}{adv lsh nd}{adv rsh}{ 46 | adv rsh nd}{1 add adv}{/rc X nd}{1 add set}{1 add clr}{adv 2 chg}{adv 2 47 | chg nd}{pop nd}]dup{bind pop}forall N /D{/cc X dup type /stringtype ne{] 48 | }if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup 49 | length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{ 50 | cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin 51 | 0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul 52 | add .99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore showpage 53 | userdict /eop-hook known{eop-hook}if}N /@start{userdict /start-hook 54 | known{start-hook}if pop /VResolution X /Resolution X 1000 div /DVImag X 55 | /IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for 56 | 65781.76 div /vsize X 65781.76 div /hsize X}N /p{show}N /RMat[1 0 0 -1 0 57 | 0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V 58 | {}B /RV statusdict begin /product where{pop product dup length 7 ge{0 7 59 | getinterval dup(Display)eq exch 0 4 getinterval(NeXT)eq or}{pop false} 60 | ifelse}{false}ifelse end{{gsave TR -.1 -.1 TR 1 1 scale rulex ruley 61 | false RMat{BDot}imagemask grestore}}{{gsave TR -.1 -.1 TR rulex ruley 62 | scale 1 1 false RMat{BDot}imagemask grestore}}ifelse B /QV{gsave 63 | transform round exch round exch itransform moveto rulex 0 rlineto 0 64 | ruley neg rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta 65 | 0 N /tail{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail} 66 | B /c{-4 M}B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{ 67 | 3 M}B /k{4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p 68 | -1 w}B /q{p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{ 69 | 3 2 roll p a}B /bos{/SS save N}B /eos{SS restore}B end 70 | %%EndProcSet 71 | TeXDict begin 39158280 55380996 1000 300 300 (fbcc_slides.dvi) 72 | @start /Fa 56 125 df<1370EA01F81207EA1FF0EA7FC0EAFF0012FC12700D0876A21E> 73 | 19 D<130C133E137E13FCEA01F8EA03E0EA07C01380120FEA1F00121E123E123C127C12 74 | 78A312F85AA97E1278A3127C123C123E121E121FEA0F80120713C0EA03E0EA01F8EA00FC 75 | 137E133E130C0F2D77A71E>40 D<126012F87E127E7EEA0F80EA07C0120313E0EA01F012 76 | 0013F81378137C133CA3133E131EA9133E133CA3137C137813F813F01201EA03E013C012 77 | 07EA0F80EA3F00127E5A5A12600F2D7BA71E>I<1370A21378A30060133000F0137838FC 78 | 79F8EAFF7F383FFFE06C13C000071300EA01FCEA07FF001F13C04813E038FF7FF8EAFC79 79 | 38F078780060133000001300A31370A215197C9D1E>I<131C133EAA007FB5FCB61280A3 80 | 6C1400D8003EC7FCAA131C191B7E9E1E>I<387FFFFCB512FEA36C13FC17057D931E>45 81 | D<123C127E12FFA4127E123C080875871E>I<141C143EA2147E147C14FC14F8A2130114 82 | F0130314E0130714C0130F1480131F1400A25B133E137E137C13FC5B12015BA212035B12 83 | 075B120F5B121F90C7FC5A123EA2127E127C12FC5AA21270172D7DA71E>I<136013F0A2 84 | 1201A21203120F127F12FF12FE12781200B3A2383FFFC04813E0A26C13C013237BA21E> 85 | 49 D<123C127E12FFA4127E123C1200A9123C127E12FFA4127E123C081975981E>58 86 | D<383FFFFE487FB61280A26C1400C9FCA5007FB5FCB61280A26C14006C5B190F7E981E> 87 | 61 D<133EA2137FA21377A2EBF780A313E3A200017FA43803C1E0A400077F1380A213FF 88 | A2487FA2EB0078A248137C001E133CA2387F80FFD8FFC11380A2D87F80130019237EA21E 89 | >65 D67 D<387FFF80B512E0806C7F381E01FCEB00 92 | 7E143E808015801407A3EC03C0A914071580A2140F15005C143E147E495A387FFFF8B55A 93 | 5C6C13801A237FA21E>I<007FB51280B612C0A27E380F0003A4EC018091C7FCA314C049 94 | 7EA213FFA41301A26D5A91C7FCA315C0EC01E0A5007FB5FCB6FCA26C14C01B237FA21E> 95 | I<007FB5FCB61280A27E380F0007A4EC030091C7FCA314C0497EA213FFA41301A26D5A91 96 | C7FCA9EA7FF0487EA26C5A19237EA21E>II<397FE0FFC0D8FFF113E0A2D87FE013C0390F001E00ABEBFFFEA4EB 100 | 001EAC397FE0FFC0D8FFF113E0A2D87FE013C01B237FA21E>I<387FFFE0B512F0A26C13 101 | E03800F000B3A9387FFFE0B512F0A26C13E014237BA21E>I<397F807F8039FFC0FFC0A2 102 | 397F807F80391E003C00147C5C495A495A5C1307495A49C7FC133E133C137E13FEEA1FFF 103 | 13EFEBCF8013C7EB87C0EB03E0EA1E01801300801478147C143C143E397F803F8039FFC0 104 | 7FC0A2397F803F801A237FA21E>75 DI<397F803FC000FF14E0EBC07F007F14C0001EEB 106 | 6F00EBE0EFA413F1A2EB71CFA3137BA2EB3B8FA3EB1F0FA3130E1300A8397F803FC039FF 107 | C07FE0A2397F803FC01B237FA21E>I<397FC0FFC0D8FFC113E013E1D87FE013C0390F60 108 | 1E001370A313781338A2133CA2131CA2131EA2130E130FA21307A2149EA21303A214DE13 109 | 01A31300387FE0FEEAFFF0147E387FE07C1B237FA21E>I<3807FFC0001F13F04813F848 110 | 13FCEA7E00007C137C0078133C00F8133E48131EB26C133EA20078133C007C137C007E13 111 | FCEA7FFF6C13F86C13F0000713C017237DA21E>I<387FFFE0B512F8806C7F380F007FEC 112 | 1F80140FEC07C01403A51407EC0F80141FEC7F00EBFFFE5C5C14E090C8FCAAEA7FE0487E 113 | A26C5A1A237FA21E>I82 D<3801FE183807FFBC001F13FC5AEA7F03EA7C0048137C5A143CA214 116 | 186C13001278127EEA3FE0EA1FFE380FFFC0000313E038003FF0EB03F8EB007C143C143E 117 | 141E126012F0A2143E6C133C6C137C38FF01F8EBFFF014E000F713C00061130017237DA2 118 | 1E>I<007FB512C0B612E0A338F00F01A40060EB00C000001400B3A4EBFFF0487FA26C5B 119 | 1B237FA21E>I<397FE03FF039FFF07FF8A2397FE03FF0390F000780B3A4EB800F000714 120 | 006D5A0003131EEBF07E6CB45A6C5B6D5AEB1FC01D2380A21E>I<397F803FC039FFC07F 121 | E0A2397F803FC0391E000F006C131EA46C6C5AA46C6C5AA46C6C5AA400005B13F1A3EB71 122 | C0A2137BA2EB3B80A2133FA26DC7FCA21B237FA21E>I<007FEB1FC039FF803FE0A2397F 123 | 001FC0003CEB0780A76CEB0F00A3131FEB3F8FA3EB7BCFA2000E13CEA31371A2000F13DE 124 | A3380760DCA3EBE0FCA2EBC07C000313781B237FA21E>I<387FC3FE38FFE7FFA2387FC3 125 | FE380F80F0380781E013C13803C3C013E3EA01E7EBF780EA00FF91C7FC7F137E133E133C 126 | 133E137E137F5BEBF780EA01E7EBE3C0EA03C3EBC1E01207EB80F0120FEB00785A387F80 127 | FFD8FFC11380A2D87F80130019237EA21E>I<397FC03FC039FFE07FE0A2397FC03FC039 128 | 0F001E00EB803E0007133C13C000035B13E0000113F86D5A1200EBF1E013795C133B133F 129 | 6D5AA26DC7FCABEB7FE0497EA26D5A1B237FA21E>I<387FFFFCB512FEA36C13FC17057D 130 | 7E1E>95 D97 D<127F487EA2127F1207A6EB8FE0EBBFF8EBFFFC80EBF83F9038E00F8090 133 | 38C007C01403138015E01401A5EBC00315C0A2EBE0079038F00F809038F83F00EBFFFE5C 134 | EB9FF838030FE01B2380A21E>III<13FE3803FF804813C04813E0381F83F0383E00F84813 139 | 780078137C143C12F8B512FCA314F800F0C7FC7E1278007C1318003C133C123F381FC0FC 140 | 380FFFF86C13F0000113E038007F8016197D981E>III<136013F0487EA26C5A136090C7FCA5EA3FF0487EA2123FEA0078B1 146 | 387FFFF0B512F8A26C13F015247CA31E>105 D108 D<387C7C1F39FEFE3F80B5EA7FC06C13FF391FCF 148 | F3E0EB87E1EB07C1A2001E1381AD397F87E1F839FFCFF3FCA2397F87E1F81E1980981E> 149 | I<387F07F038FF9FF8EBFFFC6C7F3807FC1FEBF00F13E013C0A21380AC397FF87FF039FF 150 | FCFFF8A2397FF87FF01D1980981E>I<13FE3803FF804813C04813E0381F83F0383E00F8 151 | 48137C0078133CA248131EA66C133E0078133C007C137CA26C13F8381F83F0380FFFE06C 152 | 13C06C13803800FE0017197D981E>I<387F0FE038FFBFF8EBFFFC6C7F3807F83F9038E0 153 | 0F809038C007C01403138015E01401A5EBC00315C0A2EBE0079038F00F809038F83F00EB 154 | FFFE5CEB9FF8EB8FE00180C7FCA9EA7FF8487EA26C5A1B2680981E>I<387FC07F39FFE1 155 | FF8001E713C0EA7FEF3801FFC7EC038001FCC7FC5BA25BA25BAA387FFFC0B57EA26C5B1A 156 | 197F981E>114 D<3803FEC0381FFFE05A5AEAFE03EAF001A2EB00C06C1300EA7F80EA3F 157 | FC381FFF806C13C0C613E0EB07F0386000F800F01378A27E6C13F838FF03F0EBFFE014C0 158 | 00F713803861FE0015197C981E>I<13C0487EA6387FFFFCB512FEA26C13FC3801E000AB 159 | 1406140FA3EBF01F3800F83EEBFFFCEB7FF8EB3FF0EB0FE018207F9F1E>I<007F13FE38 160 | FF81FFA2EA7F800007130FAE5CA2EBC07F6CB512F06C14F87E90387FC7F01D1980981E> 161 | I<397FE0FFC0D8FFF113E0A2D87FE013C0390F803E000007133CA2EBC07C00031378A36C 162 | 6C5AA33800F1E0A4EB7BC0A3EB3F80A36DC7FC1B197F981E>I<387FC3FE38FFE7FFA238 163 | 7FC3FE3807C1F03803C3E0EBE3C03801F780EA00FF6DC7FC137E133EA2137E137FEBF780 164 | EA01E7EBE3C03803C1E000077F1380387FC1FFD8FFE31380A2D87FC1130019197E981E> 165 | 120 D<397FC1FF80D8FFE313C0A2D87FC11380390F007C001478138012075CEA03C0A2EB 166 | C1E0EA01E1A25CEA00F3A3EB7380A2137B013FC7FCA27F131EA35BA3EA787CEAFC7813F8 167 | EAF1F0B45A6C5A5B001EC8FC1A267E981E>I<383FFFFE4813FFA33878003E147C14F838 168 | 3001F0380003E0EB07C0EB1F80EB3F00137E5B485AEA03E0485A380F8006381F000F123E 169 | 5AB6FCA36C13FE18197E981E>I<127012F8B3B3A71270052D74A71E>124 170 | D E /Fb 1 59 df<123C127E12FFA4127E123C08087A8714>58 D 171 | E /Fc 2 104 df102 D<127CEAFFC0EA07F0EA01F8EA007C7FA27FB3A46D7E13076D 174 | 7EEB01F0903800FF80EC3FC0ECFF80903801F000EB03C0495A130F49C7FCB3A4133EA25B 175 | 485AEA07F0EAFFC0007CC8FC1A457BB325>I E /Fd 24 122 df40 178 | D<12E07E12787E7E7E1380EA07C0120313E0EA01F0A2EA00F8A2137CA3133EA4131E131F 179 | AC131E133EA4137CA313F8A2EA01F0A2EA03E013C01207EA0F801300121E5A5A5A5A1038 180 | 7BAB1C>I48 D<143E147F5CEB01DF1303A2EB 183 | 079F130FEB1F1F131E133E137CA213F8EA01F0120313E0EA07C0EA0F80121F1300123E12 184 | 7E5AB612FC15FEA26C14FCC7EA1F00A9140E1F267EA524>52 D<007FB512F0B612F8A26C 185 | 14F0C7EA07E0EC0FC0EC1F801500143E5C5C13015C495AA2495A130F5CA249C7FCA25B13 186 | 3EA2137E137CA413FC5BA713701D267DA524>55 D57 190 | D<127C12FCA51200B212FCA5127C061E799D14>I<007FB61280B712C0A2168000F8C9FC 191 | ADB612FE81A25D00F8C9FCAEB712C016E0A26C15C023277AA62D>69 192 | D<007FB712E0B812F0A26C16E0C7D80F80C7FCB3B06EC8FC2C277DA633>84 193 | D97 D<127012F8A9EB1FC0EB7FF038F9FFF800FB7F38FF80FE38 196 | FE003F48EB1F8048130FEC07C0A3EC03E0A8EC07C0A2140F6C1480EC1F006C5B38FF81FE 197 | 38FBFFFC00F913F000F85B38703F801B287BA724>I100 200 | DI<90383F81C09038FFE3E04813F3000713FB380F 203 | F03F381FC00F1300003E1307127E007C1303A25AA76C1307127CA26C130F123F381F801F 204 | 380FE07B3807FFF36C13E36C13C338003F031300A215C0140715800010130F003FEB3F00 205 | EBFFFE6C5B6C13F0C613C01B287D9D24>103 D<127812FCA412781200A51238127CB3AA 206 | 123806297CA810>105 D<127012F8B3B3A2127005287BA710>108 207 | D<26700FE013FE3BF83FF803FF809026FFFC0F13C000F96D4813E03BFBC07F3C07F03AFF 208 | 001F70014802E013F84890380FC000A2485CB3A200706DC712702D1E7B9D38>I<38700F 209 | E038F83FF8EBFFFC00F97F38FBC07F38FF001F48148048130FA25AB3A20070EB0700191E 210 | 7B9D24>II<38701FC038F87FF038F9FFF800FB7F38FF 213 | 81FE38FE003F48EB1F8048130F15C01407A2EC03E0A8EC07C0A2140F6C1480EC1F006C13 214 | 7F38FF81FE38FBFFFC00F913F000F85BEB3F8090C8FCA712701B267B9D24>I<38700780 215 | EAF81F137F13FF38F9F800EAFBC0B45A90C7FC5A5AA35AB11270111E7B9D18>114 216 | D<48B4FC000F13E04813F85AEA7E00007C1310481300A47EEA7F80EA3FFC381FFF806C13 217 | E06C13F0C613F8EB07FC1300147E143EA3124000F0137C38FE01FCB512F8003F13F0000F 218 | 13C000011300171E7E9D1B>I<007CEB01E0007E1303003E1307003FEB0FC0391F801F80 219 | D80FC013003807E03E3803F07E00015B3800F9F8EBFDF0EB7FE06D5A131F6D5A131F497E 220 | 497EEB7DF0EBF8F83801F07C3803E07E00077F48487E9038800F80391F0007C04814E000 221 | 7EEB03F048EB01F80078EB00F01D1E7F9D20>120 D<00F0EB01E06C1303A27E007CEB07 222 | C0127E003EEB0F80A27EEC1F001380000F133EA2EA07C05CEA03E0147814F8EA01F05CEA 223 | 00F113F95C1379EB7BC0133FA26D5AA291C7FCA3131E137EEA7FFC485A13E0EA7F801B26 224 | 7E9D20>I E /Fe 23 122 df19 D65 229 | D67 D<90381FFFF04913F85B15F06D13E0903800FC00A21301 233 | 5CA313035CA413075CA4130F5CA3131F5CA4133F91C7FCA45B137EA313FE5BA2383FFFE0 234 | 487FB5FC5C6C5B1D2F7FAE16>73 D<131E133F5B137EA413FE5BA312015BA412035BA412 235 | 075BA3120F5BA4121F5BA4123F90C9FCA35A127EA2007FB612F016F8B7FC16F06C15E025 236 | 2F78AE31>76 D78 240 | D<011FB512F04914FE49ECFF8017E017F0017EC7EA3FF8EE07FC01FE140149EC00FE177E 241 | A2120149153E177EA3000316FC5BEE01F8EE03F0EE0FE00007ED3FC049903801FF8090B6 242 | EAFE005E4815E093C7FC01C0C9FCA3121F5BA4123F90CAFCA35A127EA412FE5A12782F2F 243 | 78AE36>80 D<913801FFE0020F13FE027FEBFF8049B612E05B903907FE007FD90FF0EB07 244 | C0D91FC0130149C81280017E15005BA3485AA27FA26C7E6D7EEB7FE014FF6D13F8010F13 245 | FF6D14C0010180D9003F7F02017F9138001FFCED03FE1500167FA282A4167EA200205D12 246 | 70007CEC03F8007F4A5AD8FFC0EB1FE0D87FFCEBFFC06CB65A000F4AC7FC000314F8C614 247 | E0D907FEC8FC2B317BAF30>83 D97 D<1638167CA216FC16F8A4150116F0A3EC7F03903903FFC3E0010F 251 | 13E34913F390387FC07B9038FE001FD801F814C04848130F485A4913074848130F48C713 252 | 80A2123E151F16005AA35D48143EA4007C147E157C15FCA26C1301003FEB07F8381F800E 253 | 380FE03C3807FFF86C13F16CEBC1F06C6CC65A263079AF2B>100 254 | DI<131C13 257 | 3EA2137E137CA413FC5BA30001EB0FF09038F03FFCECFFFE01F17F9039F3C03F803903F7 258 | 000F01EE14C013F8491307A24848EB0F80A25BA2000F141F491400A4001F5C90C7123EA4 259 | 48147E003E147CA3007E14FC007C5CA400FC1301485C00706D5A223079AF2B>104 260 | D<137C13FEA5137C1300A613E0EA01F0A4120313E0A4120713C0A3120F1380A4121F1300 261 | A45A123EA3127E127CA412FC5A12700F3179B014>I<9026E007F8EB07F82701F03FFEEB 262 | 3FFE91B590B5FC01F102811480903CF3E01FC3E01FC03C03F70007C7000701EE02EE14E0 263 | 01F814F803031403495C48484948EB07C0A2495CA2000F020F140F494A1480A4001F021F 264 | 141F90C790C71300A4484A5C003E023E143EA3007E027E147E007C027C147CA400FC02FC 265 | 14FC484A5C0070027014703B2479A344>109 D<9038E00FF03901F03FFCECFFFE01F17F 266 | 9039F3C03F803903F7000F01EE14C013F8491307A24848EB0F80A25BA2000F141F491400 267 | A4001F5C90C7123EA448147E003E147CA3007E14FC007C5CA400FC1301485C00706D5A22 268 | 2479A32B>I<90383803F890387C1FFEEC7FFF91B5128090397DF03FC09039FF800FE091 269 | 380003F013FC15014914F8000114005BA312035BA40007EC01F05BA2ED03E0A2000FEC07 270 | C049130F6D1480ED1F00001F147E6D5B90386003F89038781FF090383FFFE0486C138026 271 | 3E0FFEC7FCEB03F890C9FCA2127E127CA412FC5A1270252E7BA32B>112 272 | D<9038E001E03801F00F143F147F9038F1FFC03903F3FC00EBE7E0EBEF8001FEC7FC5B48 273 | 5A5B5BA2485AA25BA3121F90C8FCA45A123EA3127E127CA412FC5A12701B2479A31D> 274 | 114 DI<1338137CA513FC5BA3387FFFFEB6FCA26C13FE3801F000485AA5485AA5485AA5 278 | 48C7FCA4123EA51440EB01C0EB0FE0383FFFC01480381FFE00EA07E0182E77AD1F>II<007002F8147000F8010115F84A6CEB01F0A20207EC03E06C 282 | 14BC007CD90F3CEB07C0170F021E1580EF1F00143C173EEC783E5F14F0007E5E383E01E0 283 | 4C5A903803C01E4C5AEB07804C5A90380F001F4C5A011E92C7FCD81E1C5C013C141E0138 284 | 143E0178EB0F3C0170147C01F01478D81FE014F85E5B000F5D496D5A352477A339>119 285 | D<01F0141F486C143F6C6C147E16FC017EEB01F06DEB03E0ED07C090391F800F80010FEB 286 | 1F00903807C03E6E5A903803E1F8903801F3F0ECFFE06D5B6E5A92C7FC143E147E14FF90 287 | 3801EF80EB03CF90380F87C090381F03E0133E496C7E01F87F3801F0004848137C484813 288 | 7E4848133E48C7123F003EEC1F8048140F4815C048EC078028247EA326>I<0178EC0380 289 | 01F814076D140F017CEC1F00A2163E017E5CA2013E5CA24B5A013F495A7F4B5A150F5E6E 290 | 48C7FC130F153E5DA26D6C5AA2ECC1F05D14C3903803C7C0ECE78014EF92C8FC130114FE 291 | 5CA25C6D5A13015C13035C495AD8601FC9FCEA7FFE5BEAFFF0EA7FC0292E7FA326>I 292 | E /Ff 35 123 df<131C137EEA03FE120FEA3FFCEA7FF0EAFFC0EA7F0012780F0973A925 293 | >19 D40 D<127012FC7E127F6C7EEA0FC0 296 | 6C7E6C7E6C7E6C7E137C137E133E133F7F1480130F14C01307A314E01303AA130714C0A3 297 | 130F1480131F14005B133E137E137C13FC485A485A485A485AEA3F8048C7FC12FE5A1270 298 | 13367AAF25>I43 D<121FEA3F80EA7FC0A213E0A3123F121F1203120713C0120FEA1F80127FEAFF 300 | 005A12F812700B13738825>I<007FB512E0B612F0A46C14E01C067C9725>I<123E127FEA 301 | FF80A5EA7F00123E0909728825>I<123E127FEAFF80A5EA7F00123EC7FCAC123E127FEA 302 | FF80A5EA7F00123E091E729D25>58 D<007FB512FCB67EA37E3907C0003EA5151C92C7FC 303 | A3141C143EA3EBFFFEA5EBC03EA3141C91C8FCA21507ED0F80A7007FB6FCB7FCA36C1500 304 | 212A7EA925>69 D<007FB512E0B612F0A46C14E01C067C7E25>95 305 | D<3807FF80001F13E04813F8487F80EB00FF143F003EEB1F80C7120FA3EB0FFF90B5FC12 306 | 075A383FFE0FEA7FC0EA7E005A5AA36C131F007E133F387F81FF6CB512FE6C14FF6C13F7 307 | 6C13C33901FE01FE201E7C9D25>97 DIIIII<90381F80FE90387FE3FF48B612805A5A01F0EB0F 320 | 00390FC03F06496CC7FC001F80EB000FA5EB801F000F91C7FC6D5A3807F0FE13FF5C485B 321 | EB7FE0EB1F8090C9FCA213A03807FFFEECFFC04814F04880393F0003FC007CEB007E0078 322 | 141E00F8141F4880A36C5C007C143E007F14FE393FE007FC6CB55A6C5C6C5C0001148026 323 | 001FF8C7FC212E7E9D25>II<131C133E137FA3133E131C90C8FCA6EA3FFE487EA37EEA001FB3A2007FB512 326 | 80B612C0A36C14801A2B7AAA25>I<147014F8EB01FCA3EB00F814701400A63801FFF848 327 | 13FCA37EC7127CB3AD003813FC007C13F8EAFE01EB07F0B512E014C06C13806C1300EA0F 328 | FC163A7DAA25>I108 D<397E1F01F039FF7F87F89038FFCFFCECFFFE7E390FE1FE1F9038C0FC0FEB80 330 | F8A3EB00F0AF3A7FE1FE1FE03AFFF3FF3FF0A33A7FE1FE1FE0241E809D25>I<387FC07F 331 | 39FFE3FFC001E77F01EF7F6CB57E000313819038FC00FC49137C5BA25BAF3A7FFF07FFE0 332 | B5008F13F0A36C010713E0241E809D25>II<387FC0 335 | 7F39FFE3FFE001E77F90B57E6C800003EB83FE9038FC007F497F49EB1F80150F5B16C015 336 | 07A6150F6D1480151F7F6DEB3F006D13FEEBFF83ECFFFC01EF5B01E75B01E313C001E090 337 | C7FC91C8FCAAEA7FFFB57EA36C90C8FC222D809D25>I<90383FC0E09038FFF1F0000313 338 | F94813FD4813FF381FF07FEBC01F383F0007127E1403127C00FC13015AA67E007C1303A2 339 | 007E13076C130FEB801F381FE07F6CB5FC6C13FD6C13F96C13E138003F81EB0001AA9138 340 | 3FFF804A13C0A36E1380222D7D9D25>I<397FF007F839FFF83FFCEC7FFE91B5FCEA7FFB 341 | 3900FFFC3FECE01EECC00091C7FCA25B5BA35BAB387FFFFCB57EA36C5B201E7E9D25>I< 342 | 3801FFC6000713FF121F5A5A48C67E00FC131F5AA2140E00FE90C7FCEA7FC06CB4FC6C13 343 | F0000713FCC67FEB07FF9038003F800070EB0FC000F81307A27EA26C130F39FFC07F8090 344 | B5FC15005C00F313F838607FC01A1E7B9D25>I<137013F8A7007FB512C0B612E0A36C14 345 | C0D800F8C7FCAD157015F8A3EBFC0115F0EB7F07ECFFE06D13C06D13806D1300EB03F81D 346 | 267EA525>I<397FC00FF8486C487EA3007F130F0003EB007CB115FC1401EBF80F6CB612 347 | E016F07E90387FFE7F90391FF03FE0241E809D25>I<397FF00FFE39FFF81FFFA3397FF0 348 | 0FFE39078001E0A2EBC003000314C0A2EBE00700011480A2EBF00F00001400A26D5AEB78 349 | 1EA26D5AA36D5AA36D5AA36D5A6D5A201E7E9D25>I<3A7FF807FF80486C4813C0A36C48 350 | 6C1380000FC7EA3C00A47F00075CA2EB81F0EB83F8A2D803C3137001C713F014BCA313CF 351 | 00015C141E13EFA2EBFF1F13FE00006D5AA290387C0780221E7F9D25>I<397FF81FFC39 352 | FFFC3FFEA3397FF81FFC3901F00F80EC1F003800F81EEB7C3CEB3E7CEB1EF8EB1FF06D5A 353 | 13076D5A497E130F80EB1E78EB3C7CEB7C3EEB781E497ED801E013800003EB07C0397FF0 354 | 0FFE39FFF81FFFA3397FF00FFE201E7E9D25>I<397FF00FFE39FFF81FFFA3397FF00FFE 355 | 39078001E013C00003130315C0EA01E0140701F013801200140F01781300A2EB7C1FEB3C 356 | 1EA26D5AA3EB0F38147813075CA213035CA21301495AA213075CA2EA3E0F007F90C7FC5B 357 | EA7C7EEA7FFCA26C5AEA1FE06C5A202D7E9D25>I<003FB512F84814FCA315F8397C0003 358 | F0EC07E0EC0FC0EC1F800038EB7F00C712FE495A495A495A495A495A495A49C7FC13FE48 359 | 5A4848131CD807E0133E485A485A48C7FC48B512FEB6FCA36C14FC1F1E7E9D25>I 360 | E /Fg 31 121 df<903803FFF05B131F017F13803901FFFE004813F0000F13C0D83FFEC7 361 | FCEA7FF8EAFFC06CC8FC1C0B64C444>19 D39 D<007FB612E0B712F0A66C15E024087F9E2D 363 | >45 D<153E15FF5C1407141F49B5FC133F007FB6FCB7FCA580EA7FE0C7FCB3B3AB001FB7 364 | 12FC4816FE4816FFA46C16FE6C16FC304676C544>49 DI<91380FFF8091B5 370 | 12F8010714FF011F15C0017F15F048B712FC00078248D9F8017F489026C0007F1380007F 371 | 90C7001F13C013FC6C486E13E06C48806C4816F06C5A6C5A6CC8FCC9FCA25E18E0A24C13 372 | C05E4C138093B5FC4B140003075B037F5B91B65A17E05F94C7FC16FCEEFF8017E017F8DA 373 | 000313FE9238007FFF701380040F13E07013F0A27013F8A218FC8218FEA700204B13FC12 374 | 78007C17F8007E5DB46C16F001E05C01F84A13E001FF027F13C0003FD9F003B512806C90 375 | B7120000075E6C16F8C65E013F15C0010792C7FC010114F8D9000F90C8FC37477AC544> 376 | I<923803FFFC4B7FA25D5DA25D5DA292B5FC5C16DF4A139F5C161FEC0FFE141F15FCEC3F 377 | F8147F15F0ECFFE05B4913C015805B4913005C131F495A5C137F495A5C5A485B5C5A4890 378 | C7FC5B121F485A5B127F485A90B912C019E0A66C18C0C9D81FFEC7FCAF705A3B457CC444 379 | >I<90B812E04817F05AA518E002F0C9FCB1ED7FF09138F7FFFE91B612C017F017FC8383 380 | 1880DB803F13C09126FC000F13E002F06D13F002C06D13F84A7F6C17FC6C90C7FC90C913 381 | FEA318FFA818FE1206000E5D001F17FC487E486C4A13F813F0486C4A13F001FE021F13E0 382 | 263FFF804913C06CD9F801B512806C90B712006C5E000116F86C6C5D011F15C001074AC7 383 | FC010014F8020F90C8FC38467CC444>I<923803FFFE030F6D7EA24B80A24B80A24B80A2 384 | 92B67EA34A81A24A8116FB4A01F37F16F14A01E18016E05E4A6E7F16804A82834A010080 385 | 835D02FF6E7F5D496F7F5D498383494981835D496F805D498484494982844990C8808492 386 | B8FC90BA7EA24885A24885A34885A24801E0C80001148084484918C085484918E08591CA 387 | FC487213F05B00FF1AF8854983D87FF07113F04D447BC358>65 D<0403B5FC93B612FE03 388 | 07EDFFE0033F16FE4AB8FC1407141F027F17FC91B6EA000F010302E01300490280143F49 389 | 49C8120F4901F815034901E0ED01F84949150090B54816784891CA1238484917005C485B 390 | 485BA2485BA2485BA2485BA4B5CCFCAA6C7FA46C7FA26C7FA26C7FA26C7F6C7F806C6D17 391 | 066C6E161E6D6D163E6D6D167E6D01F8ED01FE6D01FE15036D6D6CEC0FFF6D02E0143F01 392 | 0002FF0107B5FC6E91B7FC141F1407020117F8DA003F16E003071600030015F8040349C7 393 | FC484679C457>67 D<933807FFFC93B612F0030F15FE037FEDFFC04AB812F8020717FF14 394 | 1F147F91B538FE001F010302E001015B4991C8123F4901FC151F494915074901E0150349 395 | 49150190B548ED007C4891CA123C485B4849171C4A94C7FC485BA2485BA2485BA2485BA3 396 | 0503B61280B5C85AA794C7121FA36C7FA46C7FA26C7FA26C7FA26C7F806C7F6C7F6C806D 397 | 7F6D7F6D13F86D7F6D13FF6D02E091B5FC010002FE131F6E90B8FC141F14070201EFFC00 398 | 6E6C16E0030F93C7FC030015E0040701F8C8FC494678C45B>71 D76 D<263FFF8095B5FC486D4D1480B56C5F 400 | 6E5FA26E5FA26E5FA26E5FA26E5FA201F76DEEFFF7A201F36D4B13E7A301F16D4B13C7A2 401 | 01F06D4B1387A26E6C4B1307A26E6CED1FFEA26E6CED3FFCA26E6CED7FF8A26E6DECFFF0 402 | A26E6D4913E0A26E6D4913C0A26E6D491380A26F6C491300A26F6C495AA26F6C495AA26F 403 | 6C495AA26F6D485AA26F01C15BA36F01E35BA26F01F75BA270B5C7FCA2705BA2705BA270 404 | 5BA2705BA2705B007F030013806C4892C96C1300594475C370>I<003FB712F048EEFF80 405 | B912F818FF19C019F019FC85F1FF801AC091C8000F14E0DD007F13F0181F7213F87213FC 406 | 84841AFEA284A260A21AFC604E13F8604E13F095B512E0050F14C091B912006119F819E0 407 | 198006FCC7FC18C0A291C7121F84707F707F707F8284707F717F717F8385717F717F717F 408 | 8385717F7213807213C0A27213E07213F07213F87213FCA27213FE7213FF6C846C48EF3F 409 | FE484476C359>82 D86 D<91380FFF8049B512F8010F14FF013F15 414 | C090B77E000316F8488203837FDAE0007F91C7123F6C486E138013F8496E13C013C0496E 415 | 13E06CC8FCC9FCA6037FB5FC020FB6FC91B7FC1307011F1487017FEBE00748B512000007 416 | 13F8485B4813C0485B91C7FC485AA2485AA66D5C007F5D6D5C6E5B6C6D48B5FCECF00F6C 417 | 90B512F76C15E76C15C76C15876CECFE076C14F8013FD9C00313C0D907FEC9FC33387CB6 418 | 40>97 DI< 422 | EDFFF8020FEBFFC0027F14F849B612FE0107EDFFC05B5B137F90B5D8800F1380489038FC 423 | 00014AEB003F4849141F484914074849EC03004A91C7FC4890CAFCA25A5BA2127FA25B12 424 | FFAA127F7FA3123F7F7E18C06C6D14036E14076C6D140F6E143F6C6DEC7FE06C6DEB03FF 425 | 6C9038FF803F6D90B6FC6D16C0010F16806DEDFE00010115F86D6C14E0020F91C7FC0201 426 | 13E033387BB63D>I<913801FFE0021F13FC027FEBFF8049B612E00107814981013F8149 427 | 8190B500807F489026FE001F13804801F86D13C04A7F48496D13E0485B4A7F4817F091C8 428 | FC5A4916F8127FA290B8FCA2B9FCA318F001FCCAFCA6127FA27FA2123F7F7E6E15306C6D 429 | 15F06E14016C16036C01F8140F6C6DEC3FF86C01FF14FF6DEBE00F6D90B6FC6D16F06D16 430 | E0010316800100EDFE00023F14F0020F1480020001F8C7FC35387CB63E>101 431 | D104 DI108 435 | DIIII114 451 | DIII120 465 | D E /Fh 40 121 df11 D19 D24 D<12FFA8121E123EA2123C127CA21278A212F812F0A2 470 | 081376B81D>39 D<007FB51280B612C0A36C14801A057F9722>45 471 | D<12FFA7127F080876871D>I<14E0497E1307130F133FEA3FFFB5FCA313C7EA0007B3B3 472 | A5007FB6FCA2B712806C1500A2213876B734>49 D<903801FFC0010F13FC017F13FF90B6 473 | 12C048814848C67FD807F0EB1FF8D80FC0EB07FC4848EB01FE48C87E82007E1680163F48 474 | 16C0127C12380018151F1208C9FC163FA21780A2167F17005E5E4B5A4B5A4B5A4B5A4B5A 475 | 4B5A4BC7FC15FEEC03FCEC07F04A5A4A5A027FC8FC14FE495AEB03F0495AEB1FC0495A01 476 | 7EC9FC5B485A485AEA0FC048B712804816C05AA26C16802A387CB734>III<0007B612FC825AA25E01E0C9FCAFEC7FE09038 485 | E3FFFC90B6FC16C0829138801FF09039FC0007F8496D7E01E06D7E6C486D7E4980C91380 486 | A2163F17C0A8EE7F8012100030160000785D00FE4A5A6C5DD87FC0EB07F8D81FF0EB1FF0 487 | D80FFEEBFFE06CB65A00015D6C6C49C7FC011F13F8010113802A387CB634>II<127F12FFA71200B3A912FFA7127F082B76 493 | AA1D>58 D<007FB512FEB712E016FC16FF17C090C7000F13F003007FEE1FFCEE07FE1601 494 | 707E831880A2173F177FA218005F4C5A1603EE0FFCEE3FF04BB45A031F138090B648C7FC 495 | 16F8A216FF17C090C7000313F09238003FFCEE07FEEE01FF701380EF7FC0EF3FE0171FEF 496 | 0FF0A618E0171F173FEF7FC0933801FF8004071300EE3FFE923803FFFC90B712F05F94C7 497 | FC16FC6C1580343977B844>66 D<92381FFF800203B512FC020FECFF80027F15F091B7FC 498 | 0103EBF001010F90C7121FD91FFCEC07E0D93FF01401D97FC0EC0060494815004890CAFC 499 | 485A485A5B485A121F5B123F5BA2485AA348CBFCAB6C7EA36C7EA27F121F7F120F6C7E7F 500 | 6C7E6C7E6C6D15186D6C1538D93FF015F8D91FFC14036DB4140F010301F013FF010090B6 501 | 12E06E1580020FECFE00020314F0DA001F90C7FC353B79B942>I<007FB712FCB812FEA3 502 | 17FC90CAFCB3A390B712C017E0A317C090CAFCB3A7127E2F3977B83D>70 503 | D<127EB4FCB3B3AF90B712F017F8A36C16F02D3977B83B>76 D<007FB6FCB712F016FE70 504 | 7E17E090C7000113F89238001FFCEE03FEEE00FFEF7F80EF3FC0A2EF1FE0A7EF3FC0A2EF 505 | 7F80EFFF00EE03FEEE1FFC4BB45A90B712E017804CC7FC16F0168090C7EA3FC06F7E150F 506 | 826F7E6F7E6F7E150082707E707E707EA2707E707E707E160183707EEF7F80EF3FC0A2EF 507 | 1FE0EF0FF01707007E1603343977B843>82 D97 D<127C12FEAC14FF010313E0010F7F4913FC497F90387C07FFD9F0001380D8FF 512 | C0EB3FC049EB1FE090C7120FED07F05AED03F8A2ED01FCA3ED00FEAA16FC1501A3ED03F8 513 | A2ED07F07EED0FE06DEB1FC06DEB7F809039E001FF0039FEF80FFE90387FFFFC6D5B6D5B 514 | D87C0713C0260001FEC7FC273A78B834>II<167C16 518 | FEAC14FF010713C0011F13F04913F890B512FC48EBE03E48EB000FD807FC130313F04848 519 | 130148481300A2485AA248C8FCA3127E12FEAA127FA36C7EA26C6C1301A26C6C13037F6C 520 | 6C1307D803FE131E3901FFC07C6CEBFFF86D13F0011F13E00107EB807CD901FEC7FC273A 521 | 7CB834>I<14FF010713E0011F13F8017F13FE90B6FC48018013803903FE003FD807F8EB 522 | 1FC049EB0FE0484813074848EB03F0A24848EB01F8A248C7FC150016FC127E12FEA3B7FC 523 | A316F848C9FCA3127E127FA36C7EA26C7E6C6C140C6D141C6C6C143C6C6C14FC6C6C1303 524 | 3A00FFC03FF06DB512E06D14C0010F1400010313FC9038007FC0262E7CAC2E>II<027F137C903903FFC0FE010F13F0013F13F84913FC 527 | 9038FFE03C48EB000ED803FC130748481303485A484813015B003F14005B127F90C8FCA3 528 | 12FEA86C14017EA27F003F14037F6C6C13076C6C13066D130ED807FE131C3903FFC0786C 529 | EBFFF86C6C13F06D13C0010F1380903801FE0090C8FCA316FCA215010008EC03F8001EEC 530 | 07F0D81FC0EB0FE001FEEB7FC090B612806C15006C5CC66C13F8010313C027397CAB34> 531 | I<127C12FEACEC7FC0903801FFF0010713FC497F497FD93E011380903878007F01E0EB3F 532 | C049131F00FF15E049130FA290C7FCA25AB3AB007CEC07C0233978B834>I<127E12FFA6 533 | 127E1200A7123E127FB3B3A5123E083A7AB916>I<147E14FFA6147E1400A7143E147FB3 534 | B3AA14FEEA6001387F0FFCB512F814F06C13E06C13C03803FE00184687B91A>I<127C12 535 | FEB3B3B3127C073979B816>108 DIII<14FFD87C 544 | 0313E0D8FE0F7F4913FC497F90387C07FFD9F0001380D8FFC0EB7FC049EB1FE090C7120F 545 | 16F0481407ED03F8A216FC1501A216FE1500A9ED01FCA3150316F8150716F06C140FED1F 546 | E06DEB3FC06DEB7F809039E001FF0039FEF80FFE90387FFFFC6D5B6D5B010713C0D901FE 547 | C7FC90C9FCA9127C273778AB34>I<027F137C903903FFC0FE010F13F0013F13F84913FC 548 | 9038FFE03C48EB000ED803FC130748481303485A484813015B003F14005B127F90C8FCA3 549 | 12FEA9127FA37F123FA26C6C13017F000F14036D1307D807FC130F6C6C131E3901FFC07C 550 | 6CEBFFF86D13F0011F13E001071380903800FE0091C7FCA9167C27377CAB34>II 556 | I<137C13FEAB007FB512F8B612FCA36C14F8C648C7FCB3AC6D130C151C6D133EEC81FE90 557 | 383FFFFC15F86D13E06D1380903803F8001F387EB625>I<007CEC07C000FEEC0FE0B3AC 558 | 151FA2153FA2157F007F14EFEC03CF393FE00F8F90B5120F6C13FE6C13FC00039038F007 559 | C0C60180C7FC232C78AA34>I<0078150F00FCED1F806C153F007E1600127F6C157EA26D 560 | 14FE001F5D7F000F4A5AA26D130300075D7F00034A5AA26C6C495AA27F00004A5AA2017E 561 | 49C7FCA2017F5B6D137EA26D6C5AA214C1010F5B14E1903807E3F0A214F701035B14FF6D 562 | 5BA36D5BA2023EC8FC292B7EAA2E>I<007C153E00FE157E007F15FE6C6C495A6C6C495A 563 | 6C6C5C15076C6C495A6C6C495A6C6C495A6C6C49C7FC017F137E6D6C5A90381F81F8EB0F 564 | C3903807E7F0ECFFE06D5B6D5B6D90C8FC147E147F4A7E5B497F903807E7E090380FC3F0 565 | ECC1F890381F80FC90383F007E017E137F496D7E00016E7E4848130F48486D7E496D7E48 566 | 4880001F6E7E48486D7E48C8127F00FEED3F8048151F48150F292B7EAA2E>120 567 | D E /Fi 63 124 df11 DII<12F012FC127FEA1FC0EA07F0EA00FC133F130F1008 573 | 78AF2B>18 D<131F137FEA01FCEA07F0EA1FC0EA7E0012F812E010086DAF2B>I24 D<12FEA7121C123CA2123812781270A212F012 575 | E0A2071178AF18>39 D<14F01301EB03C0EB0780EB0F00131E5B5B13F8485A5B1203485A 576 | A2485AA248C7FCA2121E123EA35AA4127812F8AD1278127CA47EA3121E121FA26C7EA26C 577 | 7EA26C7E12017F6C7E13787F7F7FEB0780EB03C0EB01F01300144379B421>I<12E07E12 578 | 787E7E7E6C7E6C7E7F6C7E12007F137CA27FA27FA27F1480A3EB07C0A4130314E0AD14C0 579 | 1307A4EB0F80A314005BA2133EA25BA25B5B1201485A5B485A48C7FC121E5A5A5A5A1343 580 | 7AB421>I<12FEA7121C123CA2123812781270A212F012E0A20711788618>44 581 | D<387FFFF8B512FCA26C13F816047F931D>I<12FEA6127E0707788618>I<1306130F133F 582 | 13FF123F5AB5FCEA7F9FEA201F1200B3AF003FB512C04814E0A215C01B2E78AD2B>49 583 | DIII<000FB512FC48 593 | 80A35D90C9FCABEB07FC90383FFF8090B512E0819038FC03F89038E000FC0180137E90C7 594 | 7E000E80C81380A2ED0FC0A7ED1F8012100030143F007C150000FE147E397F8001FC393F 595 | F00FF86CB55A00075C6C5CC691C7FCEB1FF0222E7CAC2B>II<007FB612E0B712F0A36C15E0C8EA0FC0ED3F80ED7E005D4A 600 | 5A4A5AA24A5A4A5A4A5A143F92C7FC147EA25C13015C13035CA2495AA2130F5CA3495AA5 601 | 49C8FCA8131E242D7DAC2B>I<127E12FEA61200B3A412FEA6127E072478A318>58 602 | D65 D<007FB57EB612F815FF16C08226FC000113 606 | F89138000FFC1503ED00FE167E82A5167E5E1501ED0FF0ED3FE091381FFF80B648C7FC15 607 | F815FF16E000FCC7EA3FF0ED07FCED01FEED007FEE3F80161FEE0FC0A5161F1780167FEE 608 | FF00ED07FEED7FFCB75A16E05E4BC7FC6C14E02A2F78AE38>I<913803FFE0023F13FF49 609 | B612E013075B90393FFC007FD97FE0EB07C049C8FC48481500EA03F8485A485A5B485A12 610 | 3F90CAFCA2127EA35AA9127EA37EA27F121F6C7E7F6C7E6C7ED801FE15306C6C15F0D97F 611 | E01303D93FFC133F010FB6FC6D15C001011500D9003F13FC020313C02C317AAF37>I<00 612 | 7FB512E0B612FE6F7E16E08200FCC7EA3FFCED07FEED00FFEE7F80EE1FC0EE0FE01607EE 613 | 03F0A2EE01F8A2EE00FCA3177EA9177C17FCA3EE01F8160317F01607EE0FE0EE1FC0EE3F 614 | 80EEFF00ED07FEED3FFCB75A16E016804BC7FC6C14E02F2F78AE3D>I<007FB612FEB8FC 615 | A35E00FCCAFCAFB712F882A35E00FCCAFCB1B8FC1780A36C1600292F78AE36>I<007FB6 616 | 12FCB712FEA316FC00FCC9FCB0B712C016E0A316C000FCC9FCB3A21278272F78AE33>I< 617 | 913807FFC0023F13FE49B612C0010715F05B90393FFC007FD97FE0130749C7EA01E04848 618 | EC0060D803F81500485A485A5B485A123F90CAFCA2127EA35AA292380FFFF05DA4ED0001 619 | A2127EA37EA27F121F6C7E7F6C7E6C7EEA01FE6C7ED97FE01303D93FFC137F010FB6FC7F 620 | 010115C0D9003FEBFC00020713802C317AAF39>I<387FFFC0B512E0A36C13C03801F800 621 | B3B3387FFFC0B512E0A36C13C0132F7FAE16>73 D<127812FCB3B3A5B712E016F0A36C15 622 | E0242F78AE31>76 D<007FEE07F0486CED0FF86D151FA26D153FA3D8FBF0157DA2D8F9F8 623 | 15F9A2D8F8FCEC01F1A2017EEC03E1A26DEC07C1A36D6CEB0F81A26D6CEB1F01A26D6C13 624 | 3EA26D6C137CA2010114786E13F8010014F0ECFC01A291387E03E0A2023E13C0EC3F0702 625 | 1F1380158F020F1300A2EC07DEA215FE6E5AA26E5A6E5A007091C812F0352F78AE46>I< 626 | 007F151C486C143E7F7FA2EAFBF0A2EAF9F8EAF8FCA2137EA27F6D7EA26D7EA26D7E6D7E 627 | A26D7EA26D7E80147E80A2EC1F80A2EC0FC0EC07E0A2EC03F0A2EC01F8EC00FCA2157EA2 628 | 153FED1FBEA2ED0FFEA2150715030070EC01FC272F78AE38>I<913803FF80023F13F849 629 | B6FC010715C0903A0FFC007FE0D93FE0EB0FF8D97F80EB03FC01FEC87ED801F8153F4848 630 | ED1F804848ED0FC04848ED07E0A24848ED03F048C9EA01F8A2003E1600007E17FCA2007C 631 | 177C00FC177EA86C17FE007E17FCA3007F16016C17F86D1503001F17F06D15076C6CED0F 632 | E06C6CED1FC06C6CED3F806C6CED7F006C6C15FED97F80EB03FCD93FE0EB0FF8D90FFEEB 633 | FFE06DB65A010192C7FCD9003F13F80203138037317BAF42>I<007FB512C0B612F815FF 634 | 168016E000FCC7EA7FF0ED07F8ED01FC1500167EA2163FA6167EA216FC1501ED07F8ED7F 635 | F0B712C01680EDFE0015F000FCC9FCB31278282F78AE36>I<913803FF80023F13F849B6 636 | FC010715C04948C67FD93FE0EB0FF8D97F80EB03FC01FEC87E4848157F4848ED3F80D807 637 | E0ED0FC0000F17E04915074848ED03F0003F17F890C91201A2007EEE00FCA348177EA900 638 | 7E17FCA3007F16016C17F8A26C6C013EEB03F06D013F13076C6C90391F800FE0000703C0 639 | 13C06C6C90390FE01F80D801FC903907F07F006C6C903803F8FE903A7F8001FFFC90263F 640 | E0005BD90FFE14E06DB65A1301D9003F800203EB87F091C7EA03F8707E707E177FEF3F80 641 | EF1FC018E0170F1707373A7BAF42>I<903803FFC0011F13FC017FEBFF8048B612E05A39 642 | 07FE007FD80FF01307D81FC0EB01C04848EB004090C9FC127EA5127F7E13C0EA1FF0EA0F 643 | FE3807FFE06C13FF6C14F06C6C13FC011F13FF01031480D9001F13C0020013E0ED1FF015 644 | 07ED03F8150116FC1500A50040EC01F8127000FCEC03F0B4140701C0EB1FE001FCEBFFC0 645 | 003FB61280000FECFE0000035CC66C13F0010790C7FC26317CAF30>83 646 | D<007FB812FCB912FEA36C17FCC8007EC8FCB3B3A5153C372F7DAE3E>I<0078151C00FC 647 | 153EB3AF6C157E007E157CA2007F15FC6C6CEB01F8001FEC03F001E01307D80FF8EB1FE0 648 | 6CB4EBFFC06C90B51280C6ECFE006D5B011F13F001011380273078AE38>I94 650 | D97 653 | D<127012F8ABEB07E0EB3FFC497E00F9B5128039FBE03FC038FF800F39FE0003E048EB01 654 | F015F8481300157CA3153EA9157CA315F87EEC01F06C1303EC07E06CEB0FC039FBC07F80 655 | 00F9B5120000F85BEB7FF838700FC01F3079AF2B>I 658 | I<151C153EABEB0FE0EB3FFCEBFFFE4813FF3903FC07BE3907E001FE380FC0004848137E 659 | 90C7FC003E143EA25AA35AA81278127CA36C147E123F6C14FE380F80013907E003BE3903 660 | F80F3E3801FFFE6C13FCEB7FF890380FE01C1F307CAF2B>III<9038 665 | 07E01C90383FF83EEBFFFE4813FF3903FC07BE3807F003390FC001FE381F800090C7127E 666 | 123E153E5AA35AA8007C147EA36C14FE123F6C1301D80FC013BEEBE0033907F80F3E3803 667 | FFFEC613FCEB7FF8EB0FE090C7FCA3153C157C00101478003C14F8003FEB03F09038E00F 668 | E06CB512C06C14800001EBFE0038001FF01F307CA32B>I<127012F8ABEB07F8EB1FFEEB 669 | 7FFF90B5128039F9F01FC039FB8007E038FF00034814F014015AA25AB3A60070EB00E01C 670 | 3079AF2B>I<127C12FEA512FC1200A61238127CB3B0123807317AB014>II<127012F8AB15F81403EC07F0EC0FE0EC1FC0EC3F80EC7F0014FE495AEB03 673 | F0EB0FE0495A495A49C7FC13FEEAF9FF00FB7FB57E13CFEB87E0EB03F0486C7E12FC486C 674 | 7E147E80EC1F80A2EC0FC0EC07E0EC03F0A2EC01F8EC00FC157E0070143C1F3079AF29> 675 | I<127012F8B3B3AA1270053079AF14>I<267007FCEB07FC26F81FFFEB1FFF496D481380 676 | 90B56CB512C03CF9F00FE1F00FE03CFBC003F3C003F0D90001EB000100FE02FE14F80200 677 | 1400485CA2485CB3A6007002701470352479A344>I<387007F838F81FFEEB7FFF90B512 678 | 8039F9F01FC039FB8007E038FF00034814F014015AA25AB3A60070EB00E01C2479A32B> 679 | II<387007E038F83FFC497E00F9B5128039FBE07FC038FF800F39FE 683 | 0007E048EB03F0EC01F848130015FC157CA2157E153EA8157CA315F87EEC01F06C1303EC 684 | 07E06CEB1FC039FBC07F8000F9B5120000F85BEB7FF8EB0FC090C8FCA912701F2E79A32B 685 | >I<903807E01C90383FF83EEBFFFE4813FF3903FC07BE3807F003390FC001FE381F8000 686 | 90C7127E123E153E5AA35AA8127CA3007E147E123E003F14FE6C7E380FC0013907E003BE 687 | 3903FC0F3E3801FFFE6C13FCEB3FF8EB0FE090C7FCA9151C1F2E7CA32B>I<387001F0EA 688 | F807131F133F137FEBFE00EAF9F0EAFBC05BB4C7FC5AA25AA25AB3A31270142479A31D> 689 | II<13E0487EA9387FFFFEB6FCA26C5BD801F0C7FCB3A714036D5A0000EB1F80 693 | 90B512006D5AEB3FF8EB1FC0192E7EAD1F>I<007014E000F8EB01F0B3A71403A2140714 694 | 0F007C131D007F13F9383FFFF16C13E16C13813903FC00E01C2479A32B>I<00F0EC0780 695 | 6C140FA2007CEC1F00A2127E003E143EA26C5CA27F000F5CA26C6C485AA213E00003495A 696 | A26C6C485AA213F80000495AA2D97C1FC7FCA2137EEB3E3EA2EB3F7EEB1F7C14FC6D5AA3 697 | 6D5A6D5A21247EA326>I<007CEC0F80127E6CEC1F006C5C6D137E6C6C5B6C6C485AD803 698 | F05B6C6C485A6C6C485AEB7C0F6D485A6D48C7FC14BEEB0FFC6D5A6D5A1301497E130749 699 | 7EEB1F3E8090383E0F80496C7E496C7ED801F07F0003130148486C7E49137C48487F48C7 700 | 123F48EC1F80007EEC0FC048EC07E00078EC03C023247FA326>120 701 | D<00F0EC07806C140F7E007CEC1F00A27E153E123F6C5C7F000F14FC5D6C7E4A5A13E012 702 | 036D485A12014A5AEA00F85DEBFC0F137C4AC7FC133E141EEB1E3E131FEB0F3CA25CEB07 703 | F8A26D5AA26D5AA213035C1307495AD8301FC8FCEA7FFF5B13F8EA3FE0212E7EA326>I< 704 | 007FB71280B812C0A26C16802A0480972B>123 D E /Fj 17 118 705 | df19 706 | D39 707 | D<923801FFFE033FEBFFF04AB7FC020F16E0143F91B8FC130349DA000F13C04901F81301 708 | 013F01C0EB007F4990C8121F494815074801F815034849ED01804A150048491600485B5A 709 | 91CBFC485AA2127F5BA3485AA96C7EA37F123FA26C7E807E6C7F6C6D16606E16E06C6D15 710 | 016C01FE15036D6C150F6D01C0EC1FF0010F01F8147F6D01FFEB07FF6D91B6FC1300023F 711 | 16C0020F1600020115FCDA003F14E0030101FCC7FC3C3B7AB949>67 712 | D<007FB612F8B812C017F817FF18C08418F8848401F8C700037FDC003F1380170F7113C0 713 | A27113E0A64D13C05F4D1380057F1300933807FFFC90B85A18E0188005FCC7FC17E01780 714 | 9026F800077F6F7F81836F7F707E707E161F83707F707F707FA2707F707F717E173F8471 715 | 7E7113807113C0A27113E07113F0836C48167F3C3978B84A>82 D97 D100 723 | DI105 728 | D108 DI<4AB47E267FE00713F026FFF01F13FC027F7F91 732 | B6FC01F115809026F3F01F13C09038F780079038FF00034915E0497F5BA35BB3AC6C486D 733 | 13C02B2D7AAC38>III<15F8387FE00738FFF00F143F147F14 741 | FF13F113F313F7ECFE00EBFFF0148091C7FC5B5B5BA25BB3A96C5A1D2D7AAC26>114 742 | D<903807FF80013F13F890B512FE0003ECFF804815E05A5AEBFC00D83FE0EB1FC0150749 743 | 1303007F14001600A27F7F13FE383FFFF8ECFF8015F06C14FC6C806C806C15806C15C06C 744 | 15E0133F010714F0EB007F020113F8EC007F151F150F122012701278007E15F0007F141F 745 | 01E0133FD8FFFCEBFFE090B612C0A21680003FECFE0000075CC614F0010F1380252F7DAD 746 | 2C>III E end 750 | %%EndProlog 751 | %%BeginSetup 752 | %%Feature: *Resolution 300dpi 753 | TeXDict begin 754 | %%PaperSize: a4 755 | 756 | %%EndSetup 757 | %%Page: 1 1 758 | 1 0 bop 299 136 a Fj(R)m(\023)-54 b(ealisation)37 b(d'un)h(Compilateur) 759 | d(C)762 358 y Fi(F)n(ab)n(rice)27 b(Bella)n(rd)71 576 760 | y Fh(But)34 b(du)f(p)m(rojet:)71 701 y(F)m(aire)40 b(un)e(auto-amo)m 761 | (r\030)-46 b(cage)37 b(p)s(our)h(d)m(\023)-49 b(emontrer)39 762 | b(que)71 825 y(le)c(compilateur)h(fonctionne)d(e\013ectivement.)106 763 | 1106 y(1.)41 b(Les)34 b(choix)106 1386 y(2.)41 b(L'a)m(rchitecture)35 764 | b(globale)106 1666 y(3.)41 b(Le)34 b(compilateur)i(C)106 765 | 1947 y(4.)41 b(L'assembleur)106 2227 y(5.)g(La)34 b(machine)h 766 | (virtuelle)106 2507 y(6.)41 b(Les)34 b(R)m(\023)-49 b(esultats)p 767 | eop 768 | %%Page: 2 2 769 | 2 1 bop 71 454 a Fg(Les)46 b(Choix)g(-)g(1)p 71 591 1910 770 | 5 v 71 794 a Fi(Nous)33 b(avons)h(envisag)n(\023)-41 771 | b(e)33 b(la)f(compilati)o(on)f(de)j(deux)g(t)n(yp)r(es)g(de)71 772 | 873 y(langage:)144 1046 y({)41 b(CAML)144 1218 y({)g(C)71 773 | 1390 y(Nous)j(avons)g(choisi)e(le)i(C)g(pa)n(r)f(go^)-43 774 | b(ut)44 b(p)r(ersonnel)g(et)h(p)r(our)71 1469 y(p)r(ouvoir)30 775 | b(tester)h(le)f(compilateur)e(sur)j(une)g(la)n(rge)e(gamme)g(de)71 776 | 1548 y(sources.)71 1706 y(Les)f(grands)h(choix:)144 1878 777 | y({)41 b(P)n(as)28 b(de)h(p)n(r)n(\023)-41 b(ep)n(ro)r(cesseur:)29 778 | b(on)g(utilise)d Ff(gcc)36 b(-E)144 2050 y Fi({)41 b(P)n(as)28 779 | b(de)h(\015ottants)144 2222 y({)41 b(P)n(as)28 b(de)h(rep)n(rise)f(des) 780 | h(erreurs)p eop 781 | %%Page: 3 3 782 | 3 2 bop 71 293 a Fg(Les)46 b(Choix)g(-)g(2)p 71 430 1910 783 | 5 v 144 727 a Fi({)41 b(On)28 b(utilise)c Ff(flex\(lex\))f 784 | Fi(et)k Ff(bison\(yac)o(c\))c Fi(p)r(our)k(le)f Fe(pa)n(rser)p 785 | Fi(.)228 806 y(Donc)h(le)e(compilateur)e(doit)j(p)r(ouvoir)f(accepter)i 786 | (le)e(co)r(de)228 885 y(g)n(\023)-41 b(en)n(\023)g(er)n(\023)g(e)30 787 | b(pa)n(r)d(ces)j(2)e(utilitair)o(es.)144 1057 y({)41 788 | b(Gestion)19 b(de)h(mo)r(dules)e(s)n(\023)-41 b(epa)n(r)n(\023)g(es,)18 789 | b(donc)i(un)f(syst)n(\022)-41 b(eme)19 b(d')n(\023)-41 790 | b(edi-)228 1136 y(tion)28 b(de)h(liens)f(est)h(n)n(\023)-41 791 | b(ecessaire.)144 1308 y({)41 b(Dans)33 b(la)e(mesure)h(du)h(p)r 792 | (ossible,)e(on)i(reste)g(confo)n(rme)d(\022)-42 b(a)228 793 | 1387 y(la)28 b(no)n(rme)f Fe(ANSI)i(C)p Fi(.)144 1560 794 | y({)41 b(Utilisati)o(on)23 b(d'une)j(machine)e(\022)-42 795 | b(a)25 b(pile.)f(Simple,)g(mais)f(em-)228 1638 y(p)n(^)-41 796 | b(eche)30 b(l')n(\023)-41 b(evolution)27 b(du)i(compilateur.)144 797 | 1811 y({)41 b(P)n(our)21 b(des)g(questions)f(de)h(p)r(erfo)n(rmances,)f 798 | (on)h(est)g(d)n(\023)-41 b(ep)r(en-)228 1890 y(dant)26 799 | b(du)h Fe(ha)n(rdw)n(a)n(re)p Fi(:)d(taille)g(des)i(p)r(ointeurs,)g 800 | (alignement)228 1968 y(des)j(donn)n(\023)-41 b(ees,)30 801 | b Fe(endianit)n(\023)-41 b(e)p Fi(.)144 2141 y({)41 b(On)20 802 | b(s'imp)r(ose)f(en\014n)h(la)e(contrainte)h(de)h(d)n(\023)-41 803 | b(ep)r(endre)20 b(au)f(mi-)228 2220 y(nimum)e(des)j(fonctions)g(des)g 804 | (lib)n(rai)o(ri)o(es)d(standa)n(rds:)i(on)g(re-)228 2298 805 | y(compile)h(une)i(pa)n(rtie)f(du)h(co)r(de)g(p)r(our)h 806 | Ff(stdlib.h)o Fi(,)c Ff(stdio.h)p Fi(,)228 2377 y Ff(stdarg.h)26 807 | b Fi(et)j Ff(string.h)p Fi(.)p eop 808 | %%Page: 4 4 809 | 4 3 bop 71 148 a Fg(Architecture)47 b(G)m(\023)-65 b(en)m(\023)g(erale) 810 | 47 b(-)f(1)p 71 271 1910 5 v 71 526 a Fi(Compilateur)25 811 | b(C)k(\()p Ff(fbcc)p Fi(\):)71 605 y Fd(\(4700)23 b(lignes\))120 812 | 766 y Fi(1.)41 b Fe(Lexer)120 927 y Fi(2.)g Fe(P)n(a)n(rser)120 813 | 1089 y Fi(3.)g(Gestion)29 b(des)g(d)n(\023)-41 b(ecla)n(rations)120 814 | 1250 y(4.)41 b(Pro)r(duction)19 b(des)h(donn)n(\023)-41 815 | b(ees)20 b(p)r(our)f(les)f(va)n(riables)f(statiques)120 816 | 1412 y(5.)41 b(T)-7 b(ypage)29 b(des)g(exp)n(ressions)120 817 | 1573 y(6.)41 b(Propagation)28 b(des)h(constantes)120 818 | 1735 y(7.)41 b(G)n(\023)-41 b(en)n(\023)g(eration)29 819 | b(de)g(co)r(de)g(assembleur)71 1896 y(Assembleur)e(\()p 820 | Ff(fbas)p Fi(\):)71 1975 y Fd(\(700)c(lignes\))120 2137 821 | y Fi(1.)41 b Fe(Lexer)58 b Fi(-)28 b Fe(P)n(a)n(rser)120 822 | 2298 y Fi(2.)41 b(Gestion)27 b(des)g(symb)r(oles)e(exp)r(o)n(rt)n(\023) 823 | -41 b(es,)28 b(globaux,)d(ou)i(p)n(riv)n(\023)-41 b(es)120 824 | 2460 y(3.)41 b(Pro)r(duction)33 b(d'un)f(ex)n(\023)-41 825 | b(ecutable)33 b(relogeable)e(avec)i(table)228 2538 y(de)c(relo)r 826 | (cation)p eop 827 | %%Page: 5 5 828 | 5 4 bop 71 413 a Fg(Architecture)47 b(G)m(\023)-65 b(en)m(\023)g(erale) 829 | 47 b(-)f(2)p 71 550 1910 5 v 71 815 a Fi(Machine)28 b(virtuelle)f(\()p 830 | Ff(fbvm)p Fi(\):)71 894 y Fd(\(900)c(lignes\))120 1067 831 | y Fi(1.)41 b(Cha)n(rgement)28 b(de)h(l'ex)n(\023)-41 832 | b(ecutable)28 b(et)h(relo)r(cation)120 1239 y(2.)41 b(Emulation)26 833 | b(des)j(instructions)120 1411 y(3.)41 b(App)r(el)28 b(de)h(quelques)e 834 | (fonctions)h(de)g(la)f(lib)n(rai)o(ri)o(e)e(C)j(stan-)228 835 | 1490 y(da)n(rd)g(gr)o(^)-42 b(ace)28 b(\022)-42 b(a)28 836 | b(des)h Fe(traps)71 1662 y Fi(Lib)n(rair)o(i)o(es)d(\()p 837 | Ff(startup.s)p Fi(,)p Ff(fb)o(li)o(b.c)o Fi(\):)71 1741 838 | y Fd(\(900)d(lignes\))120 1913 y Fi(1.)41 b(Co)r(de)30 839 | b(de)f Fe(sta)n(rtup)120 2086 y Fi(2.)41 b(Compilation)23 840 | b(des)j(fonctions)g Fc(f)p Ff(fvs)p Fc(g)p Ff(pri)o(ntf)c 841 | Fi(et)k Ff(stdarg.h)120 2258 y Fi(3.)41 b(Compilation)25 842 | b(des)k(fonctions)g(de)g Ff(string.h)p eop 843 | %%Page: 6 6 844 | 6 5 bop 71 453 a Fg(Le)45 b(Compilateu)q(r)j(C)e(-)g(1)p 845 | 71 604 1910 5 v 71 869 a Fi(Ca)n(ract)n(\023)-41 b(eristiques)26 846 | b(ANSI)j(non)g(impl)n(\023)-41 b(em)o(ent)n(\023)g(ees:)144 847 | 1042 y({)41 b(T)-7 b(yp)r(es)30 b Ff(long)p Fi(,)c Ff(float)h 848 | Fi(et)i Ff(double)144 1214 y Fi({)41 b(Quali\014catifs)27 849 | b(de)i(t)n(yp)r(es)h Ff(const)c Fi(et)j Ff(volatile)144 850 | 1386 y Fi({)41 b(A\013ectations)c(de)f(structures,)g(passage)g(pa)n(r)f 851 | (valeur)g(et)228 1465 y(retour)29 b(de)g(structures)144 852 | 1637 y({)41 b(Ca)n(ract)n(\022)-41 b(eres)28 b(de)h(t)n(yp)r(e)h 853 | Ff(wchar)p 1106 1637 22 2 v 24 w(t)144 1810 y Fi({)41 854 | b(P)n(a)n(rsing)27 b(des)i(constantes)g(de)g(t)n(yp)r(e)g 855 | Ff(unsigned)34 b(int)144 1982 y Fi({)41 b(Certaines)28 856 | b(fo)n(rmes)g(d'initial)o(i)o(sati)o(ons)e(statiques)144 857 | 2154 y({)41 b(Quelques)25 b(contr^)-43 b(oles)24 b(de)g(t)n(yp)r(e)h 858 | (dans)f(les)g(exp)n(ressions)g(et)228 2233 y(structures)29 859 | b(de)g(contr^)-43 b(ole.)p eop 860 | %%Page: 7 7 861 | 7 6 bop 71 165 a Fg(Le)45 b(Compilateu)q(r)j(C)e(-)g(2)p 862 | 71 316 1910 5 v 71 581 a Fi(Exemples)27 b(de)i(ca)n(ract)n(\023)-41 863 | b(eristiques)26 b(impl)n(\023)-41 b(ement)n(\023)g(ees:)144 864 | 754 y({)41 b(Anciens)23 b(et)f(nouveaux)h(p)n(rotot)n(yp)r(es)g(de)f 865 | (fonctions,)h(avec)228 833 y(les)41 b Fb(:)13 b(:)f(:)54 866 | b Fi(p)r(our)42 b(indiquer)e(une)i(fonction)e(\022)-42 867 | b(a)42 b(nomb)n(re)e(de)228 911 y(pa)n(ram)n(\022)-41 868 | b(etres)27 b(va)n(riables)144 1084 y({)41 b(Blo)r(cs)29 869 | b(dans)g(les)f(fonctions)144 1256 y({)41 b(T)-7 b(ableaux)31 870 | b(multidi)o(m)o(ensionnel)o(s,)e Ff(struct)p Fi(,)h Ff(union)p 871 | Fi(,)g Ff(enum)p Fi(,)228 1335 y(p)r(ointeurs)f(sur)f(les)g(fonctions) 872 | 144 1507 y({)41 b(Gestion)29 b(compl)n(\022)-41 b(ete)28 873 | b(de)h Ff(typedef)144 1679 y Fi({)41 b(T)-7 b(outes)32 874 | b(les)g(instructions)f(de)h(contr^)-43 b(ole,)31 b(y)i(comp)n(ris)d 875 | (les)228 1758 y Ff(goto)144 1930 y Fi({)41 b(T)-7 b(ables)33 876 | b(des)h(symb)r(oles)f(s)n(\023)-41 b(epa)n(r)n(\023)g(ees)34 877 | b(p)r(our)g(les)e(\023)-41 b(etiquettes)228 2009 y(de)22 878 | b Ff(struct)p Fi(,)d Ff(union)p Fi(,)g(et)j Ff(enum)p 879 | Fi(,)e(les)h(champs)f(de)i(structures,)228 2088 y(les)k(\023)-41 880 | b(etiquettes)29 b(de)g Ff(goto)144 2260 y Fi({)41 b(Initialisa)o(tions) 881 | 25 b(statiques)j(et)h(dynamiques)f(auto)n(ris)n(\023)-41 882 | b(ees)144 2433 y({)41 b(T)-7 b(ypage)19 b(pleinement)f(confo)n(rme)f 883 | (\022)-42 b(a)19 b(la)f(no)n(rme)f(ANSI)j(p)r(our)228 884 | 2512 y(p)n(resque)29 b(tous)g(les)f(op)n(\023)-41 b(erateurs)p 885 | eop 886 | %%Page: 8 8 887 | 8 7 bop 71 431 a Fg(Le)45 b(Compilateu)q(r)j(C)e(-)g(3)p 888 | 71 581 1910 5 v 71 847 a Fi(D)n(\023)-41 b(etails)27 889 | b(d'impl)n(\023)-41 b(em)o(entation:)144 1019 y({)41 890 | b(Il)24 b(n'y)h(a)f(pas)h(de)g(rep)n(r)n(\023)-41 b(esentation)24 891 | b(interm)n(\023)-41 b(ediai)o(re)22 b(p)r(our)j(le)228 892 | 1098 y(co)r(de)32 b(autre)f(que)g(celle)e(des)i(exp)n(ressions.)f(Le)h 893 | (compila-)228 1177 y(teur)i(p)r(ourrait)c(^)-41 b(etre)32 894 | b(vu)h(comme)e(un)h(p)n(remier)e(pas)i(vers)228 1256 895 | y(un)d(g)n(\023)-41 b(en)n(\023)g(erateur)29 b(de)g(co)r(de)h(interm)n 896 | (\023)-41 b(ediai)o(re)144 1428 y({)41 b(T)-7 b(outes)22 897 | b(les)g(tables)f(de)h(symb)r(oles)f(sont)h(g)n(\023)-41 898 | b(er)n(\023)g(ees)22 b(avec)h(des)228 1507 y(tables)28 899 | b(de)h(hachage)144 1679 y({)41 b(Pratiquement)18 b(toutes)h(les)g(donn) 900 | n(\023)-41 b(ees)20 b(sont)f(sto)r(ck)n(\023)-41 b(ees)20 901 | b(dans)228 1758 y(des)32 b(listes.)e(Cela)h(p)r(ermet)g(de)h(simpli)o 902 | (\014er)d(la)i(gestion)g(de)228 1837 y(la)24 b(m)n(\023)-41 903 | b(emoire)22 b(et)i(\023)-41 b(evite)25 b(d'ab)r(o)n(rd)f(un)h(trop)g 904 | (grand)f(nomb)n(re)228 1916 y(de)29 b(structures)f(\022)-42 905 | b(a)29 b(d)n(\023)-41 b(e\014nir)28 b(de)h(fa\030)-38 906 | b(con)29 b(explicite.)144 2088 y({)41 b(Le)h(mo)r(d)n(\022)-41 907 | b(ele)41 b(de)i(pile)d(est)i(le)g(m)n(^)-41 b(eme)40 908 | b(que)i(celui)f(du)h(C)228 2167 y(standa)n(rd.)22 b(On)i(utilise)d(un)i 909 | (lien)f(dynamique)f(et)j(on)f(sauve)228 2246 y(aussi)k(la)g(taille)e 910 | (des)k(a)n(rguments)d(pass)n(\023)-41 b(es)28 b(en)g(pa)n(ram)n(\022) 911 | -41 b(etre.)p eop 912 | %%Page: 9 9 913 | 9 8 bop 71 328 a Fg(Le)45 b(Compilateu)q(r)j(C)e(-)g(4)p 914 | 71 479 1910 5 v 71 670 a Fi(La)32 b(syntaxe)h(des)g(d)n(\023)-41 915 | b(ecla)n(rations)31 b(imp)r(ose)g(de)j(construire)e(une)71 916 | 736 y(rep)n(r)n(\023)-41 b(esentation)30 b(interm)n(\023)-41 917 | b(ediai)o(re)28 b(p)r(our)k(les)f(t)n(yp)r(es.)g(On)h(utilise)71 918 | 803 y(p)n(ratiquement)26 b(la)h(m)n(^)-41 b(eme)28 b(rep)n(r)n(\023)-41 919 | b(esentation)27 b(p)r(our)i(le)f(t)n(yp)r(e)h(d)n(\023)-41 920 | b(e-)71 869 y(\014nitif.)71 1002 y Fd(T)-6 b(yp)r(es:)71 921 | 1114 y Fa(type)32 b(:==)62 b(\(base_t)q(yp)q(e\))314 922 | 1181 y(|)31 b(\(TYPE_P)q(OI)q(NT)q(ER)q(\))j(+)d(type)314 923 | 1247 y(|)g(\(TYPE_A)q(RR)q(AY)j(dim\))f(+)e(type)314 924 | 1313 y(|)g(\(TYPE_S)q(TR)q(UC)q(T)j(sym\))e(|)f(\(TYPE_U)q(NI)q(ON)j 925 | (sym\))e(|)f(\(TYPE_E)q(NU)q(M)j(sym\))314 1380 y(|)d(\(TYPE_F)q(UN)q 926 | (C)j(func_typ)q(e)g(var_list)q(\))f(+)e(type)71 1513 927 | y(base_type)j(:==)63 b(TYPE_CHA)q(R)34 b(|)d(TYPE_UCH)q(AR)467 928 | 1579 y(|)g(TYPE_SHO)q(RT)j(|)d(TYPE_US)q(HO)q(RT)467 929 | 1646 y(|)g(TYPE_INT)j(|)d(TYPE_UI)q(NT)71 1778 y(func_type)j(:==)e 930 | (FUNC_EL)q(LI)q(PS)q(IS)i(|)d(FUNC_OL)q(D)j(|)c(FUNC_NE)q(W)71 931 | 1911 y(var_list)k(:==)e(var1)g(+)f(...)h(+)f(varN)71 932 | 2044 y(var)h(:==)f(\()g(\(nom\))i(var_sto)q(ra)q(ge)h(type)f(var_init)h 933 | (\))71 2177 y(var_stora)q(ge)g(:==)63 b(STORAGE_)q(DE)q(FA)q(UL)q(T)34 934 | b(|)d(STORAGE_A)q(UT)q(O)j(|)d(STORAGE_)q(RE)q(GI)q(ST)q(ER)528 935 | 2243 y(|)g(STORAGE_)q(ST)q(AT)q(IC)j(|)d(STORAGE_)q(EX)q(TE)q(RN)71 936 | 2376 y(var_init)j(:==)e(\(INIT_EX)q(PR)i(expr\))f(|)e(\(INIT_L)q(IST)j 937 | (var_ini)q(t1)g(...)e(var_ini)q(tN)q(\))p eop 938 | %%Page: 10 10 939 | 10 9 bop 71 223 a Fg(Le)45 b(Compilateu)q(r)j(C)e(-)g(5)p 940 | 71 373 1910 5 v 71 564 a Fd(T)-6 b(able)23 b(des)i(symb)r(oles:)71 941 | 676 y Fa(var_locat)q(io)q(n)34 b(:==)e(VAR_STAC)q(K)i(|)d(VAR_DATA)71 942 | 809 y(sym_var)i(:==)f(\()f(SYM_VAR)j(var_sto)q(ra)q(ge)g(type)f 943 | (\(var_loca)q(ti)q(on)h(var_off)q(se)q(t\))q(\))71 942 944 | y(sym_field)q(_s)q(tr)q(uc)q(t)g(:==)e(\(type)h(offset\))71 945 | 1075 y(sym_typed)q(ef)h(:==)e(\(SYM_TY)q(PE)q(DE)q(F)i(type\))71 946 | 1208 y(sym_struc)q(t)g(:==)62 b(\(TYPE_S)q(TR)q(UC)q(T)34 947 | b(-1\))62 b(/*)32 b(si)f(non)h(d\023)-30 b(efini)33 b(*/)497 948 | 1274 y(|)e(\(TYPE_S)q(TR)q(UC)q(T)j(symbol_t)q(ab)q(le)g(size)e 949 | (align\))71 1407 y(sym_enum_)q(co)q(ns)q(t)i(:==)e(\(SYM_ENU)q(M_)q(CO) 950 | q(NS)q(T)i(val\))71 1519 y Fd(Exp)n(ressions:)71 1631 951 | y Fa(expr)e(:==)g(\(type)h(tag)f(expr1)h(...)f(exprN)h(\))71 952 | 1764 y(expr_iden)q(t)h(:==)e(\(type)h(EXPR_IDE)q(NT)h(sym\))71 953 | 1897 y(expr_call)g(:==)e(\(type)h(EXPR_CA)q(LL)h(expr_fu)q(nc)g(n)d 954 | (param1)i(paramN\))71 2030 y(expr_int)h(:==)e(\(type)h(EXPR_INT)h(n\)) 955 | 71 2163 y(expr_str)g(:==)e(\(type)h(EXPR_STR)h(str1)f(...)f(strN\))71 956 | 2295 y(expr_cast)i(:==)e(\(type)h(EXPR_CA)q(ST)h(expr\))71 957 | 2428 y(etc...)p eop 958 | %%Page: 11 11 959 | 11 10 bop 71 312 a Fg(L'Assembleur)p 71 449 1910 5 v 960 | 144 746 a Fi({)41 b(G)n(\023)-41 b(en)n(\023)g(eration)35 961 | b(de)f(co)r(de)i(et)f(donn)n(\023)-41 b(ees)35 b(dans)g(2)f(segments) 962 | 228 825 y Ff(.text)27 b Fi(et)i Ff(.data)144 997 y Fi({)41 963 | b(Donn)n(\023)-41 b(ees:)20 b Ff(.byte)35 b Fe(num)p 964 | Fi(,)18 b Ff(.short)34 b Fe(num)p Fi(,)18 b Ff(.int)35 965 | b Fe(exp)n(r)p Fi(,)p Ff(.align)228 1076 y Fe(num)p Fi(,)28 966 | b Ff(.zero)35 b Fe(num)144 1248 y Fi({)41 b(Etiquettes:)29 967 | b Ff(.equ)34 b Fe(sym)p Ff(,)p Fe(num)27 b Fi(,)i Fe(sym)p 968 | Ff(:)p Fi(,)e Ff(.globl)34 b Fe(sym)144 1420 y Fi({)41 969 | b(Exp)n(ressions)28 b(de)h(la)e(fo)n(rme:)h Fe(sym)p 970 | Fi(,)g Fe(num)p Fi(,)f Fe(sym)h Ff(+)p Fe(num)144 1593 971 | y Fi({)41 b(D)n(\023)-41 b(ebut)30 b(d'un)e(nouveau)i(mo)r(dule:)d 972 | Ff(.module)71 1765 y Fi(On)j(utilise)e(p)r(our)i(plus)f(de)h(simplici)o 973 | (t)n(\023)-41 b(e)28 b(l'assembleur)f(comme)69 1844 y(\023)-41 974 | b(editeur)38 b(de)i(liens.)e(Un)h(symb)r(ole)f(p)r(eut)h(^)-41 975 | b(etre)39 b(externe)h(\(non)71 1923 y(d)n(\023)-41 b(e\014ni)41 976 | b(p)r(our)h(le)e(moment\),)g(global)g(\(grace)h(\022)-42 977 | b(a)41 b(la)f(directive)71 2001 y Ff(.globl)p Fi(\))26 978 | b(ou)j(p)n(riv)n(\023)-41 b(e.)71 2080 y(La)28 b(directive)g 979 | Ff(.module)d Fi(e\013ace)30 b(tous)f(les)f(symb)r(oles)g(p)n(riv)n 980 | (\023)-41 b(es.)71 2238 y(L'ex)n(\023)g(ecutable)37 b(g)n(\023)-41 981 | b(en)n(\023)g(er)n(\023)g(e)39 b(contient)f(une)g(table)f(de)h(relo)r 982 | (cation)71 2317 y(ca)n(r)d(on)h(veut)g(que)g(les)f(p)r(ointeurs)h(de)g 983 | (la)f(machine)f(virtuelle)71 2396 y(soient)28 b(compatibles)e(avec)j 984 | (les)f(p)r(ointeurs)h(r)n(\023)-41 b(eels.)p eop 985 | %%Page: 12 12 986 | 12 11 bop 71 290 a Fg(La)45 b(Machine)i(Virtuelle)p 71 987 | 427 1910 5 v 71 693 a Fi(C'est)32 b(une)g(machine)d(\022)-42 988 | b(a)31 b(pile.)g(Le)g(\014chier)h Ff(fbvmspec.)o(h)d 989 | Fi(donne)71 772 y(des)41 b(info)n(rmati)o(ons)d(vitales)i(sur)g(l'a)n 990 | (rchitecture)f(\()p Fe(endianit)n(\023)-41 b(e)p Fi(,)71 991 | 851 y(alignement,)31 b(taille)g(des)i(t)n(yp)r(es)h(de)g(base,)g(mo)r 992 | (d)n(\022)-41 b(ele)32 b(de)i(pile\).)71 930 y(On)g(a)g(supp)r(os)n 993 | (\023)-41 b(e)35 b(ici)e(p)r(our)h(simpli\014er)d(qu'un)j(p)r(ointeur)g 994 | (avait)71 1009 y(la)27 b(m)n(^)-41 b(eme)27 b(taille)f(qu'un)j 995 | Ff(int)p Fi(.)71 1166 y(Les)f(instructions:)71 1307 y 996 | Ff(lecture)33 b(m\023)-37 b(em.)108 b(:)37 b(ld_b,ld_)o(ub,)o(ld)o(_w)o 997 | (,ld)o(_u)o(w,l)o(d_)o(i)71 1386 y(\023)-37 b(ecriture)33 998 | b(m\023)-37 b(em.)71 b(:)37 b(st_b,st_)o(w,s)o(t_)o(i)71 999 | 1465 y(arithm\023)-37 b(et)o(iq)o(ues)69 b(:)37 b(add_i,su)o(b_i)o(,m)o 1000 | (ul)o(_i,)o(mu)o(l_u)o(i,)o(div)o(_i)o(,)693 1544 y(div_ui,m)o(od_)o 1001 | (i,)o(mo)o(d_u)o(i,)o(neg)o(_i)71 1623 y(comparai)o(so)o(ns)106 1002 | b(:)37 b(cmplt_i,)o(cmp)o(le)o(_i)o(,cm)o(pg)o(e_i)o(,c)o(mpg)o(t_)o 1003 | (i,)693 1702 y(cmpeq_i,)o(cmp)o(ne)o(_i)o(,)693 1781 1004 | y(cmplt_ui)o(,cm)o(pl)o(e_)o(ui,)o(cm)o(pge)o(_u)o(i,c)o(mp)o(gt)o(_ui) 1005 | 71 1859 y(logiques)252 b(:)37 b(and_i,or)o(_i,)o(xo)o(r_)o(i,n)o(ot)o 1006 | (_i,)693 1938 y(shl_i,sh)o(r_i)o(,s)o(hr)o(_ui)71 2017 1007 | y(conversi)o(on)o(s)143 b(:)37 b(cvt_i_b,)o(cvt)o(_i)o(_u)o(b,c)o(vt)o 1008 | (_i_)o(w,)o(cvt)o(_i)o(_u)o(w)71 2096 y(constant)o(es)179 1009 | b(:)37 b(li_i)e(n,libp_i)e(n)71 2175 y(sauts)363 b(:)37 1010 | b(jeq_i)d(n,jne_i)g(n,switch_)o(i,)o(jmp)f(n)71 2254 1011 | y(fonction)o(s)216 b(:)37 b(jsr)e(n,rts)71 2333 y(gestion)e(pile)108 1012 | b(:)37 b(dup,pop,)o(add)o(sp)c(n)71 2412 y(systeme)289 1013 | b(:)37 b(libcall)c(n)p eop 1014 | %%Page: 13 13 1015 | 13 12 bop 71 232 a Fg(R)m(\023)-65 b(esultats)47 b(-)f(Conclusion)p 1016 | 71 369 1910 5 v 144 666 a Fi({)41 b(Le)29 b(compilateur)c(se)k(compile) 1017 | d(lui-m)m(^)-41 b(eme,)25 b(et)k(la)e(version)228 745 1018 | y(compil)n(\023)-41 b(ee)42 b(se)h(recompile)e(elle-m)n(^)-41 1019 | b(eme)41 b(en)i(donnant)h(le)228 824 y(m)n(^)-41 b(eme)27 1020 | b(co)r(de.)j(La)e(vitesse)g(reste)h(raisonnable.)d(P)n(our)i(en)228 1021 | 902 y(a)n(rriver)20 b(l)o(\022)-42 b(a,)21 b(il)f(a)i(fallu)e(non)j 1022 | (seulement)e(r)n(\023)-41 b(ealiser)20 b(le)h(compi-)228 1023 | 981 y(lateur,)i(mais)e(aussi)h(fab)n(riquer)g(tout)i(un)g 1024 | (environnement)228 1060 y(de)29 b(compilation)d(et)j(d'ex)n(\023)-41 1025 | b(ecution.)144 1232 y({)41 b(Grande)e(complexit)n(\023)-41 1026 | b(e)37 b(du)i(t)n(ypage)g(en)g(C.)f(Finalement,)228 1311 1027 | y(un)i(compilateur)c(de)k(langage)e(plus)e(\023)-41 b(evolu)n(\023)g(e) 1028 | 39 b(doit)e(^)-41 b(etre)228 1390 y(pa)n(rado)n(xalement)26 1029 | b(plus)i(simple.)144 1562 y({)41 b(Le)25 b(choix)g(d'une)g(machine)d 1030 | (\022)-42 b(a)24 b(pile)g(n'a)g(pas)f(\023)-41 b(et)n(\023)g(e)25 1031 | b(optimal.)228 1641 y(Nous)f(p)r(ensions)g(ne)g(pas)g(avoir)f(le)g 1032 | (temps)h(de)g(g)n(\023)-41 b(en)n(\023)g(erer)24 b(du)228 1033 | 1720 y(co)r(de)34 b(interm)n(\023)-41 b(ediaire)30 b(puis)i(un)i(co)r 1034 | (de)g(assembleur)d(p)r(our)228 1799 y(une)24 b(machine)c(\022)-42 1035 | b(a)23 b(registres.)f(Finalement,)f(avec)i(le)g(recul,)228 1036 | 1878 y(si)39 b(un)g(tel)g(choix)g(avait)d(\023)-41 b(et)n(\023)g(e)40 1037 | b(fait)e(d)n(\022)-41 b(es)40 b(le)e(d)n(\023)-41 b(ebut,)40 1038 | b(nous)228 1957 y(aurions)32 b(pu)i(mener)d(\022)-42 1039 | b(a)33 b(bien)g(cette)i(t)o(^)-42 b(ache.)33 b(Cela)g(aurait)228 1040 | 2036 y(p)r(ermis)22 b(de)i(plus)f(travailler)e(sur)i(l'optimisa)o(tion) 1041 | d(du)k(co)r(de)228 2115 y(g)n(\023)-41 b(en)n(\023)g(er)n(\023)g(e.)144 1042 | 2287 y({)41 b(Il)36 b(faut)i(donc)f(plut^)-43 b(ot)36 1043 | b(voir)h(ce)g(p)n(rojet)f(comme)g(un)h(g)n(\023)-41 b(e-)228 1044 | 2366 y(n)n(\023)g(erateur)36 b(de)g(co)r(de)h(interm)n(\023)-41 1045 | b(ediaire)33 b(p)r(our)j(le)g(C)g(et)g(non)228 2445 y(comme)28 1046 | b(un)g(compilateur)e(complet.)p eop 1047 | %%Trailer 1048 | end 1049 | userdict /end-hook known{end-hook}if 1050 | %%EOF 1051 | -------------------------------------------------------------------------------- /doc/fbcc_slides.tex: -------------------------------------------------------------------------------- 1 | \documentstyle[french]{slides} 2 | 3 | \pagestyle{empty} 4 | 5 | % ligne horizontale 6 | \newcommand{\horizline}{\rule[\baselineskip]{\textwidth}{1pt}} 7 | 8 | % titre standard 9 | 10 | \newcommand{\pagetitle}[1]{ 11 | \typeout{#1} 12 | \begin{flushleft} 13 | {\large\bf #1} 14 | \end{flushleft} 15 | \horizline 16 | } 17 | 18 | \begin{document} 19 | 20 | \blackandwhite{fbcc1.tex} 21 | 22 | \end{document} 23 | 24 | -------------------------------------------------------------------------------- /fbas/Makefile: -------------------------------------------------------------------------------- 1 | all: fbas 2 | 3 | fbas: fbas.y lex.yy.c 4 | bison -o fbas.c fbas.y 5 | gcc -O2 -m32 -Wall -I. -I../fbvm fbas.c -o fbas 6 | 7 | lex.yy.c: fbas_lex.l 8 | flex fbas_lex.l 9 | 10 | clean: 11 | rm -f *.o *~ fbas.c lex.yy.c fbas 12 | -------------------------------------------------------------------------------- /fbas/dump: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | exec hexdump -e '"%06_ax " 16/1 "%02X " "\n"' $* 3 | -------------------------------------------------------------------------------- /fbas/fbMakefile: -------------------------------------------------------------------------------- 1 | 2 | # normal assembling 3 | PROG= ./fbfbas 4 | FBCC = ../fbcc/fbcc 5 | FBAS = ./fbas 6 | 7 | # testing of fbfbas 8 | #PROG= fbfbas1 9 | #FBCC = ../fbcc 10 | #FBAS= ../fbvm/fbvm fbfbas 11 | 12 | FBINCLUDE = -I../lib -I../fbvm 13 | FBLIBS = ../lib/startup.ss ../lib/fblib.s ../lib/getopt.s 14 | OBJS = fbas.s 15 | all: $(PROG) 16 | 17 | $(PROG): $(OBJS) 18 | cat $(FBLIBS) $(OBJS) | $(FBAS) -o $(PROG) 19 | 20 | fbas.c: fbas.y lex.yy.c 21 | bison -o fbas.c fbas.y 22 | 23 | lex.yy.c: fbas_lex.l 24 | flex fbas_lex.l 25 | 26 | clean: 27 | rm -f *.s *.i 28 | 29 | .c.s: 30 | gcc -U__GNUC__ -E $(FBINCLUDE) $*.c >$*.i 31 | $(FBCC) < $*.i > $*.s 32 | 33 | -------------------------------------------------------------------------------- /fbas/fbas.y: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbas/fbas.y -------------------------------------------------------------------------------- /fbas/fbas_lex.l: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbas/fbas_lex.l -------------------------------------------------------------------------------- /fbcc/Makefile: -------------------------------------------------------------------------------- 1 | OBJS = fblist.o fbgen.o fbtype.o fbconst.o fberror.o fbsym.o fbparse.o fbcc.o 2 | CFLAGS = -m32 -g -Wall -O2 -I../fbvm 3 | LIBS = 4 | LFLAGS = -m32 5 | 6 | all: fbcc 7 | 8 | clean: 9 | rm -f *.o *.i *.s *~ fbcc fbfbcc fbfbcc1 lex.yy.c fbparse.c 10 | 11 | fbcc: $(OBJS) 12 | gcc -g $(OBJS) $(LFLAGS) -o fbcc $(LIBS) 13 | 14 | fbsym.o: fbsym.c fbcc.h 15 | 16 | fblist.o: fblist.c fbcc.h 17 | 18 | fbtype.o: fbtype.c fbcc.h 19 | 20 | fbgen.o: fbgen.c fbcc.h 21 | 22 | fbconst.o: fbconst.c fbcc.h 23 | 24 | lex.yy.c: fblex.l fbcc.h 25 | flex fblex.l 26 | 27 | fbparse.c: lex.yy.c fbparse.y fbcc.h 28 | bison -o fbparse.c fbparse.y 29 | 30 | .c.o: 31 | gcc $(CFLAGS) -c $*.c 32 | 33 | -------------------------------------------------------------------------------- /fbcc/fbMakefile: -------------------------------------------------------------------------------- 1 | # 2 | # For bootstrapping: fbcc compiles itself. 3 | # 4 | FBCC= ./fbcc 5 | PROG = ./fbfbcc 6 | 7 | # 8 | # For testing: fbcc compiled with itself compiles itself :) 9 | # 10 | #PROG= fbfbcc1 11 | #FBCC = ../fbvm/fbvm fbfbcc 12 | 13 | FBAS = ../fbas/fbas 14 | FBINCLUDE = -I../lib -I../fbvm 15 | FBLIBS = ../lib/startup.ss ../lib/fblib.s 16 | OBJS = fblist.s fbgen.s fbtype.s fbconst.s fberror.s fbsym.s fbcc.s fbparse.s 17 | 18 | all: $(PROG) 19 | 20 | # 21 | # assembling & linking 22 | # 23 | $(PROG): $(OBJS) 24 | cat $(FBLIBS) $(OBJS) | $(FBAS) -o $(PROG) 25 | 26 | clean: 27 | rm -f *.s *.i 28 | 29 | # 30 | # we use gcc (cpp) for preprocessing 31 | # 32 | .c.s: 33 | gcc -U__GNUC__ -E $(FBINCLUDE) $*.c >$*.i 34 | $(FBCC) < $*.i > $*.s 35 | -------------------------------------------------------------------------------- /fbcc/fbcc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbcc.c -------------------------------------------------------------------------------- /fbcc/fbcc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbcc.h -------------------------------------------------------------------------------- /fbcc/fbconst.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbconst.c -------------------------------------------------------------------------------- /fbcc/fberror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FBCC - A simple C compiler. 3 | * 4 | * Copyright (c) 1996 Fabrice Bellard 5 | * 6 | * Contact addresses: 7 | * mail: Fabrice Bellard, 451 chemin du mas de Matour, 34790 Grabels, France 8 | * email: bellard@email.enst.fr 9 | * url: http://www.enst.fr/~bellard 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 | */ 25 | #include 26 | #include 27 | #include 28 | #include "fbcc.h" 29 | 30 | int debug_print_expr=0; 31 | 32 | int errors_nb; 33 | int line_current; 34 | 35 | void Error(char *format,...) 36 | { 37 | va_list ap; 38 | 39 | errors_nb++; 40 | fprintf(stderr,"Error #%d line %d: ",errors_nb,line_current); 41 | 42 | va_start(ap,format); 43 | vfprintf(stderr,format,ap); 44 | va_end(ap); 45 | 46 | fprintf(stderr,"\n"); 47 | exit(1); 48 | } 49 | 50 | void Warning(char *format,...) 51 | { 52 | va_list ap; 53 | 54 | errors_nb++; 55 | fprintf(stderr,"Warning line %d: ",line_current); 56 | 57 | va_start(ap,format); 58 | vfprintf(stderr,format,ap); 59 | va_end(ap); 60 | 61 | fprintf(stderr,"\n"); 62 | } 63 | 64 | 65 | void yyerror(char *str) 66 | { 67 | Error(str); 68 | } 69 | 70 | void Error_Internal(char *format,...) 71 | { 72 | va_list ap; 73 | 74 | fprintf(stderr,"Internal error line %d: ",line_current); 75 | 76 | va_start(ap,format); 77 | vfprintf(stderr,format,ap); 78 | va_end(ap); 79 | 80 | fprintf(stderr,"\n"); 81 | exit(1); 82 | } 83 | 84 | void ddprintf(char *format,...) 85 | { 86 | va_list ap; 87 | 88 | va_start(ap,format); 89 | vfprintf(stderr,format,ap); 90 | va_end(ap); 91 | 92 | } 93 | -------------------------------------------------------------------------------- /fbcc/fbgen.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbgen.c -------------------------------------------------------------------------------- /fbcc/fblex.l: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fblex.l -------------------------------------------------------------------------------- /fbcc/fblist.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fblist.c -------------------------------------------------------------------------------- /fbcc/fbobj.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbobj.c -------------------------------------------------------------------------------- /fbcc/fbparse.y: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbparse.y -------------------------------------------------------------------------------- /fbcc/fbsym.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbsym.c -------------------------------------------------------------------------------- /fbcc/fbtype.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbcc/fbtype.c -------------------------------------------------------------------------------- /fbvm/Makefile: -------------------------------------------------------------------------------- 1 | OBJS = fbvm.o 2 | CFLAGS = -g -Wall -O2 -m32 3 | LIBS = 4 | LFLAGS = -m32 5 | 6 | all: fbvm 7 | 8 | clean: 9 | rm -f *.o *~ fbvm fbvmspec.h 10 | 11 | # Use the i386 version by default 12 | fbvmspec.h: fbvmspec_i386.h 13 | cp fbvmspec_i386.h fbvmspec.h 14 | 15 | fbvm.o: fbvm.c fbvmspec.h fbvminstr.h 16 | 17 | fbvm: $(OBJS) 18 | gcc -g $(OBJS) $(LFLAGS) -o fbvm $(LIBS) 19 | 20 | .c.o: 21 | gcc $(CFLAGS) -c $*.c 22 | 23 | -------------------------------------------------------------------------------- /fbvm/fbvm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbvm/fbvm.c -------------------------------------------------------------------------------- /fbvm/fbvminstr.h: -------------------------------------------------------------------------------- 1 | 2 | char *vm_instr_str[]= 3 | { 4 | "zero", 5 | "ld_b", 6 | "ld_ub", 7 | "ld_w", 8 | "ld_uw", 9 | "ld_i", 10 | 11 | "st_b", 12 | "st_w", 13 | "st_i", 14 | 15 | "add_i", 16 | "sub_i", 17 | "mul_i", 18 | "div_i", 19 | "div_ui", 20 | "mod_i", 21 | "mod_ui", 22 | "neg_i", 23 | 24 | "cmplt_i", 25 | "cmple_i", 26 | "cmpge_i", 27 | "cmpgt_i", 28 | "cmpeq_i", 29 | "cmpne_i", 30 | 31 | "cmplt_ui", 32 | "cmple_ui", 33 | "cmpge_ui", 34 | "cmpgt_ui", 35 | 36 | "and_i", 37 | "or_i", 38 | "xor_i", 39 | "not_i", 40 | "shl_i", 41 | "shr_i", 42 | "shr_ui", 43 | 44 | /* conversions */ 45 | "cvt_i_b", 46 | "cvt_i_ub", 47 | "cvt_i_w", 48 | "cvt_i_uw", 49 | 50 | "cvt_b_i", 51 | "cvt_w_i", 52 | 53 | 54 | "li_i", 55 | "libp_i", 56 | 57 | /* sauts conditionnels */ 58 | "jeq_i", 59 | "jne_i", 60 | "switch_i", 61 | 62 | /* sauts */ 63 | "jmp", 64 | 65 | /* appel de fonctions */ 66 | "jsr", 67 | "rts", 68 | 69 | /* gestion de la pile */ 70 | "dup", 71 | "pop", 72 | "addsp", 73 | 74 | "libcall", 75 | NULL, 76 | }; 77 | 78 | -------------------------------------------------------------------------------- /fbvm/fbvmspec_i386.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbvm/fbvmspec_i386.h -------------------------------------------------------------------------------- /fbvm/fbvmspec_sun4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/fbvm/fbvmspec_sun4.h -------------------------------------------------------------------------------- /lib/Makefile: -------------------------------------------------------------------------------- 1 | FBCC = ../fbcc/fbcc 2 | FBAS = ../fbas/fbas 3 | FBINCLUDE = . 4 | FBLIBS = startup.ss fblib.s 5 | 6 | all: fblib.s getopt.s 7 | 8 | # 9 | # getopt.c 10 | # 11 | getopt.s: getopt.c 12 | 13 | # 14 | # stdlib 15 | # 16 | fblib.s: fblib.c 17 | 18 | 19 | clean: 20 | rm -f *.s *.i *~ 21 | 22 | .c.s: 23 | gcc -E -I$(FBINCLUDE) $*.c >$*.i 24 | $(FBCC) < $*.i > $*.s 25 | -------------------------------------------------------------------------------- /lib/fblib.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/lib/fblib.c -------------------------------------------------------------------------------- /lib/getopt.c: -------------------------------------------------------------------------------- 1 | /* Getopt for GNU. 2 | NOTE: getopt is now part of the C library, so if you don't know what 3 | "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu 4 | before changing it! 5 | 6 | Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 7 | Free Software Foundation, Inc. 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 22 | 23 | /* This tells Alpha OSF/1 not to define a getopt prototype in . 24 | Ditto for AIX 3.2 and . */ 25 | #ifndef _NO_PROTO 26 | #define _NO_PROTO 27 | #endif 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include 31 | #endif 32 | 33 | #if !defined (__STDC__) || !__STDC__ 34 | /* This is a separate conditional since some stdc systems 35 | reject `defined (const)'. */ 36 | #ifndef const 37 | #define const 38 | #endif 39 | #endif 40 | 41 | #include 42 | 43 | /* Comment out all this code if we are using the GNU C Library, and are not 44 | actually compiling the library itself. This code is part of the GNU C 45 | Library, but also included in many other GNU distributions. Compiling 46 | and linking in this code is a waste when using the GNU C library 47 | (especially if it is a shared library). Rather than having every GNU 48 | program understand `configure --with-gnu-libc' and omit the object files, 49 | it is simpler to just do this in the source for each such file. */ 50 | 51 | #if defined (_LIBC) || !defined (__GNU_LIBRARY__) 52 | 53 | 54 | /* This needs to come after some library #include 55 | to get __GNU_LIBRARY__ defined. */ 56 | #ifdef __GNU_LIBRARY__ 57 | /* Don't include stdlib.h for non-GNU C libraries because some of them 58 | contain conflicting prototypes for getopt. */ 59 | #include 60 | #endif /* GNU C library. */ 61 | 62 | /* This is for other GNU distributions with internationalized messages. 63 | The GNU C Library itself does not yet support such messages. */ 64 | #if HAVE_LIBINTL_H 65 | # include 66 | #else 67 | # define gettext(msgid) (msgid) 68 | #endif 69 | 70 | /* This version of `getopt' appears to the caller like standard Unix `getopt' 71 | but it behaves differently for the user, since it allows the user 72 | to intersperse the options with the other arguments. 73 | 74 | As `getopt' works, it permutes the elements of ARGV so that, 75 | when it is done, all the options precede everything else. Thus 76 | all application programs are extended to handle flexible argument order. 77 | 78 | Setting the environment variable POSIXLY_CORRECT disables permutation. 79 | Then the behavior is completely standard. 80 | 81 | GNU application programs can use a third alternative mode in which 82 | they can distinguish the relative order of options and other arguments. */ 83 | 84 | #include "getopt.h" 85 | 86 | /* For communication from `getopt' to the caller. 87 | When `getopt' finds an option that takes an argument, 88 | the argument value is returned here. 89 | Also, when `ordering' is RETURN_IN_ORDER, 90 | each non-option ARGV-element is returned here. */ 91 | 92 | char *optarg = NULL; 93 | 94 | /* Index in ARGV of the next element to be scanned. 95 | This is used for communication to and from the caller 96 | and for communication between successive calls to `getopt'. 97 | 98 | On entry to `getopt', zero means this is the first call; initialize. 99 | 100 | When `getopt' returns EOF, this is the index of the first of the 101 | non-option elements that the caller should itself scan. 102 | 103 | Otherwise, `optind' communicates from one call to the next 104 | how much of ARGV has been scanned so far. */ 105 | 106 | /* XXX 1003.2 says this must be 1 before any call. */ 107 | int optind = 0; 108 | 109 | /* The next char to be scanned in the option-element 110 | in which the last option character we returned was found. 111 | This allows us to pick up the scan where we left off. 112 | 113 | If this is zero, or a null string, it means resume the scan 114 | by advancing to the next ARGV-element. */ 115 | 116 | static char *nextchar; 117 | 118 | /* Callers store zero here to inhibit the error message 119 | for unrecognized options. */ 120 | 121 | int opterr = 1; 122 | 123 | /* Set to an option character which was unrecognized. 124 | This must be initialized on some systems to avoid linking in the 125 | system's own getopt implementation. */ 126 | 127 | int optopt = '?'; 128 | 129 | /* Describe how to deal with options that follow non-option ARGV-elements. 130 | 131 | If the caller did not specify anything, 132 | the default is REQUIRE_ORDER if the environment variable 133 | POSIXLY_CORRECT is defined, PERMUTE otherwise. 134 | 135 | REQUIRE_ORDER means don't recognize them as options; 136 | stop option processing when the first non-option is seen. 137 | This is what Unix does. 138 | This mode of operation is selected by either setting the environment 139 | variable POSIXLY_CORRECT, or using `+' as the first character 140 | of the list of option characters. 141 | 142 | PERMUTE is the default. We permute the contents of ARGV as we scan, 143 | so that eventually all the non-options are at the end. This allows options 144 | to be given in any order, even with programs that were not written to 145 | expect this. 146 | 147 | RETURN_IN_ORDER is an option available to programs that were written 148 | to expect options and other ARGV-elements in any order and that care about 149 | the ordering of the two. We describe each non-option ARGV-element 150 | as if it were the argument of an option with character code 1. 151 | Using `-' as the first character of the list of option characters 152 | selects this mode of operation. 153 | 154 | The special argument `--' forces an end of option-scanning regardless 155 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only 156 | `--' can cause `getopt' to return EOF with `optind' != ARGC. */ 157 | 158 | static enum 159 | { 160 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER 161 | } ordering; 162 | 163 | /* Value of POSIXLY_CORRECT environment variable. */ 164 | static char *posixly_correct; 165 | 166 | /* #ifdef __GNU_LIBRARY__ */ 167 | #if 1 168 | /* We want to avoid inclusion of string.h with non-GNU libraries 169 | because there are many ways it can cause trouble. 170 | On some systems, it contains special magic macros that don't work 171 | in GCC. */ 172 | #include 173 | #define my_index strchr 174 | #else 175 | 176 | /* Avoid depending on library functions or files 177 | whose names are inconsistent. */ 178 | 179 | char *getenv (); 180 | 181 | static char * 182 | my_index (str, chr) 183 | const char *str; 184 | int chr; 185 | { 186 | while (*str) 187 | { 188 | if (*str == chr) 189 | return (char *) str; 190 | str++; 191 | } 192 | return 0; 193 | } 194 | 195 | /* If using GCC, we can safely declare strlen this way. 196 | If not using GCC, it is ok not to declare it. */ 197 | #ifdef __GNUC__ 198 | /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. 199 | That was relevant to code that was here before. */ 200 | #if !defined (__STDC__) || !__STDC__ 201 | /* gcc with -traditional declares the built-in strlen to return int, 202 | and has done so at least since version 2.4.5. -- rms. */ 203 | extern int strlen (const char *); 204 | #endif /* not __STDC__ */ 205 | #endif /* __GNUC__ */ 206 | 207 | #endif /* not __GNU_LIBRARY__ */ 208 | 209 | /* Handle permutation of arguments. */ 210 | 211 | /* Describe the part of ARGV that contains non-options that have 212 | been skipped. `first_nonopt' is the index in ARGV of the first of them; 213 | `last_nonopt' is the index after the last of them. */ 214 | 215 | static int first_nonopt; 216 | static int last_nonopt; 217 | 218 | /* Exchange two adjacent subsequences of ARGV. 219 | One subsequence is elements [first_nonopt,last_nonopt) 220 | which contains all the non-options that have been skipped so far. 221 | The other is elements [last_nonopt,optind), which contains all 222 | the options processed since those non-options were skipped. 223 | 224 | `first_nonopt' and `last_nonopt' are relocated so that they describe 225 | the new indices of the non-options in ARGV after they are moved. */ 226 | 227 | static void 228 | exchange (argv) 229 | char **argv; 230 | { 231 | int bottom = first_nonopt; 232 | int middle = last_nonopt; 233 | int top = optind; 234 | char *tem; 235 | 236 | /* Exchange the shorter segment with the far end of the longer segment. 237 | That puts the shorter segment into the right place. 238 | It leaves the longer segment in the right place overall, 239 | but it consists of two parts that need to be swapped next. */ 240 | 241 | while (top > middle && middle > bottom) 242 | { 243 | if (top - middle > middle - bottom) 244 | { 245 | /* Bottom segment is the short one. */ 246 | int len = middle - bottom; 247 | register int i; 248 | 249 | /* Swap it with the top part of the top segment. */ 250 | for (i = 0; i < len; i++) 251 | { 252 | tem = argv[bottom + i]; 253 | argv[bottom + i] = argv[top - (middle - bottom) + i]; 254 | argv[top - (middle - bottom) + i] = tem; 255 | } 256 | /* Exclude the moved bottom segment from further swapping. */ 257 | top -= len; 258 | } 259 | else 260 | { 261 | /* Top segment is the short one. */ 262 | int len = top - middle; 263 | register int i; 264 | 265 | /* Swap it with the bottom part of the bottom segment. */ 266 | for (i = 0; i < len; i++) 267 | { 268 | tem = argv[bottom + i]; 269 | argv[bottom + i] = argv[middle + i]; 270 | argv[middle + i] = tem; 271 | } 272 | /* Exclude the moved top segment from further swapping. */ 273 | bottom += len; 274 | } 275 | } 276 | 277 | /* Update records for the slots the non-options now occupy. */ 278 | 279 | first_nonopt += (optind - last_nonopt); 280 | last_nonopt = optind; 281 | } 282 | 283 | /* Initialize the internal data when the first call is made. */ 284 | 285 | static const char * 286 | _getopt_initialize (optstring) 287 | const char *optstring; 288 | { 289 | /* Start processing options with ARGV-element 1 (since ARGV-element 0 290 | is the program name); the sequence of previously skipped 291 | non-option ARGV-elements is empty. */ 292 | 293 | first_nonopt = last_nonopt = optind = 1; 294 | 295 | nextchar = NULL; 296 | 297 | posixly_correct = getenv ("POSIXLY_CORRECT"); 298 | 299 | /* Determine how to handle the ordering of options and nonoptions. */ 300 | 301 | if (optstring[0] == '-') 302 | { 303 | ordering = RETURN_IN_ORDER; 304 | ++optstring; 305 | } 306 | else if (optstring[0] == '+') 307 | { 308 | ordering = REQUIRE_ORDER; 309 | ++optstring; 310 | } 311 | else if (posixly_correct != NULL) 312 | ordering = REQUIRE_ORDER; 313 | else 314 | ordering = PERMUTE; 315 | return optstring; 316 | } 317 | 318 | /* Scan elements of ARGV (whose length is ARGC) for option characters 319 | given in OPTSTRING. 320 | 321 | If an element of ARGV starts with '-', and is not exactly "-" or "--", 322 | then it is an option element. The characters of this element 323 | (aside from the initial '-') are option characters. If `getopt' 324 | is called repeatedly, it returns successively each of the option characters 325 | from each of the option elements. 326 | 327 | If `getopt' finds another option character, it returns that character, 328 | updating `optind' and `nextchar' so that the next call to `getopt' can 329 | resume the scan with the following option character or ARGV-element. 330 | 331 | If there are no more option characters, `getopt' returns `EOF'. 332 | Then `optind' is the index in ARGV of the first ARGV-element 333 | that is not an option. (The ARGV-elements have been permuted 334 | so that those that are not options now come last.) 335 | 336 | OPTSTRING is a string containing the legitimate option characters. 337 | If an option character is seen that is not listed in OPTSTRING, 338 | return '?' after printing an error message. If you set `opterr' to 339 | zero, the error message is suppressed but we still return '?'. 340 | 341 | If a char in OPTSTRING is followed by a colon, that means it wants an arg, 342 | so the following text in the same ARGV-element, or the text of the following 343 | ARGV-element, is returned in `optarg'. Two colons mean an option that 344 | wants an optional arg; if there is text in the current ARGV-element, 345 | it is returned in `optarg', otherwise `optarg' is set to zero. 346 | 347 | If OPTSTRING starts with `-' or `+', it requests different methods of 348 | handling the non-option ARGV-elements. 349 | See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. 350 | 351 | Long-named options begin with `--' instead of `-'. 352 | Their names may be abbreviated as long as the abbreviation is unique 353 | or is an exact match for some defined option. If they have an 354 | argument, it follows the option name in the same ARGV-element, separated 355 | from the option name by a `=', or else the in next ARGV-element. 356 | When `getopt' finds a long-named option, it returns 0 if that option's 357 | `flag' field is nonzero, the value of the option's `val' field 358 | if the `flag' field is zero. 359 | 360 | The elements of ARGV aren't really const, because we permute them. 361 | But we pretend they're const in the prototype to be compatible 362 | with other systems. 363 | 364 | LONGOPTS is a vector of `struct option' terminated by an 365 | element containing a name which is zero. 366 | 367 | LONGIND returns the index in LONGOPT of the long-named option found. 368 | It is only valid when a long-named option has been found by the most 369 | recent call. 370 | 371 | If LONG_ONLY is nonzero, '-' as well as '--' can introduce 372 | long-named options. */ 373 | 374 | int 375 | _getopt_internal (argc, argv, optstring, longopts, longind, long_only) 376 | int argc; 377 | char *const *argv; 378 | const char *optstring; 379 | const struct option *longopts; 380 | int *longind; 381 | int long_only; 382 | { 383 | optarg = NULL; 384 | 385 | if (optind == 0) 386 | { 387 | optstring = _getopt_initialize (optstring); 388 | optind = 1; /* Don't scan ARGV[0], the program name. */ 389 | } 390 | 391 | if (nextchar == NULL || *nextchar == '\0') 392 | { 393 | /* Advance to the next ARGV-element. */ 394 | 395 | if (ordering == PERMUTE) 396 | { 397 | /* If we have just processed some options following some non-options, 398 | exchange them so that the options come first. */ 399 | 400 | if (first_nonopt != last_nonopt && last_nonopt != optind) 401 | exchange ((char **) argv); 402 | else if (last_nonopt != optind) 403 | first_nonopt = optind; 404 | 405 | /* Skip any additional non-options 406 | and extend the range of non-options previously skipped. */ 407 | 408 | while (optind < argc 409 | && (argv[optind][0] != '-' || argv[optind][1] == '\0')) 410 | optind++; 411 | 412 | last_nonopt = optind; 413 | } 414 | 415 | /* The special ARGV-element `--' means premature end of options. 416 | Skip it like a null option, 417 | then exchange with previous non-options as if it were an option, 418 | then skip everything else like a non-option. */ 419 | 420 | if (optind != argc && !strcmp (argv[optind], "--")) 421 | { 422 | optind++; 423 | 424 | if (first_nonopt != last_nonopt && last_nonopt != optind) 425 | exchange ((char **) argv); 426 | else if (first_nonopt == last_nonopt) 427 | first_nonopt = optind; 428 | last_nonopt = argc; 429 | 430 | optind = argc; 431 | } 432 | 433 | /* If we have done all the ARGV-elements, stop the scan 434 | and back over any non-options that we skipped and permuted. */ 435 | 436 | if (optind == argc) 437 | { 438 | /* Set the next-arg-index to point at the non-options 439 | that we previously skipped, so the caller will digest them. */ 440 | if (first_nonopt != last_nonopt) 441 | optind = first_nonopt; 442 | return EOF; 443 | } 444 | 445 | /* If we have come to a non-option and did not permute it, 446 | either stop the scan or describe it to the caller and pass it by. */ 447 | 448 | if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) 449 | { 450 | if (ordering == REQUIRE_ORDER) 451 | return EOF; 452 | optarg = argv[optind++]; 453 | return 1; 454 | } 455 | 456 | /* We have found another option-ARGV-element. 457 | Skip the initial punctuation. */ 458 | 459 | nextchar = (argv[optind] + 1 460 | + (longopts != NULL && argv[optind][1] == '-')); 461 | } 462 | 463 | /* Decode the current option-ARGV-element. */ 464 | 465 | /* Check whether the ARGV-element is a long option. 466 | 467 | If long_only and the ARGV-element has the form "-f", where f is 468 | a valid short option, don't consider it an abbreviated form of 469 | a long option that starts with f. Otherwise there would be no 470 | way to give the -f short option. 471 | 472 | On the other hand, if there's a long option "fubar" and 473 | the ARGV-element is "-fu", do consider that an abbreviation of 474 | the long option, just like "--fu", and not "-f" with arg "u". 475 | 476 | This distinction seems to be the most useful approach. */ 477 | 478 | if (longopts != NULL 479 | && (argv[optind][1] == '-' 480 | || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) 481 | { 482 | char *nameend; 483 | const struct option *p; 484 | const struct option *pfound = NULL; 485 | int exact = 0; 486 | int ambig = 0; 487 | int indfound; 488 | int option_index; 489 | 490 | for (nameend = nextchar; *nameend && *nameend != '='; nameend++) 491 | /* Do nothing. */ ; 492 | 493 | /* Test all long options for either exact match 494 | or abbreviated matches. */ 495 | for (p = longopts, option_index = 0; p->name; p++, option_index++) 496 | if (!strncmp (p->name, nextchar, nameend - nextchar)) 497 | { 498 | if (nameend - nextchar == strlen (p->name)) 499 | { 500 | /* Exact match found. */ 501 | pfound = p; 502 | indfound = option_index; 503 | exact = 1; 504 | break; 505 | } 506 | else if (pfound == NULL) 507 | { 508 | /* First nonexact match found. */ 509 | pfound = p; 510 | indfound = option_index; 511 | } 512 | else 513 | /* Second or later nonexact match found. */ 514 | ambig = 1; 515 | } 516 | 517 | if (ambig && !exact) 518 | { 519 | if (opterr) 520 | fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"), 521 | argv[0], argv[optind]); 522 | nextchar += strlen (nextchar); 523 | optind++; 524 | return '?'; 525 | } 526 | 527 | if (pfound != NULL) 528 | { 529 | option_index = indfound; 530 | optind++; 531 | if (*nameend) 532 | { 533 | /* Don't test has_arg with >, because some C compilers don't 534 | allow it to be used on enums. */ 535 | if (pfound->has_arg) 536 | optarg = nameend + 1; 537 | else 538 | { 539 | if (opterr) 540 | if (argv[optind - 1][1] == '-') 541 | /* --option */ 542 | fprintf (stderr, 543 | gettext ("%s: option `--%s' doesn't allow an argument\n"), 544 | argv[0], pfound->name); 545 | else 546 | /* +option or -option */ 547 | fprintf (stderr, 548 | gettext ("%s: option `%c%s' doesn't allow an argument\n"), 549 | argv[0], argv[optind - 1][0], pfound->name); 550 | 551 | nextchar += strlen (nextchar); 552 | return '?'; 553 | } 554 | } 555 | else if (pfound->has_arg == 1) 556 | { 557 | if (optind < argc) 558 | optarg = argv[optind++]; 559 | else 560 | { 561 | if (opterr) 562 | fprintf (stderr, 563 | gettext ("%s: option `%s' requires an argument\n"), 564 | argv[0], argv[optind - 1]); 565 | nextchar += strlen (nextchar); 566 | return optstring[0] == ':' ? ':' : '?'; 567 | } 568 | } 569 | nextchar += strlen (nextchar); 570 | if (longind != NULL) 571 | *longind = option_index; 572 | if (pfound->flag) 573 | { 574 | *(pfound->flag) = pfound->val; 575 | return 0; 576 | } 577 | return pfound->val; 578 | } 579 | 580 | /* Can't find it as a long option. If this is not getopt_long_only, 581 | or the option starts with '--' or is not a valid short 582 | option, then it's an error. 583 | Otherwise interpret it as a short option. */ 584 | if (!long_only || argv[optind][1] == '-' 585 | || my_index (optstring, *nextchar) == NULL) 586 | { 587 | if (opterr) 588 | { 589 | if (argv[optind][1] == '-') 590 | /* --option */ 591 | fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"), 592 | argv[0], nextchar); 593 | else 594 | /* +option or -option */ 595 | fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"), 596 | argv[0], argv[optind][0], nextchar); 597 | } 598 | nextchar = (char *) ""; 599 | optind++; 600 | return '?'; 601 | } 602 | } 603 | 604 | /* Look at and handle the next short option-character. */ 605 | 606 | { 607 | char c = *nextchar++; 608 | char *temp = my_index (optstring, c); 609 | 610 | /* Increment `optind' when we start to process its last character. */ 611 | if (*nextchar == '\0') 612 | ++optind; 613 | 614 | if (temp == NULL || c == ':') 615 | { 616 | if (opterr) 617 | { 618 | if (posixly_correct) 619 | /* 1003.2 specifies the format of this message. */ 620 | fprintf (stderr, gettext ("%s: illegal option -- %c\n"), 621 | argv[0], c); 622 | else 623 | fprintf (stderr, gettext ("%s: invalid option -- %c\n"), 624 | argv[0], c); 625 | } 626 | optopt = c; 627 | return '?'; 628 | } 629 | if (temp[1] == ':') 630 | { 631 | if (temp[2] == ':') 632 | { 633 | /* This is an option that accepts an argument optionally. */ 634 | if (*nextchar != '\0') 635 | { 636 | optarg = nextchar; 637 | optind++; 638 | } 639 | else 640 | optarg = NULL; 641 | nextchar = NULL; 642 | } 643 | else 644 | { 645 | /* This is an option that requires an argument. */ 646 | if (*nextchar != '\0') 647 | { 648 | optarg = nextchar; 649 | /* If we end this ARGV-element by taking the rest as an arg, 650 | we must advance to the next element now. */ 651 | optind++; 652 | } 653 | else if (optind == argc) 654 | { 655 | if (opterr) 656 | { 657 | /* 1003.2 specifies the format of this message. */ 658 | fprintf (stderr, 659 | gettext ("%s: option requires an argument -- %c\n"), 660 | argv[0], c); 661 | } 662 | optopt = c; 663 | if (optstring[0] == ':') 664 | c = ':'; 665 | else 666 | c = '?'; 667 | } 668 | else 669 | /* We already incremented `optind' once; 670 | increment it again when taking next ARGV-elt as argument. */ 671 | optarg = argv[optind++]; 672 | nextchar = NULL; 673 | } 674 | } 675 | return c; 676 | } 677 | } 678 | 679 | int 680 | getopt (argc, argv, optstring) 681 | int argc; 682 | char *const *argv; 683 | const char *optstring; 684 | { 685 | return _getopt_internal (argc, argv, optstring, 686 | (const struct option *) 0, 687 | (int *) 0, 688 | 0); 689 | } 690 | 691 | #endif /* _LIBC or not __GNU_LIBRARY__. */ 692 | 693 | #ifdef TEST 694 | 695 | /* Compile with -DTEST to make an executable for use in testing 696 | the above definition of `getopt'. */ 697 | 698 | int 699 | main (argc, argv) 700 | int argc; 701 | char **argv; 702 | { 703 | int c; 704 | int digit_optind = 0; 705 | 706 | while (1) 707 | { 708 | int this_option_optind = optind ? optind : 1; 709 | 710 | c = getopt (argc, argv, "abc:d:0123456789"); 711 | if (c == EOF) 712 | break; 713 | 714 | switch (c) 715 | { 716 | case '0': 717 | case '1': 718 | case '2': 719 | case '3': 720 | case '4': 721 | case '5': 722 | case '6': 723 | case '7': 724 | case '8': 725 | case '9': 726 | if (digit_optind != 0 && digit_optind != this_option_optind) 727 | printf ("digits occur in two different argv-elements.\n"); 728 | digit_optind = this_option_optind; 729 | printf ("option %c\n", c); 730 | break; 731 | 732 | case 'a': 733 | printf ("option a\n"); 734 | break; 735 | 736 | case 'b': 737 | printf ("option b\n"); 738 | break; 739 | 740 | case 'c': 741 | printf ("option c with value `%s'\n", optarg); 742 | break; 743 | 744 | case '?': 745 | break; 746 | 747 | default: 748 | printf ("?? getopt returned character code 0%o ??\n", c); 749 | } 750 | } 751 | 752 | if (optind < argc) 753 | { 754 | printf ("non-option ARGV-elements: "); 755 | while (optind < argc) 756 | printf ("%s ", argv[optind++]); 757 | printf ("\n"); 758 | } 759 | 760 | exit (0); 761 | } 762 | 763 | #endif /* TEST */ 764 | -------------------------------------------------------------------------------- /lib/getopt.h: -------------------------------------------------------------------------------- 1 | /* Declarations for getopt. 2 | Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc. 3 | 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms of the GNU General Public License as published by the 6 | Free Software Foundation; either version 2, or (at your option) any 7 | later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 17 | 18 | #ifndef _GETOPT_H 19 | #define _GETOPT_H 1 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* For communication from `getopt' to the caller. 26 | When `getopt' finds an option that takes an argument, 27 | the argument value is returned here. 28 | Also, when `ordering' is RETURN_IN_ORDER, 29 | each non-option ARGV-element is returned here. */ 30 | 31 | extern char *optarg; 32 | 33 | /* Index in ARGV of the next element to be scanned. 34 | This is used for communication to and from the caller 35 | and for communication between successive calls to `getopt'. 36 | 37 | On entry to `getopt', zero means this is the first call; initialize. 38 | 39 | When `getopt' returns EOF, this is the index of the first of the 40 | non-option elements that the caller should itself scan. 41 | 42 | Otherwise, `optind' communicates from one call to the next 43 | how much of ARGV has been scanned so far. */ 44 | 45 | extern int optind; 46 | 47 | /* Callers store zero here to inhibit the error message `getopt' prints 48 | for unrecognized options. */ 49 | 50 | extern int opterr; 51 | 52 | /* Set to an option character which was unrecognized. */ 53 | 54 | extern int optopt; 55 | 56 | /* Describe the long-named options requested by the application. 57 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 58 | of `struct option' terminated by an element containing a name which is 59 | zero. 60 | 61 | The field `has_arg' is: 62 | no_argument (or 0) if the option does not take an argument, 63 | required_argument (or 1) if the option requires an argument, 64 | optional_argument (or 2) if the option takes an optional argument. 65 | 66 | If the field `flag' is not NULL, it points to a variable that is set 67 | to the value given in the field `val' when the option is found, but 68 | left unchanged if the option is not found. 69 | 70 | To have a long-named option do something other than set an `int' to 71 | a compiled-in constant, such as set a value from `optarg', set the 72 | option's `flag' field to zero and its `val' field to a nonzero 73 | value (the equivalent single-letter option character, if there is 74 | one). For long options that have a zero `flag' field, `getopt' 75 | returns the contents of the `val' field. */ 76 | 77 | struct option 78 | { 79 | #if defined (__STDC__) && __STDC__ 80 | const char *name; 81 | #else 82 | char *name; 83 | #endif 84 | /* has_arg can't be an enum because some compilers complain about 85 | type mismatches in all the code that assumes it is an int. */ 86 | int has_arg; 87 | int *flag; 88 | int val; 89 | }; 90 | 91 | /* Names for the values of the `has_arg' field of `struct option'. */ 92 | 93 | #define no_argument 0 94 | #define required_argument 1 95 | #define optional_argument 2 96 | 97 | #if defined (__STDC__) && __STDC__ 98 | #ifdef __GNU_LIBRARY__ 99 | /* Many other libraries have conflicting prototypes for getopt, with 100 | differences in the consts, in stdlib.h. To avoid compilation 101 | errors, only prototype getopt for the GNU C library. */ 102 | extern int getopt (int argc, char *const *argv, const char *shortopts); 103 | #else /* not __GNU_LIBRARY__ */ 104 | extern int getopt (); 105 | #endif /* __GNU_LIBRARY__ */ 106 | extern int getopt_long (int argc, char *const *argv, const char *shortopts, 107 | const struct option *longopts, int *longind); 108 | extern int getopt_long_only (int argc, char *const *argv, 109 | const char *shortopts, 110 | const struct option *longopts, int *longind); 111 | 112 | /* Internal only. Users should not call this directly. */ 113 | extern int _getopt_internal (int argc, char *const *argv, 114 | const char *shortopts, 115 | const struct option *longopts, int *longind, 116 | int long_only); 117 | #else /* not __STDC__ */ 118 | extern int getopt (); 119 | extern int getopt_long (); 120 | extern int getopt_long_only (); 121 | 122 | extern int _getopt_internal (); 123 | #endif /* __STDC__ */ 124 | 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | 129 | #endif /* _GETOPT_H */ 130 | -------------------------------------------------------------------------------- /lib/getopt1.c: -------------------------------------------------------------------------------- 1 | /* getopt_long and getopt_long_only entry points for GNU getopt. 2 | Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994 3 | Free Software Foundation, Inc. 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the 7 | Free Software Foundation; either version 2, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18 | 19 | #ifdef HAVE_CONFIG_H 20 | #include 21 | #endif 22 | 23 | #include "getopt.h" 24 | 25 | #if !defined (__STDC__) || !__STDC__ 26 | /* This is a separate conditional since some stdc systems 27 | reject `defined (const)'. */ 28 | #ifndef const 29 | #define const 30 | #endif 31 | #endif 32 | 33 | #include 34 | 35 | /* Comment out all this code if we are using the GNU C Library, and are not 36 | actually compiling the library itself. This code is part of the GNU C 37 | Library, but also included in many other GNU distributions. Compiling 38 | and linking in this code is a waste when using the GNU C library 39 | (especially if it is a shared library). Rather than having every GNU 40 | program understand `configure --with-gnu-libc' and omit the object files, 41 | it is simpler to just do this in the source for each such file. */ 42 | 43 | #if defined (_LIBC) || !defined (__GNU_LIBRARY__) 44 | 45 | 46 | /* This needs to come after some library #include 47 | to get __GNU_LIBRARY__ defined. */ 48 | #ifdef __GNU_LIBRARY__ 49 | #include 50 | #else 51 | char *getenv (); 52 | #endif 53 | 54 | #ifndef NULL 55 | #define NULL 0 56 | #endif 57 | 58 | int 59 | getopt_long (argc, argv, options, long_options, opt_index) 60 | int argc; 61 | char *const *argv; 62 | const char *options; 63 | const struct option *long_options; 64 | int *opt_index; 65 | { 66 | return _getopt_internal (argc, argv, options, long_options, opt_index, 0); 67 | } 68 | 69 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. 70 | If an option that starts with '-' (not '--') doesn't match a long option, 71 | but does match a short option, it is parsed as a short option 72 | instead. */ 73 | 74 | int 75 | getopt_long_only (argc, argv, options, long_options, opt_index) 76 | int argc; 77 | char *const *argv; 78 | const char *options; 79 | const struct option *long_options; 80 | int *opt_index; 81 | { 82 | return _getopt_internal (argc, argv, options, long_options, opt_index, 1); 83 | } 84 | 85 | 86 | #endif /* _LIBC or not __GNU_LIBRARY__. */ 87 | 88 | #ifdef TEST 89 | 90 | #include 91 | 92 | int 93 | main (argc, argv) 94 | int argc; 95 | char **argv; 96 | { 97 | int c; 98 | int digit_optind = 0; 99 | 100 | while (1) 101 | { 102 | int this_option_optind = optind ? optind : 1; 103 | int option_index = 0; 104 | static struct option long_options[] = 105 | { 106 | {"add", 1, 0, 0}, 107 | {"append", 0, 0, 0}, 108 | {"delete", 1, 0, 0}, 109 | {"verbose", 0, 0, 0}, 110 | {"create", 0, 0, 0}, 111 | {"file", 1, 0, 0}, 112 | {0, 0, 0, 0} 113 | }; 114 | 115 | c = getopt_long (argc, argv, "abc:d:0123456789", 116 | long_options, &option_index); 117 | if (c == EOF) 118 | break; 119 | 120 | switch (c) 121 | { 122 | case 0: 123 | printf ("option %s", long_options[option_index].name); 124 | if (optarg) 125 | printf (" with arg %s", optarg); 126 | printf ("\n"); 127 | break; 128 | 129 | case '0': 130 | case '1': 131 | case '2': 132 | case '3': 133 | case '4': 134 | case '5': 135 | case '6': 136 | case '7': 137 | case '8': 138 | case '9': 139 | if (digit_optind != 0 && digit_optind != this_option_optind) 140 | printf ("digits occur in two different argv-elements.\n"); 141 | digit_optind = this_option_optind; 142 | printf ("option %c\n", c); 143 | break; 144 | 145 | case 'a': 146 | printf ("option a\n"); 147 | break; 148 | 149 | case 'b': 150 | printf ("option b\n"); 151 | break; 152 | 153 | case 'c': 154 | printf ("option c with value `%s'\n", optarg); 155 | break; 156 | 157 | case 'd': 158 | printf ("option d with value `%s'\n", optarg); 159 | break; 160 | 161 | case '?': 162 | break; 163 | 164 | default: 165 | printf ("?? getopt returned character code 0%o ??\n", c); 166 | } 167 | } 168 | 169 | if (optind < argc) 170 | { 171 | printf ("non-option ARGV-elements: "); 172 | while (optind < argc) 173 | printf ("%s ", argv[optind++]); 174 | printf ("\n"); 175 | } 176 | 177 | exit (0); 178 | } 179 | 180 | #endif /* TEST */ 181 | -------------------------------------------------------------------------------- /lib/startup.ss: -------------------------------------------------------------------------------- 1 | .module 2 | 3 | .text 4 | /* on reprend les variables globales */ 5 | li_i _vars 6 | li_i _getvars 7 | jsr 4 8 | pop 9 | 10 | /* lancement de 'main' puis 'exit' */ 11 | li_i _argv 12 | ld_i 13 | li_i _argc 14 | ld_i 15 | li_i main 16 | jsr 8 17 | li_i exit 18 | jsr 4 19 | 20 | /* variables globales */ 21 | 22 | .data 23 | .align 4 24 | _vars: 25 | stdin: 26 | .globl stdin 27 | .int 0 28 | stdout: 29 | .globl stdout 30 | .int 0 31 | stderr: 32 | .globl stderr 33 | .int 0 34 | _argc: 35 | .int 0 36 | _argv: 37 | .int 0 38 | 39 | 40 | 41 | /* librairie */ 42 | .text 43 | 44 | _getvars: 45 | libcall 0 46 | rts 47 | 48 | malloc: 49 | .globl malloc 50 | libcall 1 51 | rts 52 | 53 | free: 54 | .globl free 55 | libcall 2 56 | rts 57 | 58 | exit: 59 | .globl exit 60 | libcall 3 61 | rts 62 | 63 | realloc: 64 | .globl realloc 65 | libcall 4 66 | rts 67 | 68 | fputc: 69 | .globl fputc 70 | libcall 5 71 | rts 72 | 73 | fgetc: 74 | .globl fgetc 75 | libcall 6 76 | rts 77 | 78 | fread: 79 | .globl fread 80 | libcall 7 81 | rts 82 | 83 | fwrite: 84 | .globl fwrite 85 | libcall 8 86 | rts 87 | 88 | ferror: 89 | .globl ferror 90 | libcall 9 91 | rts 92 | 93 | fopen: 94 | .globl fopen 95 | libcall 10 96 | rts 97 | 98 | fclose: 99 | .globl fclose 100 | libcall 11 101 | rts 102 | 103 | -------------------------------------------------------------------------------- /lib/stdarg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/lib/stdarg.h -------------------------------------------------------------------------------- /lib/stdio.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #ifndef _STDIO_H 6 | 7 | #define _STDIO_H 8 | 9 | #define EOF (-1) 10 | 11 | typedef struct _FILE FILE; 12 | 13 | extern FILE *stdin,*stdout,*stderr; 14 | 15 | int vsprintf(char *buf, const char *fmt, va_list args); 16 | int sprintf(char * buf, const char *fmt, ...); 17 | 18 | void vfprintf(FILE *f,const char *fmt,va_list args); 19 | void fprintf(FILE *,const char *fmt,...); 20 | 21 | void printf(const char *fmt, ...); 22 | 23 | FILE *fopen(char *,char *); 24 | int fclose(FILE *); 25 | int fwrite(void *,size_t,size_t,FILE *); 26 | int fread(void *,size_t,size_t,FILE *); 27 | int fgetc(FILE *); 28 | int fputc(int,FILE *); 29 | int ferror(FILE *); 30 | 31 | #define getc(f) fgetc(f) 32 | #define putchar(c) fputc(c,stdout) 33 | #define getchar() fgetc(stdin) 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/stdlib.h: -------------------------------------------------------------------------------- 1 | /* stdlib.h */ 2 | 3 | #ifndef _STDLIB_H 4 | 5 | #define _STDLIB_H 6 | 7 | #define NULL ((void *)0) 8 | 9 | /* stdarg.h */ 10 | 11 | /* il n'y a pas de type long */ 12 | 13 | #define long int 14 | typedef int size_t; 15 | 16 | void *malloc(int); 17 | void free(void *); 18 | void exit(int); 19 | void *realloc(void *,size_t); 20 | char *getenv(const char *name); 21 | int atoi(char *s); 22 | 23 | /* void *alloca(int); */ 24 | #define alloca malloc 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/string.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _STRING_H 3 | 4 | #define _STRING_H 5 | 6 | char * strcpy(char * dest,const char *src); 7 | char * strncpy(char * dest,const char *src,size_t count); 8 | char * strcat(char * dest, const char * src); 9 | char * strncat(char *dest, const char *src, size_t count); 10 | int strcmp(const char * cs,const char * ct); 11 | int strncmp(const char * cs,const char * ct,size_t count); 12 | char * strchr(const char * s,char c); 13 | size_t strlen(const char * s); 14 | size_t strnlen(const char * s, size_t count); 15 | size_t strspn(const char *s, const char *accept); 16 | char * strpbrk(const char * cs,const char * ct); 17 | char * strtok(char * s,const char * ct); 18 | void * memset(void * s,char c,size_t count); 19 | char * bcopy(const char * src, char * dest, int count); 20 | void * memcpy(void * dest,const void *src,size_t count); 21 | void * memmove(void * dest,const void *src,size_t count); 22 | int memcmp(const void * cs,const void * ct,size_t count); 23 | void * memscan(void * addr, unsigned char c, size_t size); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /test2/Makefile: -------------------------------------------------------------------------------- 1 | FBCC = ../fbcc/fbcc 2 | FBAS = ../fbas/fbas 3 | FBINCLUDE = ../lib 4 | FBLIBS = ../lib/startup.ss ../lib/fblib.s 5 | 6 | all: dijkstra test1 testopt 7 | chmod +x vm 8 | -./vm dijkstra 9 | -./vm test1 10 | -./vm testopt arg1 arg2 lastarg 11 | 12 | # exemple 1 13 | dijkstra: dijkstra.s 14 | cat $(FBLIBS) dijkstra.s | $(FBAS) -o dijkstra 15 | 16 | # exemple 2 17 | test1: test1.s 18 | cat $(FBLIBS) test1.s | $(FBAS) -o test1 19 | 20 | # getopt test 21 | testopt: testopt.s 22 | cat $(FBLIBS) ../lib/getopt.s testopt.s | $(FBAS) -o testopt 23 | 24 | clean: 25 | rm -f *.s *.i *~ test1 testopt dijkstra tralala 26 | 27 | .c.s: 28 | gcc -E -I$(FBINCLUDE) $*.c >$*.i 29 | $(FBCC) < $*.i > $*.s 30 | -------------------------------------------------------------------------------- /test2/dijkstra.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DoctorWkt/fbcc/f855f7225b73eba2521b7722684439d38ce3a79e/test2/dijkstra.c -------------------------------------------------------------------------------- /test2/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void put(char c) 6 | { 7 | printf("c=%d\n",c); 8 | } 9 | 10 | 11 | 12 | 13 | int main(int argc,char *argv[]) 14 | { 15 | int a=1,i; 16 | char *buf1; 17 | char *buf=(char *) 3+4; 18 | FILE *f; 19 | 20 | buf=(void *) 2; 21 | 22 | a=2; 23 | put(a); 24 | fprintf(stderr,"stderr %d\n",23 << a); 25 | printf("printf %d\n",23); 26 | fwrite("hello\n",1,6,stdout); 27 | buf=malloc(100); 28 | strcpy(buf,"fabrice"); 29 | printf("strlen %s = %d\n",buf,strlen(buf)); 30 | 31 | f=fopen("tralala","w"); 32 | 33 | for(i=10;i>=0;i--) { 34 | fprintf(f,"i=%d\n",i); 35 | } 36 | fclose(f); 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /test2/testopt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void print_help(void) 7 | { 8 | printf("This is the help.\n"); 9 | } 10 | 11 | 12 | int main(int argc,char *argv[]) 13 | { 14 | int i,c; 15 | 16 | printf("argc=%d ",argc); 17 | for(i=0;i