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.

Chapter 13<br />

Listing 13-7. (page 1 of 2) Creates instructions to set, clear, and toggle Port<br />

1, bit 0 in BASIC-52.<br />

;example program for creating custom commands and instructions<br />

in BASIC-52<br />

;system must contain code memory from 2000h-2079h<br />

tokentable equ 2100h ;start address, token table<br />

vectortable equ 2200h ;start address, vector table<br />

org 2002h ;5Ah at 2002h tells BASIC-52<br />

db 5ah ;to call 2048h (see below)<br />

org 2048h ;Set bit 45 to tell BASIC-52<br />

;that custom commands or<br />

setb 45 ;instructions have been<br />

ret<br />

;added<br />

org 2078h ;stores starting address of<br />

mov dptr,#tokentable token table<br />

ret<br />

org 2070h ;stores starting address of<br />

mov dptr,#vectortable vector table<br />

ret<br />

org tokentable ;token table start address<br />

db 10h ;first user-defined token<br />

db “TGGP10" ;command or instruction name<br />

;(must use all capital<br />

;letters, beginning<br />

;combination of letters<br />

;must be unique)<br />

db 0 ;end of token indicator<br />

db 11h ;2nd user-defined token<br />

db “SETP10" ;command or instruction name<br />

db 0 ;end of token indicator<br />

db 12h ;final user-defined token<br />

db “CLRP10" ;command or instruction name<br />

db 0ffh ;end of list indicator<br />

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

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

Saved successfully!

Ooh no, something went wrong!