Difference between revisions of "CSC103: DT's Notes 1"

From dftwiki3
Jump to: navigation, search
Line 1,353: Line 1,353:
 
|}
 
|}
  
<center>[[Image:CSC103FirstAssemblyProgSimul1.jpg|600px]]</center>
+
<br />
 +
We now use the simulator to write the program, translate it, and to execute it.
 +
<br />
 +
<center>[[Image:CSC103FirstAssemblyProgSimul1.jpg|500px]]</center>
 +
<br />
  
 
The figure above shows the program entered in the ''Program Window'' of the simulator.  It is entered simply by typing  
 
The figure above shows the program entered in the ''Program Window'' of the simulator.  It is entered simply by typing  
Line 1,359: Line 1,363:
 
coding system (in our case assembly language), and a ''translator'' must be invoked to transform the text into numbers.
 
coding system (in our case assembly language), and a ''translator'' must be invoked to transform the text into numbers.
  
 +
<br />
 +
<br />
 +
<br />
  
<center>[[Image:CSC103FirstAssemblyProgSimul2.jpg|600px]]</center>
+
<center>[[Image:CSC103FirstAssemblyProgSimul2.jpg|500px]]</center>
 +
<br />
  
 
The figure above shows the result of pressing the '''Translate''' button.  The translator takes the program, transforms each line into a number, and stores the numbers at different addresses in memory.  You should recognize 3 numbers at Addresses  
 
The figure above shows the result of pressing the '''Translate''' button.  The translator takes the program, transforms each line into a number, and stores the numbers at different addresses in memory.  You should recognize 3 numbers at Addresses  
 
10, 11, and 12.  Yes?
 
10, 11, and 12.  Yes?
  
 +
<br />
 +
<br />
 +
<br />
  
<center>[[Image:CSC103FirstAssemblyProgSimul3.jpg|600px]]</center>
+
<center>[[Image:CSC103FirstAssemblyProgSimul3.jpg|500px]]</center>
 +
<br />
  
 
The figure above shows the same information as displayed in the previous image, but this time we have asked the simulator
 
The figure above shows the same information as displayed in the previous image, but this time we have asked the simulator
Line 1,373: Line 1,385:
 
correspond to these numbers, even though our program doesn't have more instructions.  So 3 becomes '''ADD 3''',  
 
correspond to these numbers, even though our program doesn't have more instructions.  So 3 becomes '''ADD 3''',  
 
5 becomes '''Add 5''' and 0 becomes '''Add 0'''.   
 
5 becomes '''Add 5''' and 0 becomes '''Add 0'''.   
 +
<br />
 +
<br />
 +
<br />
 +
<center>[[Image:CSC103FirstAssemblyProgSimul4.jpg|500px]]</center>
 +
<br />
 +
If we press on the '''Run''' button, the simulator starts going and executes the program, step-by-step, very fast.  The figure
 +
above shows the simulator when it has finished running the program.  We know that the program has finished running because
 +
the legend '''Clock Stopped''' appears in the top of the simulator window.  The simulator always does this when it executes
 +
a '''HLT''' instruction.  Note that '''ADD 8''' now appears in Memory Location 12.  It should really be '''8''', but we see '''ADD 8'''.  That is simply because the simulator is in this mode where it shows every number as an instruction.  If we want to see the numbers, then we switch the simulator to make it display numbers, and that's the figure below.
  
<center>[[Image:CSC103FirstAssemblyProgSimul4.jpg|600px]]</center>
+
<br />
<center>[[Image:CSC103FirstAssemblyProgSimul5.jpg|600px]]</center>
+
<center>[[Image:CSC103FirstAssemblyProgSimul5.jpg|500px]]</center>
 +
<br />
 +
<br />
 +
<br />
  
  
Line 1,410: Line 1,434:
 
you just did and go through it, one instruction at a time.
 
you just did and go through it, one instruction at a time.
  
 +
This program
 
The program is the following:
 
The program is the following:
  
Line 1,417: Line 1,442:
 
  ;&nbsp;First&nbsp;initialize&nbsp;both&nbsp;variables&nbsp;with&nbsp;55&nbsp;&nbsp;
 
  ;&nbsp;First&nbsp;initialize&nbsp;both&nbsp;variables&nbsp;with&nbsp;55&nbsp;&nbsp;
 
  start: lod-c&nbsp;55&nbsp;
 
  start: lod-c&nbsp;55&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;var1&nbsp;
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;15&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;var2&nbsp;&nbsp;
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;16&nbsp;&nbsp;
 
   
 
   
 
  ;&nbsp;now&nbsp;loop&nbsp;and&nbsp;increment&nbsp;Location&nbsp;15&nbsp;and&nbsp;decrement&nbsp;Location&nbsp;16&nbsp;
 
  ;&nbsp;now&nbsp;loop&nbsp;and&nbsp;increment&nbsp;Location&nbsp;15&nbsp;and&nbsp;decrement&nbsp;Location&nbsp;16&nbsp;
 
  ;&nbsp;the&nbsp;loop&nbsp;is&nbsp;endless.&nbsp;
 
  ;&nbsp;the&nbsp;loop&nbsp;is&nbsp;endless.&nbsp;
 
  loop: lod&nbsp;15&nbsp;
 
  loop: lod&nbsp;15&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add-c &nbsp;1&nbsp;
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add-c &nbsp;1&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto&nbsp;15&nbsp;
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;15&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lod &nbsp;16&nbsp;
+
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lod &nbsp;16&nbsp;
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dec&nbsp;
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dec&nbsp;
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;16&nbsp;
 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;16&nbsp;

Revision as of 20:21, 28 September 2013

--© D. Thiebaut 08:10, 30 January 2012 (EST)



This section is only visible to computers located at Smith College













.