Difference between revisions of "CSC103: DT's Notes 1"
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 Add to Acc ADD-C Add C to Acc | ||
+ | SUB Sub from Acc SUB-C Sub C from Acc | ||
+ | AND And with Acc AND-C And C with Acc | ||
+ | OR Or with Acc OR-C Or C with Acc | ||
+ | NOT invert Acc LOD-C Load C in Acc | ||
+ | SHL Shift left Acc ADD-I Add-indirect | ||
+ | SHR Shift right Acc SUB-I Sub-indirect | ||
+ | INC Increment Acc AND-I And-indirect | ||
+ | DEC Decrement Acc OR-I Or-indirect | ||
+ | LOD Load Acc from mem LOD-I Load indirect | ||
+ | HLT Stop! STO-I Store indirect | ||
+ | JMP Jmp to address JMP-I Jmp indirect | ||
+ | JMZ Jmp if Acc=0 JMZ-I Jmp zero indirect | ||
+ | JMN Jmp if negative JMN-I Jmp negative indirect | ||
+ | JMF Jmp on flag JMF-I Jmp flag indirect | ||
+ | STO Store Acc in 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)