⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdccman.txt

📁 很少见的源码公开的msc51和z80的c编译器。
💻 TXT
📖 第 1 页 / 共 5 页
字号:
+--------------------------------+-------------------------------------------+Make sure the compiler works on a very simple example. Typein the following test.c program using your favorite editor:int test(int t) {    return t+3;}Compile this using the following command: "sdcc -c test.c".If all goes well, the compiler will generate a test.asmand test.rel file. Congratulations, you've just compiledyour first program with SDCC. We used the -c option to tellSDCC not to link the generated code, just to keep thingssimple for this step.The next step is to try it with the linker. Type in "sdcctest.c". If all goes well the compiler will link with thelibraries and produce a test.ihx output file. If this stepfails (no test.ihx, and the linker generates warnings),then the problem is most likely that sdcc cannot find the/usr/local/share/sdcc/lib directory (see the Install trouble-shootingsection for suggestions).The final test is to ensure sdcc can use the standard headerfiles and libraries. Edit test.c and change it to the following:#include <string.h>main() {char str1[10];    strcpy(str1, "testing");}Compile this by typing "sdcc test.c". This should generatea test.ihx output file, and it should give no warnings suchas not finding the string.h file. If it cannot find thestring.h file, then the problem is that sdcc cannot findthe /usr/local/share/sdcc/include directory (see the Installtrouble-shooting section for suggestions). Install Trouble-shooting SDCC cannot find libraries or header files.The default installation assumes the libraries and headerfiles are located at "/usr/local/share/sdcc/lib"and "/usr/local/share/sdcc/include".An alternative is to specify these locations as compileroptions like this: "sdcc -L /usr/local/sdcc/lib/small -I /usr/local/sdcc/include test.c". SDCC does not compile correctly.A thing to try is starting from scratch by unpacking the.tgz source package again in an empty directory. Confureit again and build like:make 2&>1 | tee make.logAfter this you can review the make.log file to locate theproblem. Or a relevant part of this be attached to an emailthat could be helpful when requesting help from the mailinglist. What the "./configure"  doesThe "./configure" command is a scriptthat analyzes your system and performs some configurationto ensure the source package compiles on your system. Itwill take a few minutes to run, and will compile a few teststo determine what compiler features are installed. What the "make" does.This runs the GNU make tool, which automatically compilesall the source packages into the final installed binaryexecutables. What the "make install"  command does.This will install the compiler, other executables and librariesin to the appropriate system directories. The default isto copy the executables to /usr/local/bin and the librariesand header files to /usr/local/share/sdcc/lib and /usr/local/share/sdcc/include. Additional Information for Windows Users<pending: is this up to date?>The standard method of installing on a Unix system involvescompiling the source package. This is easily done underUnix, but under Windows it can be a more difficult process.The Cygwin is a large package to download, and the compilationruns considerably slower under Windows due to the overheadof the Cygwin tool set. An alternative is to install a pre-compiledWindows binary package. There are various trade-offs betweeneach of these methods. The Cygwin package allows a Windows user to run a Unix commandline interface (bash shell) and also implements a Unix likefile system on top of Windows. Included are many of thefamous GNU software development tools which can augmentthe SDCC compiler.This is great if you have some experiencewith Unix command line tools and file system conventions,if not you may find it easier to start by installing a binaryWindows package. The binary packages work with the Windowsfile system conventions. Getting started with CygwinSDCC is typically distributed as a tarred/gzipped file (.tgz).This is a packed file similar to a .zip file. Cygwin includesthe tools you will need to unpack the SDCC distribution(tar and gzip). To unpack it, simply follow the instructionsunder the Linux/Unix install section. Before you do thisyou need to learn how to start a cygwin shell and some ofthe basic commands used to move files, change directory,run commands and so on. The change directory command is"cd", the move command is "mv".To print the current working directory, type "pwd".To make a directory, use "mkdir".There are some basic differences between Unix and Windowsfile systems you should understand. When you type in directorypaths, Unix and the Cygwin bash prompt uses forward slashes'/' between directories while Windows traditionally uses'\' backward slashes. So when you work at the Cygwin bashprompt, you will need to use the forward '/' slashes. Unixdoes not have a concept of drive letters, such as "c:",instead all files systems attach and appear as directories. Running SDCC as Native Compiled ExecutablesIf you use the pre-compiled binaries, the install directoriesfor the libraries and header files may need to be specifiedon the sdcc command line like this: "sdcc -L c:\usr\local\sdcc\lib\small-I c:\usr\local\sdcc\include test.c" if you are running outsideof a Unix bash shell.If you have successfully installed and compiled SDCC withthe Cygwin package, it is possible to compile into native.exe files by using the additional makefiles included forthis purpose. For example, with the Borland 32-bit compileryou would run "make -f Makefile.bcc". A command line versionof the Borland 32-bit compiler can be downloaded from theInprise web site. SDCC on Other Platforms FreeBSD and other non-GNU Unixes - Make sure the GNU make  is installed as the default make tool. SDCC has been ported to run under a variety of operating  systems and processors. If you can run GNU GCC/make then  chances are good SDCC can be compiled and run on your  system. Advanced Install OptionsThe "configure" command has several options.The most commonly used option is --prefix=<directory name>,where <directory name> is the final location for the sdccexecutables and libraries, (default location is /usr/local).The installation process will create the following directorystructure under the <directory name> specified (if theydo not already exist). bin/ - binary exectables (add to PATH environment variable)bin/share/bin/share/sdcc/include/ - include header filesbin/share/sdcc/lib/bin/share/sdcc/lib/small/ - Object & library files for smallmodel librarybin/share/sdcc/lib/large/ - Object & library files for largemodel librarybin/share/sdcc/lib/ds390/ - Object & library files forDS80C390libraryThe command "./configure --prefix=/usr/local"will configure the compiler to be installed in directory/usr/local. Components of SDCCSDCC is not just a compiler, but a collection of tools byvarious developers. These include linkers, assemblers, simulatorsand other components. Here is a summary of some of the components.Note that the included simulator and assembler have separatedocumentation which you can find in the source package intheir respective directories. As SDCC grows to include supportfor other processors, other packages from various developersare included and may have their own sets of documentation.You might want to look at the files which are installed in<installdir>. At the time of this writing, we find the followingprograms: In <installdir>/bin: sdcc - The compiler. sdcpp - The C preprocessor. asx8051 - The assembler for 8051 type processors. as-z80, as-gbz80 - The Z80 and GameBoy Z80 assemblers. aslink -The linker for 8051 type processors. link-z80, link-gbz80 - The Z80 and GameBoy Z80 linkers. s51 - The ucSim 8051 simulator. sdcdb - The source debugger. packihx - A tool to pack Intel hex files.In <installdir>/share/sdcc/include the include filesIn <installdir>/share/sdcc/lib the sources of the runtime library and the subdirs small  large and ds390 with the precompiled relocatables.In <installdir>/share/sdcc/doc the documentationAs development for other processors proceeds, this list willexpand to include executables to support processors likeAVR, PIC, etc. sdcc - The CompilerThis is the actual compiler, it in turn uses the c-preprocessorand invokes the assembler and linkage editor. sdcpp (C-Preprocessor)The preprocessor is a modified version of the GNU preprocessor.The C preprocessor is used to pull in #include sources,process #ifdef statements, #defines and so on. asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80  (The Assemblers and Linkage Editors)This is retargettable assembler & linkage editor, it wasdeveloped by Alan Baldwin. John Hartman created the versionfor 8051, and I (Sandeep) have made some enhancements andbug fixes for it to work properly with the SDCC. s51 - SimulatorS51 is a freeware, opensource simulator developed by DanielDrotos ([mailto:drdani@mazsola.iit.uni-miskolc.hu]).The simulator is built as part of the build process. Formore information visit Daniel's website at: [http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51] . sdcdb - Source Level DebuggerSdcdb is the companion source level debugger. The currentversion of the debugger uses Daniel's Simulator S51, butcan be easily changed to use other simulators. Using SDCC Compiling Single Source File ProjectsFor single source file 8051 projects the process is verysimple. Compile your programs with the following command"sdcc sourcefile.c". This will compile, assemble and linkyour source file. Output files are as followssourcefile.asm - Assembler source file created by the compilersourcefile.lst - Assembler listing file created by the Assemblersourcefile.rst - Assembler listing file updated with linkeditinformation, created by linkage editorsourcefile.sym - symbol listing for the sourcefile, createdby the assemblersourcefile.rel - Object file created by the assembler, inputto Linkage editorsourcefile.map - The memory map for the load module, createdby the Linkersourcefile.ihx - The load module in Intel hex format (youcan select the Motorola S19 format with --out-fmt-s19)sourcefile.cdb - An optional file (with --debug) containingdebug information Projects with Multiple Source FilesSDCC can compile only ONE file at a time. Let us for exampleassume that you have a project containing the followingfiles:foo1.c (contains some functions)foo2.c (contains some more functions)foomain.c (contains more functions and the function main)The first two files will need to be compiled separately withthe commands: sdcc -c foo1.csdcc -c foo2.cThen compile the source file containing the main() functionand link the files together with the following command:sdcc foomain.c foo1.rel foo2.relAlternatively, foomain.c can be separately compiled as well:sdcc -c foomain.csdcc foomain.rel foo1.rel foo2.relThe file containing the main() function must be the firstfile specified in the command line, since the linkage editorprocesses file in the order they are presented to it. Projects with Additional LibrariesSome reusable routines may be compiled into a library, seethe documentation for the assembler and linkage editor (whichare in <installdir>/share/sdcc/doc) for how to create a.lib library file. Libraries created in this manner canbe included in the command line. Make sure you include the-L <library-path> option to tell the linker where to lookfor these files if they are not in the current directory.Here is an example, assuming you have the source file foomain.cand a library foolib.lib in the directory mylib (if thatis not the same as your current project):sdcc foomain.c foolib.lib -L mylibNote here that mylib must be an absolute path name.The most efficient way to use libraries is to keep seperatemodules in seperate source files. The lib file now shouldname all the modules.rel files. For an example see the standardlibrary file libsdcc.lib in the directory <installdir>/share/lib/small. Command Line Options Processor Selection Options-mmcs51 Generate code for the MCS51 (8051) family of processors.This is the default processor target.-mds390 Generate code for the DS80C390 processor.-mz80 Generate code for the Z80 family of processors.-mgbz80 Generate code for the GameBoy Z80 processor.-mavr Generate code for the Atmel AVR processor(In development,not complete).-mpic14 Generate code for the PIC 14-bit processors(In development,not complete).-mtlcs900h Generate code for the Toshiba TLCS-900H processor(Indevelopment, not complete). Preprocessor Options-I<path> The additional location where the pre processorwill look for <..h> or "..h"files.-D<macro[=value]> Command line definition of macros. Passedto the pre processor.-M Tell the preprocessor to output a rule suitable for makedescribing the dependencies of each object file. For eachsource file, the preprocessor outputs one make-rule whose

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -