Difference between revisions of "CSC103: DT's Notes 1"
Line 1,353: | Line 1,353: | ||
|} | |} | ||
− | <center>[[Image:CSC103FirstAssemblyProgSimul1.jpg| | + | <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| | + | <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| | + | <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: | + | <br /> |
− | < | + | <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: | ||
; First initialize both variables with 55 | ; First initialize both variables with 55 | ||
start: lod-c 55 | start: lod-c 55 | ||
− | sto | + | sto 15 |
− | sto | + | sto 16 |
; now loop and increment Location 15 and decrement Location 16 | ; now loop and increment Location 15 and decrement Location 16 | ||
; the loop is endless. | ; the loop is endless. | ||
loop: lod 15 | loop: lod 15 | ||
− | add-c 1 | + | add-c 1 |
− | sto 15 | + | sto 15 |
− | lod 16 | + | lod 16 |
dec | dec | ||
sto 16 | sto 16 |
Revision as of 20:21, 28 September 2013
--© D. Thiebaut 08:10, 30 January 2012 (EST)