The Microcontroller Idea Book - Jan Axelson's Lakeview Research
The Microcontroller Idea Book - Jan Axelson's Lakeview Research
The Microcontroller Idea Book - Jan Axelson's Lakeview Research
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 15<br />
BASIC compilers<br />
A BASIC compiler offers a middle ground between the BASIC-52 interpreter and assembly-language<br />
programming. With a BASIC compiler, you write your programs using the<br />
familiar keywords and syntax rules of BASIC, but the compiled programs run on their own,<br />
without requiring the BASIC-52 interpreter. Binary Technology, Systronix, and Blue Earth<br />
are three vendors of BASIC compilers for the 8052.<br />
As with assembly language, to use a BASIC compiler, you first write a source file, using<br />
any text editor. But instead of using assembly-language mnemonics, you write the source<br />
file using the BASIC compiler’s keywords and conventions. When the program is complete,<br />
the compiler program translates your program lines into the machine codes required by the<br />
8052 chip. <strong>The</strong> compilers will create an object file, usually in Intel Hex format, for uploading<br />
or programming into EPROM, plus a listing file for documentation and debugging use.<br />
When the object file is stored in the 8052’s code memory, the 8052 can run the program<br />
directly, without having to use the BASIC-52 interpreter.<br />
Using a compiler has several advantages:<br />
• Unlike with assembly language, the syntax used with BASIC compilers is similar to<br />
BASIC-52. This means that you don’t have to learn a new programming language. In<br />
fact, you can usually use the BASIC-52 interpreter to test your code before you compile<br />
it. You can also use BASIC-52 for loading and debugging your compiled programs, as<br />
described in Chapter 13.<br />
• A compiled BASIC program will run faster than an interpreted BASIC-52 program.<br />
<strong>The</strong> speed increase depends on the program, but programs that run 20 to 50 percent<br />
faster are typical.<br />
• Because a compiler doesn’t limit you to the 8052-BASIC chip, you can develop<br />
programs for other members of the 8051 family. For example, Systronix’s BASIC<br />
compiler has optional language extensions for Dallas Semiconductor’s DS5000<br />
8051-compatible microcontroller.<br />
A disadvantage to using a compiler rather than an interpreter is that you have the extra steps<br />
of compiling and uploading programs before you can run them. But because the BASIC-52<br />
language is so similar to the compilers, you can do a lot of your testing with the interpreter,<br />
and use the compiled version for final testing only.<br />
<strong>The</strong>re’s also the added expense of buying the compiler. But if you develop many different<br />
projects, or if you need many copies of a single project, the compiler can end up saving you<br />
money, since you can use 8032 chips instead of the more expensive 8052-BASICs.<br />
246 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>