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

📄 sdccman.txt

📁 This a FREE tool chain which compiles C codes into 8051 binary code, converts the binary to RTL ROM,
💻 TXT
📖 第 1 页 / 共 5 页
字号:

bash --login -i 

with (one line):

rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red

     -bg black -fg white -geometry 100x65 -e bash --login

Text selected with the mouse is automatically copied to 
the clipboard, pasting works with shift-insert.

The 
other good tip is to make sure you have no //c/-style 
paths anywhere, use /cygdrive/c/ instead. Using // 
invokes a network lookup which is very slow. If you 
think "cygdrive" is too long, you can change it with e.g.

mount -s -u -c /mnt

SDCC sources use the unix line ending LF. Life is much 
easier, if you store the source tree on a drive which 
is mounted in binary mode. And use an editor which can 
handle LF-only line endings. Make sure not to commit 
files with windows line endings. The tabulator spacing 
used in the project is 8. Although a tabulator spacing 
of 8 is a sensible choice for programmers (it's a power 
of 2 and allows to display 8/16 bit signed variables 
without loosing columns) the plan is to move towards 
using only spaces in the source.

2.4.5 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)

Download the source package either from the SDCC 
Subversion repository or from the [http://sdcc.sourceforge.net/snap.php||snapshot builds], it will be named 
something like sdcc-src-yyyymmdd-rrrr.tar.bz2. SDCC is 
distributed with all the projects, workspaces, and 
files you need to build it using Visual C++ 6.0/NET 
(except for SDCDB and ucSim). The workspace name is 
'sdcc.dsw'. Please note that as it is now, all the 
executables are created in a folder called sdcc\bin_vc. 
Once built you need to copy the executables from 
sdcc\bin_vc to sdcc\bin before running SDCC. 

WARNING: 
Visual studio is very picky with line terminations; it 
expects the 0x0d, 0x0a DOS style line endings, not the 
0x0a Unix style line endings. When using the Subversion 
repository it's easiest to configure the svn client to 
convert automatically for you. If however you are 
getting a message such as "This makefile was not 
generated by Developer Studio etc. etc." when opening 
the sdcc.dsw workspace or any of the *.dsp projects, 
then you need to convert the Unix style line endings to 
DOS style line endings. To do so you can use the "unix2dos"
 utility freely available on the internet. Doug Hawkins 
reported in the sdcc-user list that this works:


C:\Programming\SDCC> unix2dos sdcc.dsw

C:\Programming\SDCC> for /R %I in (*.dsp) do @unix2dos "%I"


In order to build SDCC with MSVC you need win32 
executables of bison.exe, flex.exe, and gawk.exe. One 
good place to get them is [http://unxutils.sourceforge.net||here]

Download the file UnxUtils
.zip. Now you have to install the utilities and setup 
MSVC so it can locate the required programs. Here there 
are two alternatives (choose one!):

1. The easy way:

a) Extract UnxUtils.zip to your C:\ 
  hard disk PRESERVING the original paths, otherwise 
  bison won't work. (If you are using WinZip make 
  certain that 'Use folder names' is selected)

b) In the 
  Visual C++ IDE click Tools, Options, select the 
  Directory tab, in 'Show directories for:' select 
  'Executable files', and in the directories window add 
  a new path: 'C:\user\local\wbin', click ok.

(As a side 
  effect, you get a bunch of Unix utilities that could 
  be useful, such as diff and patch.)

2. A more compact way:

This one avoids extracting a 
  bunch of files you may not use, but requires some 
  extra work:

a) Create a directory were to put the 
  tools needed, or use a directory already present. Say 
  for example 'C:\util'.

b) Extract 'bison.exe', 
  'bison.hairy', 'bison.simple', 'flex.exe', and 
  gawk.exe to such directory WITHOUT preserving the 
  original paths. (If you are using WinZip make certain 
  that 'Use folder names' is not selected)

c) Rename 
  bison.exe to '_bison.exe'.

d) Create a batch file 
  'bison.bat' in 'C:\util\' and add these lines: 
  set 
  BISON_SIMPLE=C:\util\bison.simple 
  set 
  BISON_HAIRY=C:\util\bison.hairy
  _bison %1 %2 %3 %4 %5 
  %6 %7 %8 %9

Steps 'c' and 'd' are needed because bison 
  requires by default that the files 'bison.simple' and 
  'bison.hairy' reside in some weird Unix directory, 
  '/usr/local/share/' I think. So it is necessary to 
  tell bison where those files are located if they are 
  not in such directory. That is the function of the 
  environment variables BISON_SIMPLE and BISON_HAIRY.

e) 
  In the Visual C++ IDE click Tools, Options, select 
  the Directory tab, in 'Show directories for:' select 
  'Executable files', and in the directories window add 
  a new path: 'c:\util', click ok. Note that you can 
  use any other path instead of 'c:\util', even the 
  path where the Visual C++ tools are, probably: 
  'C:\Program Files\Microsoft Visual 
  Studio\Common\Tools'. So you don't have to execute 
  step 'e' :)

That is it. Open 'sdcc.dsw' in Visual Studio, click 
'build all', when it finishes copy the executables from 
sdcc\bin_vc to sdcc\bin, and you can compile using SDCC.

2.4.6 Building SDCC Using Borland

1. From the sdcc directory, run the command "make -f 
  Makefile.bcc". This should regenerate all the .exe 
  files in the bin directory except for SDCDB and ucSim.

2. If you modify any source files and need to rebuild, 
  be aware that the dependencies may not be correctly 
  calculated. The safest option is to delete all .obj 
  files and run the build again. From a Cygwin BASH 
  prompt, this can easily be done with the command (be 
  sure you are in the sdcc directory):

find . \( -name 
  '*.obj' -o -name '*.lib' -o -name '*.rul' \) -print 
  -exec rm {} \;

or on Windows NT/2000/XP from the 
  command prompt with the command:

del /s *.obj *.lib 
  *.rul from the sdcc directory.

2.4.7 Windows Install Using a ZIP Package

1. Download the binary zip package from [http://sdcc.sf.net/snap.php] and unpack it 
  using your favorite unpacking tool (gunzip, WinZip, 
  etc). This should unpack to a group of 
  sub-directories. An example directory structure after 
  unpacking the mingw32 package is: c:\sdcc\bin for the 
  executables, c:\sdcc\include and c:\sdcc\lib for the 
  include and libraries.

2. Adjust your environment variable PATH to include the 
  location of the bin directory or start sdcc using the 
  full path.

2.4.8 Windows Install Using the Setup Program<sub:Windows-Install>

Download the setup program sdcc-x.y.z-setup.exe for an 
official release from 
[http://sf.net/project/showfiles.php?group_id=599] or a setup program for one of 
the snapshots sdcc-yyyymmdd-xxxx-setup.exe from [http://sdcc.sf.net/snap.php] and 
execute it. A windows typical installer will guide you 
through the installation process.

2.4.9 VPATH feature

SDCC supports the VPATH feature provided by configure 
and make. It allows to separate the source and build 
trees. Here's an example:

cd ~                     # cd $HOME

tar -xzf sdcc.src.tar.gz # extract source to directory sdcc

mkdir sdcc.build         # put output in sdcc.build

cd sdcc.build

../sdcc/configure        # configure is doing all the magic!

make

That's it! configure will create the directory tree 
will all the necessary Makefiles in ~/sdcc.build. It 
automagically computes the variables srcdir, top_srcdir 
and top_buildir for each directory. After running make 
the generated files will be in ~/sdcc.build, while the 
source files stay in ~/sdcc.
This is not only usefull 
for building different binaries, e.g. when cross 
compiling. It also gives you a much better overview in 
the source tree when all the generated files are not 
scattered between the source files. And the best thing 
is: if you want to change a file you can leave the 
original file untouched in the source directory. Simply 
copy it to the build directory, edit it, enter `make 
clean', `rm Makefile.dep' and `make'. make will do the 
rest for you!

2.5 Building the Documentation

Add --enable-doc to the configure arguments to build 
the documentation together with all the other stuff. 
You will need several tools (LyX, LaTeX, LaTeX2HTML, 
pdflatex, dvipdf, dvips and makeindex) to get the job 
done. Another possibility is to change to the doc 
directory and to type "make" there. You're invited to 
make changes and additions to this manual 
(sdcc/doc/sdccman.lyx). Using LyX [http://www.lyx.org] as editor is 
straightforward. Prebuilt documentation in html and pdf 
format is available from [http://sdcc.sf.net/snap.php].

2.6 Reading the Documentation

Currently reading the document in pdf format is 
recommended, as for unknown reason the hyperlinks are 
working there whereas in the html version they are not

If you should know why please drop us a note
. 
You'll find the pdf version at [http://sdcc.sf.net/doc/sdccman.pdf]. 
A html version 
should be online at [http://sdcc.sf.net/doc/sdccman.html/index.html].
This documentation is in some 
aspects different from a commercial documentation: 

* It tries to document SDCC for several processor 
  architectures in one document (commercially these 
  probably would be separate documents/products). This document
   currently matches SDCC for mcs51 and DS390 best and 
  does give too few information about f.e. Z80, PIC14, 
  PIC16 and HC08.

* There are many references pointing away from this 
  documentation. Don't let this distract you. If there 
  f.e. was a reference like [http://www.opencores.org] together with a statement "
  some processors which are targetted by SDCC can be 
  implemented in a field programmable gate array" or [http://sf.net/projects/fpgac] "
  have you ever heard of an open source compiler that 
  compiles a subset of C for an FPGA?" we expect you to 
  have a quick look there and come back. If you read 
  this you are on the right track.

* Some sections attribute more space to problems, 
  restrictions and warnings than to the solution.

* The installation section and the section about the 
  debugger is intimidating.

* There are still lots of typos and there are more 
  different writing styles than pictures.

2.7 Testing the SDCC Compiler<sec:Testing-the-SDCC>

The first thing you should do after installing your 
SDCC compiler is to see if it runs. Type "sdcc --version"
 at the prompt, and the program should run and output 
its version like: 
SDCC : 
mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 
(May 8 2006) (UNIX)

If it doesn't run, or gives a message about not finding 
sdcc program, then you need to check over your 
installation. Make sure that the sdcc bin directory is 
in your executable search path defined by the PATH 
environment setting (see section [sub:Install-Trouble-shooting] Install 
trouble-shooting for suggestions). Make sure that the 
sdcc program is in the bin folder, if not perhaps 
something did not install correctly.

SDCC is commonly 
installed as described in section "Install and search paths".


Make sure the compiler works on a very simple example. 
Type in the following test.c program using your 
favorite ASCII editor:

char test;

void main(void) {
    test=0;
}

Compile this using the following command: "sdcc -c 
test.c". If all goes well, the compiler will generate a 
test.asm and test.rel file. Congratulations, you've 
just compiled your first program with SDCC. We used the 
-c option to tell SDCC not to link the generated code, 
just to keep things simple for this step.

The next step 
is to try it with the linker. Type in "sdcc test.c". If 
all goes well the compiler will link with the libraries 
and produce a test.ihx output file. If this step fails 
(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 section [sub:Install-Trouble-shooting] 
Install trouble-shooting for suggestions).

The final 
test is to ensure SDCC can use the standard header 
files and libraries. Edit test.c and change it to the following:

#include <string.h>

char str1[10];

void main(void) {
  
strcpy(str1, "testing");
}

Compile this by typing "sdcc test.c". This should 
generate a test.ihx output file, and it should give no 
warnings such as not finding the string.h file. If it 
cannot find the string.h file, then the problem is that 
SDCC cannot find the /usr/local/share/sdcc/include 
directory (see the section [sub:Install-Trouble-shooting] Install trouble-shooting 
section for suggestions). Use option --print-search-dirs
 to find exactly where SDCC is looking for the include 
and lib files.

2.8 Install Trouble-shooting<sub:Install-Trouble-shooting>

2.8.1 If SDCC does not build correctly

A thing to try is starting from scratch by unpacking 
the .tgz source package again in an empty directory. 
Configure it like:

./configure 2>&1 | tee configure.log


and build it like:

make 2>&1 | tee make.log

If anything 
goes wrong, you can review the log files to locate the 
problem. Or a relevant part of this can be attached to 
an email that could be helpful when requesting help 
from the mailing list.

2.8.2 What the "./configure" does

The "./configure" command is a script that analyzes your 
system and performs some configuration to ensure the 
source package compiles on your system. It will take a 
few minutes to run, and will compile a few tests to 
determine what compiler features are installed.

2.8.3 What the "make" does

This runs the GNU make tool, which automatically 
compiles all the source packages into the final 
installed binary executables.

2.8.4 What the "make install" command does.

This will install the compiler, other executables 
libraries and include files into the appropriate 
directories. See sections [sub:Install-paths], [sub:Search-Paths] about install and search paths.

On most systems you will need super-user privileges to 
do this.

2.9 Components of SDCC

SDCC is not just a compiler, but a collection of tools 
by various developers. These include linkers, 
assemblers, simulators and other components. Here is a 
summary of some of the components. Note that the 
included simulator and assembler have separate 
documentation which you can find in the source package 
in their respective directories. As SDCC grows to 
include support for other processors, other packages 
from various developers are 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 following programs for gcc-builds:

 
In <installdir>/bin:

* sdcc - The compiler.

* sdcpp - The C preprocessor.

⌨️ 快捷键说明

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