SDCC Compiler User Guide SDCC 4.1.11 $Date:: 2021-09-17 #$ $Revision: 12682 $ Contents 1 Introduction 7 1.1 About SDCC.............................................7 1.2 SDCC Suite Licenses.........................................8 1.3 Documentation............................................9 1.4 Typographic conventions.......................................9 1.5 Compatibility with previous versions.................................9 1.6 System Requirements......................................... 11 1.7 Other Resources............................................ 12 2 Installing SDCC 13 2.1 Configure Options........................................... 13 2.2 Install paths.............................................. 15 2.3 Search Paths.............................................. 16 2.4 Building SDCC............................................ 18 2.4.1 Building SDCC on Linux.................................. 18 2.4.2 Building SDCC on Mac OS X................................ 19 2.4.3 Cross compiling SDCC on Linux for Windows....................... 19 2.4.4 Building SDCC using Cygwin and Mingw32........................ 19 2.4.5 Building SDCC Using Microsoft Visual C++ 2010 (MSVC)................ 20 2.4.6 Windows Install Using a ZIP Package............................ 21 2.4.7 Windows Install Using the Setup Program.......................... 21 2.4.8 VPATH feature........................................ 21 2.5 Building the Documentation..................................... 22 2.6 Reading the Documentation..................................... 22 2.7 Testing the SDCC Compiler..................................... 22 2.8 Install Trouble-shooting........................................ 23 2.8.1 If SDCC does not build correctly............................... 23 2.8.2 What the ”./configure” does................................. 23 2.8.3 What the ”make” does.................................... 23 2.8.4 What the ”make install” command does............................ 23 2.9 Components of SDCC........................................ 24 2.9.1 sdcc - The Compiler..................................... 25 2.9.2 sdcpp - The C-Preprocessor................................. 25 2.9.3 sdas, sdld - The Assemblers and Linkage Editors...................... 25 2.9.4 s51, sz80, shc08, sstm8 - The Simulators.......................... 25 2.9.5 sdcdb - Source Level Debugger............................... 25 3 Using SDCC 26 3.1 Standard-Compliance......................................... 26 3.1.1 ISO C90 and ANSI C89................................... 26 3.1.2 ISO C95........................................... 27 3.1.3 ISO C99........................................... 27 3.1.4 ISO C11 and ISO C17.................................... 27 3.1.5 ISO C2X........................................... 27 3.1.6 Embedded C......................................... 27 1 CONTENTS CONTENTS 3.1.7 Implementation-defined behavior.............................. 27 3.1.7.1 Translation..................................... 27 3.1.7.2 Environment.................................... 27 3.1.7.3 Identifiers..................................... 27 3.1.7.4 Characters..................................... 28 3.1.7.5 Integers...................................... 28 3.1.7.6 Floating point................................... 28 3.1.7.7 Arrays and Pointers................................ 28 3.1.7.8 Hints........................................ 28 3.1.7.9 Structures, unions, enumerations and bit-fields.................. 28 3.1.7.10 Qualifiers..................................... 28 3.1.7.11 Preprocessing directives.............................. 28 3.1.7.12 Library functions................................. 29 3.1.7.13 Architecture.................................... 29 3.2 Compiling............................................... 29 3.2.1 Single Source File Projects.................................. 29 3.2.2 Postprocessing the Intel Hex file............................... 30 3.2.3 Projects with Multiple Source Files............................. 30 3.2.4 Projects with Additional Libraries.............................. 31 3.2.5 Using sdar to Create and Manage Libraries......................... 31 3.3 Command Line Options........................................ 31 3.3.1 Processor Selection Options................................. 31 3.3.2 Preprocessor Options..................................... 32 3.3.3 Optimization Options..................................... 33 3.3.4 Other Options......................................... 34 3.3.5 Linker Options........................................ 36 3.3.6 MCS51 Options....................................... 37 3.3.7 DS390 / DS400 Options................................... 37 3.3.8 Options common to all z80-related ports (z80, z180, r2k, r3ka, gbz80, tlcs90, ez80_z80). 38 3.3.9 Z80 Options (apply to z80, z180, r2k, r3ka, tlcs90, ez80_z80)............... 38 3.3.10 GBZ80 Options........................................ 38 3.3.11 STM8 Options........................................ 38 3.3.12 Intermediate Dump Options................................. 38 3.3.13 Redirecting output on Windows Shells............................ 39 3.4 Environment variables........................................ 39 3.5 SDCC Language Extensions..................................... 39 3.5.1 MCS51/DS390 intrinsic named address spaces....................... 39 3.5.1.1 __data / __near.................................. 40 3.5.1.2 __xdata / __far................................... 40 3.5.1.3 __idata....................................... 40 3.5.1.4 __pdata...................................... 40 3.5.1.5 __code....................................... 41 3.5.1.6 __bit........................................ 41 3.5.1.7 __sfr / __sfr16 / __sfr32 / __sbit......................... 41 3.5.1.8 Pointers to MCS51/DS390 intrinsic named address spaces............ 42 3.5.1.9 Notes on MCS51 memory layout......................... 42 3.5.2 Z80/Z180/eZ80 intrinsic named address spaces....................... 43 3.5.2.1 __sfr (in/out to 8-bit addresses).......................... 43 3.5.2.2 __banked __sfr (in/out to 16-bit addresses).................... 43 3.5.2.3 __sfr (in0/out0 to 8 bit addresses on Z180/HD64180).............. 43 3.5.3 HC08/S08 intrinsic named address spaces.......................... 43 3.5.3.1 __data....................................... 43 3.5.3.2 __xdata...................................... 44 3.5.4 PDK14/PDK15 intrinsic named address spaces....................... 44 3.5.4.1 __sfr........................................ 44 3.5.4.2 __sfr16....................................... 44 2 CONTENTS CONTENTS 3.5.5 Non-intrinsic named address spaces............................. 44 3.5.6 Absolute Addressing..................................... 45 3.5.7 Preserved register specification................................ 46 3.5.8 Binary constants....................................... 46 3.5.9 Returning void........................................ 46 3.5.10 Omitting promotion on arguments of vararg function (does not apply to pdk13, pdk14, pdk15) 46 3.6 Parameters and Local Variables.................................... 46 3.7 Overlaying.............................................. 47 3.8 Interrupt Service Routines...................................... 47 3.8.1 General Information..................................... 47 3.8.1.1 Common interrupt pitfall: variable not declared volatile ............. 48 3.8.1.2 Common interrupt pitfall: non-atomic access ................... 48 3.8.1.3 Common interrupt pitfall: stack overflow ..................... 48 3.8.1.4 Common interrupt pitfall: use of non-reentrant functions ............ 48 3.8.2 MCS51/DS390 Interrupt Service Routines.......................... 48 3.8.3 HC08 Interrupt Service Routines............................... 49 3.8.4 Z80, Z180 and eZ80 Interrupt Service Routines....................... 49 3.8.5 Rabbit 2000, 3000 and 3000A Interrupt Service Routines.................. 49 3.8.6 GBZ80 and TLCS-90 Interrupt Service Routines...................... 50 3.8.7 STM8 Interrupt Service Routines.............................. 50 3.9 Enabling and Disabling Interrupts.................................. 50 3.9.1 Critical Functions and Critical Statements.......................... 50 3.9.2 Enabling and Disabling Interrupts directly.......................... 50 3.9.3 Semaphore locking (mcs51/ds390).............................. 51 3.10 Functions using private register banks (mcs51/ds390)........................ 51 3.11 Inline Assembler Code........................................ 52 3.11.1 Inline Assembler Code Formats............................... 52 3.11.1.1 Old __asm ... __endasm; Format......................... 52 3.11.1.2 New __asm__ (”inline_assembler_code”) Format................ 52 3.11.2 A Step by Step Introduction................................. 52 3.11.3 Naked Functions....................................... 54 3.11.4 Use of Labels within Inline Assembler............................ 55 3.12 Support routines for integer multiplicative operators......................... 56 3.13 Floating Point Support........................................ 56 3.14 Library Routines........................................... 57 3.14.1 Compiler support routines (_gptrget, _mulint etc.)..................... 57 3.14.2 Stdclib functions (puts, printf, strcat etc.).......................... 57 3.14.2.1 <stdio.h>...................................... 57 3.14.2.2 <malloc.h>..................................... 58 3.14.3 Math functions (sinf, powf, sqrtf etc.)...........................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages133 Page
-
File Size-