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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Calling Assembly-language Routines<br />

Listing 13-7. (page 2 of 2)<br />

;can add up to 1Fh tokens<br />

;final token must end with 0ffh<br />

org vectortable ;vector table address<br />

dw tggp10 ;label to branch to on<br />

;TGGP10 command<br />

dw setp10 ;label to branch to on<br />

;SETP10 command<br />

dw clrp10 ;label to branch to on<br />

;CLRP10 command<br />

tggp10 org 3000h ;use any available address<br />

cpl p1.0 ;complement Port 1, bit 0<br />

;(pin 1)<br />

ret<br />

;return to BASIC-52<br />

setp10 org 3010h ;use any available address<br />

setb p1.0 ;set Port 1, bit 0 (pin 1)<br />

ret<br />

;return to BASIC-52<br />

clrp10 org 3020h ;use any available address<br />

clr p1.0 ;clear Port 1, bit 0 (pin 1)<br />

ret<br />

;return to BASIC-52<br />

end<br />

<strong>The</strong> vector table consists of a list of labels corresponding to the beginning of each<br />

assembly-language routine.<br />

In addition to the tables, you must store the assembly-language routines themselves, again<br />

using any free code/data or code memory.<br />

To use Listing 13-7, you must assemble it and upload the resulting Intel Hex file into NV<br />

memory that will be preserved on powering down or rebooting. Reboot, and you can use<br />

the new keywords TGGP10, SETP10, and CLRP10 to control bit 0 of Port 1. (Notice that<br />

the “bit-toggle”keyword is TGGP10, rather than TOGP10, which contains the keyword TO<br />

and so won’t work.)<br />

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

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

Saved successfully!

Ooh no, something went wrong!