<?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>2.3 - Lab 2: Introduction to Assembly Language</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2006/05/18 16:42:23.794 GMT-5</md:created>
  <md:revised>2006/05/18 16:44:00.129 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="nanand">
      <md:firstname>Naren</md:firstname>
      
      <md:surname>Anand</md:surname>
      <md:email>nanand@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="nanand">
      <md:firstname>Naren</md:firstname>
      
      <md:surname>Anand</md:surname>
      <md:email>nanand@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>assembly</md:keyword>
    <md:keyword>ez430</md:keyword>
    <md:keyword>msp430</md:keyword>
  </md:keywordlist>

  <md:abstract>A lab that introduces a student to assembly language programming.</md:abstract>
</metadata>

  <content>
<para id="lab3.1">In this lab you will be asked to write simple assembly statements, follow already written assembly statements, and finally to reproduce the SOS light blinking program from Lab 1 in assembly.  
</para>



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

<exercise id="exercise3.2">
<problem>
<para id="loop">Examine this loop:
<code 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 id="loopques" type="enumerated">
<item>How many times will this loop execute?</item>
<item>Why do we use the BR instruction with a #Start_loop, but with the JZ we use a plain After_loop?</item>
<item>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 id="exercise3.3">
<problem>
<para id="element-136">Re-write the blinking light program from Lab 1 using assembly code instead. As you may recall, the program must blink "SOS" (which is "... --- ...") and conform to the following Morse Code standards:


<list id="instructions1">
<item>The ammount of time of a dash is equivalent in length to 3 dots.</item>  
<item>The ammount of time between parts of a letter is equivalent in length to one dot.</item>
<item>The ammount of time between letters is equivalent in length to 3 dots.</item>
<item>The ammount of time between words (assume each SOS is a word) is equivalent to 5 dots.</item></list> 
  
  </para>

</problem>



</exercise>

  </content>
  
</document>
