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

From dftwiki3
Jump to: navigation, search
Line 1,163: Line 1,163:
 
that is much easier to remember than the number.  Writing a series of mnemonics to instruct the processor
 
that is much easier to remember than the number.  Writing a series of mnemonics to instruct the processor
 
to execute a series of action is the process of writing  an ''assembly-language program''.
 
to execute a series of action is the process of writing  an ''assembly-language program''.
 +
 +
{| style="width:100%; background:#FFD373"
 +
|-
 +
|
 +
===Instructions and Assembly Language===
 +
|}
  
 
The first mnemonic we will look at is LOD-C ''n''.  It means LOAD a Constant into the AC register.  LOD-C  
 
The first mnemonic we will look at is LOD-C ''n''.  It means LOAD a Constant into the AC register.  LOD-C  
Line 1,183: Line 1,189:
 
tells the processor "Store AC in memory at Address 10", or, "Store AC at Address 10" for short.
 
tells the processor "Store AC in memory at Address 10", or, "Store AC at Address 10" for short.
  
 +
     ADD  11
 +
 +
The ADD ''n'' mnemonic is also always followed by a number representing an address.  I means "ADD
 +
the contents of Memory Location ''n'' to the AC register", or "ADD contents of Address ''n'' to AC".
 +
 +
It is now time to write our first program.  We will use the simulator from
 +
our [http://tinyurl.com/103applets applet page].  When you start it you the window shown below.
 +
<br />
 +
<center>
 +
[[File:CSC103x-ComputerSimulator.png|500px]]
 +
</center>
 +
<br />
 +
An illustrated view of the simulator applet is given below:
 +
<br />
 +
<center>
 +
[[Image:CSC103_Annotated_Simulator.png|500px]]
 +
</center>
 +
<br />
 +
At this point you should continue with the [[CSC103 Assembly Language Lab (version 2) 2013| laboratory]]
 +
prepared for this topic.  It will take you step by step through the process of creating programs
 +
in assembly language for this simulated processor.
 +
 +
The list of all the instructions available for this processor is given below:
 +
 +
Note "-C" means ''Constant''
 +
 +
ADD&nbsp;&nbsp;&nbsp;Add&nbsp;to&nbsp;Acc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADD-C&nbsp;&nbsp;&nbsp;Add&nbsp;C&nbsp;to&nbsp;Acc
 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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Store&nbsp;Acc&nbsp;in&nbsp;mem
 +
 +
We won't learn all of the them.  The ones we touched on in the lab is sufficient to understand how a processor works.
  
 +
Here we summarize the important points you should remember from this section.
  
 +
* All we are going to find inside a computer are numbers.  Binary numbers.  The reason is that computers
 +
work with electricity, and the only way we have to store information will be using gates wired as flipflops, which
 +
allow us to store individual bits, and we can modify binary information using circuits similar to adders,
 +
and we saw that they can easily been built using logic gates.
 +
* It is tempting to think that characters such as 'A', 'B', etc are stored in memory at some point.  But actually
 +
they are not.  There is a special code that assigns numbers to letters, and these are the numbers we
 +
find in memory.  Again, these are binary numbers.  You may have heard of the code used to assign
 +
numbers to characters.  It is called ASCII, or American Standard Code for Information Interchange.  It is
 +
an old code that was created for English-based languages.  The Unicode is now replacing ASCII in many
 +
applications, as it allows one to represent many more languages that have different character sets (such
 +
as Japanese, Chinese, etc.)
 +
* The processor can execute three basic types of instructions.
 +
** '''data move''' instructions that moves information from one place in the computer to another place.  The LOD and
 +
STO instructions are good examples of this group.
 +
** '''arithmetic''' instructions, such as the ADD-C or ADD, which performs the addition of some quantity
 +
to the contents of the AC register.
 +
** '''control''' instructions, such as JMP, that instructs the processor not to continue at the next memory
 +
location when it comes time to fetch a new instruction, but to go to a different address.
 +
* Instructions are '''very''' unsophisticated.  They are very basic and operates on 1 number at a time,
 +
and modify this number using very basic operations: an addition, a subtraction, changing the value. 
 +
* However, the processor is very fast at executing these instructions.  a 1 GHz (gigahertz) processor
 +
can execute 1 billion such instruction per second.  If a human being capable of executing 1 action every
 +
second was asked to execute 1 billion such actions, without ever stopping for sleep, this would take that
 +
person... (let's ask Wolfram Alpha)
 +
<br />
 +
<center>
 +
[[Image:CSC103WolframAlpha1billionSeconds.jpg|600px]]
 +
</center>
 +
<br />
  
  

Revision as of 11:07, 22 September 2013

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



This section is only visible to computers located at Smith College













.