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

From dftwiki3
Jump to: navigation, search
Line 1,242: Line 1,242:
  
 
<br />
 
<br />
<code><pre>
+
;&nbsp;Solution&nbsp;for&nbsp;Problem&nbsp;5&nbsp;
; Solution for Problem 5  
+
;&nbsp;D.&nbsp;Thiebaut&nbsp;
; D. Thiebaut  
+
;&nbsp;First&nbsp;initialize&nbsp;both&nbsp;variables&nbsp;with&nbsp;55&nbsp;&nbsp;
; First initialize both variables with 55   
+
  start: lod-c&nbsp;55&nbsp;
start: lod-c 55  
+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;var1&nbsp;
        sto var1
+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sto &nbsp;var2&nbsp;&nbsp;
        sto var2  
+
 +
;&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;
 +
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;sto&nbsp;15&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;sto &nbsp;16&nbsp;
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jmp &nbsp;loop&nbsp;
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hlt&nbsp;&nbsp;
 +
  @15&nbsp;
 +
0&nbsp;
 +
  0&nbsp;
  
; now loop and increment Location 15 and decrement Location 16
+
<br />
; the loop is endless.
 
loop: lod 15
 
        add-c 1
 
        sto 15
 
        lod 16
 
        dec
 
        sto 16
 
        jmp loop
 
        hlt 
 
@15
 
0
 
0
 
</pre></code>
 
 
First, the lines starting with semi colons are comments, and not part of the actual program.  They allow the programmers
 
First, the lines starting with semi colons are comments, and not part of the actual program.  They allow the programmers
 
to add extra information for other programmers who may read the code.  
 
to add extra information for other programmers who may read the code.  

Revision as of 11:44, 22 September 2013

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



This section is only visible to computers located at Smith College













.