Unformatted text preview:

CS 110 Lecture 1 This course has a dual purpose A The first objective of this course is to teach you the fundamental programming skills that you will need to successfully write programs We will do this in the context of learning Java B The second objective is to teach you to write code that is robust well structured and maintainable and that adheres to sound principles of software engineering I What is a Program A program is a set of step by step instructions that instructs the computer how to perform some task or accomplish some calculation Programs contain algorithms which are sets of that explain exactly how to perform some calculation One of the most difficult things that novice programmers need to understand is that each and EVERY detailed step of the task must be clearly defined and that the computer can t remember values unless we explicitly indicate that the value is to be stored in some memory location develop an algorithm to make a PB sandwich and calculate the sum of the numbers from 1 to 10 II Basic Components of a Computer System The various components a computer system all work together to contribute to the successful execution of a program When a program is executed the steps or statements inside the program are processed one at a time frequently in the order that they occur inside the program file Input Devices Input devices provide data to a program in execution and include keyboards mice light pens etc As a program executes frequently it will require additional information to perform calculations and this category of devices allow users to communicate with the program and to provide data during execution Output Output devices allow the program to display information to the user while executing These devices include printers and displays Secondary Storage Data entered through input devices displayed on screens or stored in memory as the program executes is volatile Storage devices such as disks and CD s provide a means for the long term retention of data and files containing program code The main components involved in the execution of a program are Memory and the CPU Memory Before a program can be executed it must be loaded from disk into memory Volatile main memory is used for the temporary storage of programs and their associated data while executing It consists of a series of locations into which executable program code and data can be loaded Each memory location or cell has an address When a program is executed it is loaded from disk into memory in a series of CONSECUTIVE adjacent locations The first instruction in the program has the lowest address During execution instructions are copied from memory into the computer s CPU which is responsible for decoding and executing the instruction It is important to note that in memory everything is stored as a series of 1 s and 0 s which is known as Binary Each bit or binary digit represents the presence or absence of an electrical pulse high and low voltage Bits individually are not very useful usually the smallest addressable unit in a computers memory is a byte which consists of 8 bits A byte is sufficient to store the representation of a character in the ASCII character set For example 1000001 is an A Other encoding schemes exist for instance Java and many new languages use a different character representation called UNICODE which represents characters using 16 bits the If we are dealing with only the English language the first 128 characters of Unicode are the same as the characters in ASCII The advantage of UNICODE is that it allows for the representation of characters of most modern alphabets In Unicode 0000000010000001 is A To represent more complex values bytes are grouped together into words The exact number of bits in word varies from one family of architectures to another Frequently it is 4 When we write a program statement in some language print Hello World it can not be directly executed by the computer before it can be executed a program must be translated into the native language of the machine 1 s and 0 s known machine code or machine language The executable version of a program is in machine language Each machine language statement performs one SIMPLE operation such as retrieving data from some memory location Machine language is specific to a particular architecture so when we move a program from one kind of machine to another we would need translate it again Cpu The Central Processing Unit is responsible for executing instructions and is essentially the brain of the computer The speed of the CPU determines how many machine instructions per second it can execute It consists of a set of specialized registers which perform various functions Control Unit this component is responsible for fetching and decoding the next instruction from memory controlling the flow of instructions and data between the CPU and memory and controlling the operation of the CPU s other components Data Registers are used to contain the data associated with instructions while they are being executed the instruction register that contains the current instruction and the program counter which contains the address of the next instruction Instruction Register Holds the current machine instruction being executed Program counter contains the address of the next instruction to execute Instructions are transferred from memory into the CPU during the fetch execute cycle At the beginning of each cycle the next instruction fetched from memory and stored in the instruction register decoded and executed The number of instructions that executed is determined by the clock rate of the computer III Evolution of programming The evolution of programming and programming languages is closely tied to the advancements made in computing hardware In the early days of computing programming computing was difficult and limited in availability 1948 64 Main frames Custom Software written in house by Data processing professionals Programs were relatively simple single purpose systems Operating systems if they existed at all were generally single user o Initially in this time frame we see programs being written in machine language And computing was relegated to the science and military realms Early computers were physically enormous expensive machines run from a console 1 User at a time 1 program at a time written in machine language binary 1 s and 0 s programmer operator operates machine himself Setting a starting address of the program in memory and then


View Full Document

WVU CS 110 - Lecture

Loading Unlocking...
Login

Join to view Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?