AN1752

AN1752 - Motorola, Inc., 1998, 2001 AN1752 REV 1 Order this...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Motorola, Inc., 1998, 2001 AN1752 REV 1 Order this document by AN1752/D REV 1 Motorola Semiconductor Application Note AN1752 Data Structures for 8-Bit Microcontrollers By Brad Bierschenk Consumer Systems Group Applications Engineering Austin, Texas Introduction A data structure describes how information is organized and stored in a computer system. Although data structures are usually presented in the context of large computers, the same principles can be applied to embedded 8-bit processors. The efficient use of appropriate data structures can improve both the dynamic (time-based) and static (storage-based) performance of microcontroller software. This application note presents data structures which are useful in the development of microcontroller software. The applications presented here are by no means absolute. One can find an infinite variety of ways to apply these basic data structures in a microcontroller application. Strings A string is a sequence of elements accessed in sequential order. The string data structure usually refers to a sequence of characters. For example, a message which is to be output to a display is stored as a string of ASCII character bytes in memory. F r e e s c a l e S e m i c o n d u c t o r , I Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com n c . . . Application Note AN1752 REV 1 2 MOTOROLA Storing Strings A string of elements must be identified by a starting and ending address. A starting address for a string can be defined using an absolute address label or by using a base address of a group of strings and identifying particular strings with an offset into the group. There are several methods of terminating string information. One common way of terminating a string is by using a special character to mark the end of the string. One terminating character to use is the value $04, an ASCII EOT (end-of-transmission) byte. Figure 1 shows an example of string data. Figure 1. String Data Structure Another method of terminating a string is to identify its length. Its length can then be used as a counter value, eliminating the need for an extra byte of storage for the end of the string. A string of ASCII characters can be terminated without using an extra byte of storage by using the sign bit (most significant bit) as an indicator of the last byte of the string. Because ASCII character data is only seven bits long, the last byte of a string can be indicated by a 1 in its most significant bit location. When using this method, the programmer must be careful to strip off the sign bit before using the ASCII character value. MESSAGE POINTER $50 $51 $52 $53 $54 $55 O L $04 H E L ADDRESS DATA F r e e s c a l e S e m i c o n d u c t o r , I Freescale Semiconductor, Inc....
View Full Document

This note was uploaded on 02/08/2011 for the course EE 459L taught by Professor Weber during the Spring '11 term at USC.

Page1 / 32

AN1752 - Motorola, Inc., 1998, 2001 AN1752 REV 1 Order this...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online