<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="Module.2004-02-25.2448">
  <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Lab 3: Introduction to Assembly Language</name>
  <metadata xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
  <md:version xmlns:bib="http://bibtexml.sf.net/">1.3</md:version>
  <md:created xmlns:bib="http://bibtexml.sf.net/">2004/02/25 14:24:48 US/Central</md:created>
  <md:revised xmlns:bib="http://bibtexml.sf.net/">2005/09/14 14:41:01 GMT-5</md:revised>
  <md:authorlist xmlns:bib="http://bibtexml.sf.net/">
      <md:author xmlns:bib="http://bibtexml.sf.net/" id="seejaie">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">CJ</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Ganier</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">seejaie@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist xmlns:bib="http://bibtexml.sf.net/">
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="deaniafe">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Deania</md:firstname>
      <md:othername xmlns:bib="http://bibtexml.sf.net/">M.</md:othername>
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Fernandez</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">deaniafe@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="seejaie">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">CJ</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Ganier</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">seejaie@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="adrianv">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Adrian</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Valenzuela</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">adrianv@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="jpfrantz">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Patrick</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Frantz</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">jpfrantz@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist xmlns:bib="http://bibtexml.sf.net/">
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">assembly</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">elec 226</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">lab 3</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">msp430</md:keyword>
  </md:keywordlist>

  <md:abstract xmlns:bib="http://bibtexml.sf.net/">A lab that introduces a student to assembly language programming.</md:abstract>
</metadata>

  <content xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="lab3.1">
In this lab you will be introduced to assembly programming.  The specific assembly language instruction set of the MSP will be explained. Setting up and executing assembly projects in Crossworks will also be explained. Finally you will implement the blinking lights program from the previous lab in assembly. 
</para>

<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="lab3.2">
Read the following modules before you begin lab exercises:
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="modules" type="bulleted">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"><cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" document="m11855">CPU Registers in the MSP430</cnxn></item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"><cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" document="m11860">Structure of an Assembly Program</cnxn></item>
</list>
</para>

<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise3.1">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="pro1">
Formulate instructions to do the following things:
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="instructions" type="enumerated">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Set bit 3 to 1 at the memory address 0xd640  while leave bits 0-2 and 4-16 unaffected. </item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Jump to the instruction labeled POINT if the carry bit is set. </item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Shift register R6 right one place while preserving the sign.  </item>
</list>
</para>
</problem>
</exercise>

<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise3.2">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="loop">
Examine this loop:
<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" type="block">
... more instructions... 	
Mov.w  &amp;I,  R4  
Cmp.w  #0x0000, R4 
JZ    After_loop

Start_loop:
Dec.w   #0x0001, R4	 
JZ  After_loop
BR #Start_loop

After_loop:
...more instructions...
</code>
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="loopques" type="bulleted">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">How many times will this loop execute?</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Why do we use the BR instruction with a #Start_loop, but with the JZ we use a plain After_loop?</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">What does the first JZ instruction do? If we did not have this initial Cmp and JZ, what (possibly) inadvertent effect might occur?</item>
</list>
</para>
</problem>
</exercise>

<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise3.3">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="element-136">Re-write the blinking light program from Lab 2, now using assembly code. The program should do the following:</para><para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="pro3">

<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p3instructions" type="enumerated">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">When the program starts all three LED’s should light up for about a second then turn off. </item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Next, the green LED should blink for about 1/2 second on, 1/2 second off while the other two LED’s are off. </item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Pushing Button 1 should cause the green LED to stop blinking and cause the red LED to start the blinking pattern. </item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Pushing the button again should continue the pattern with the yellow LED, and pushing it more times should repeat the green, red, yellow pattern. Note that the current LED that's blinking should stop as soon as the button is pressed and the next LED should begin immediately. </item>

</list>
</para>
</problem>
</exercise>

  </content>
  
</document>
