lab2 - Getting Started with the MSP430 IAR Assembly by Alex...

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

View Full Document Right Arrow Icon
Getting Started with the MSP430 IAR Assembly by Alex Milenkovich, milenkovic@computer.org Objectives: This tutorial will help you get started with the MSP30 IAR Assembly program development. You will learn the following topics: ± Assembly programming ± Creating an application project using assembly programs ± Debugging using the IAR C-SPY® Debugger (Simulator) Note: It is required that students have completed the tutorial Getting Starting With MSP430 IAR Embedded Workbench before starting with this one. 1. Count Number of Characters ‘E’ in a String: Problem Statement This section defines the problem that will be solved by the Count Characters program using MSP430 assembly language. Our task is to develop an assembly program that will scan a given string of characters, for example, “HELLO WORLD, I AM THE MSP430!”, and find the number of appearances of the character ‘E’ in the string. A counter that records the number of characters ‘E’ is then written to the parallel port P1. The port should be configured as an output port, and the binary value of the port will correspond to the counter value. Step 1: Analyze the assignment and develop a plan. To solve this assignment, let us first analyze the problem statement. Your task is to write an assembly program that will count the number of characters ‘E’ in a string. First, the problem implies that we need to allocate space in memory that will keep the string “HELLO WORLD, I AM THE MSP430!”. The string has 29 characters and they are encoded using ASCII table. To allocate and initialize a string in memory we can use an assembly language directive, for example DB (Define Byte). DB "HELLO WORLD, I AM THE MSP430!" We can also put a label to mark the beginning of this string in memory, for example, mystr: mystr DB "HELLO WORLD, I AM THE MSP430!" When assembler sees the DB directive, it will allocate the space in memory required for the string that follows and initialize the allocated space with ASCII characters. The assembler will also automatically add an ASCII NULL character at the end of each string (ascii(NULL)=0x00). So, the total number of bytes occupied by this string is 30.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Step 2. Develop a plan. Our task is now to write a small program that will scan the string, character by character, check whether the current character is equal to character ‘E’, and if yes, increment a counter. The string scan is done in a program loop. The program ends when we reach the end of the string which is detected when the current character is equal to the NULL character (0x00). To scan the string we will use a register to point to the current character in the string.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2011 for the course CPE 323 taught by Professor Milenkovic during the Spring '10 term at University of Alabama - Huntsville.

Page1 / 7

lab2 - Getting Started with the MSP430 IAR Assembly by Alex...

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