18.11.2014 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Calling Assembly-language Routines<br />

13<br />

Calling Assembly-language<br />

Routines<br />

Although BASIC-52 is a convenient programming language that can do a lot, sometimes<br />

it’s just not fast enough for what you need. A line in a BASIC-52 program can take many<br />

milliseconds to execute, and for some applications, this is just too long.<br />

One way to speed things up is to use assembly language. This doesn’t mean that you have<br />

to give up on BASIC-52 entirely. You can continue to use it for the parts of your programs<br />

that aren’t time-critical, and call assembly-language routines only for those parts that have<br />

to be fast. BASIC-52 can also serve as a convenient development system for loading and<br />

testing assembly-language routines in RAM, and even for programming the routines into<br />

NV memory.<br />

Calling routines from BASIC-52 is a good way to become familiar with assembly-language<br />

programming. Plus, through experimenting, you can learn a lot about the internal workings<br />

of the 8052 chip and how the BASIC-52 interpreter works.<br />

This chapter explores how and when to interface assembly-language routines to BASIC-52<br />

programs. An example project connects a digital-to-analog converter to the 8052-BASIC.<br />

Programs in BASIC-52 and assembly language cause a sine wave to appear at the converter’s<br />

output. <strong>The</strong>re’s also a section on how to use your BASIC-52 system as a general-purpose<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 217

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!