topic 1: introduction to computers and programming “ a journey of a thousand miles must begin with...

24
Topic 1: Introduction to Computers and Programming “A journey of a thousand miles must begin with a single step.” - Lao Tzu

Post on 15-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

Topic 1: Introduction to Computers and Programming

“A journey of a thousand miles must begin with a single step.” - Lao Tzu

Page 2: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 2

Introduction to Computer Organization Computers are composed of two

distinct components: Hardware – the equipment used to

perform computations. This includes the CPU, memory, hard disk, etc…

Software – the programs that determine the operations to be performed by the hardware.

Page 3: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 3

Hardware Components Hardware consists of many types

of components: Primary Storage Secondary Storage The Central Processing Unit (CPU) Input Devices Output Devices

Page 4: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 4

Primary Storage andSecondary Storage There are two primary types of

storage in a computer: Primary Storage – often referred to as

main memory, or just memory. This storage is very quickly accessed by the various hardware components.

Secondary Storage – includes such devices as a hard disk, floppy disk, CD-ROM, DVD-ROM, etc…

Page 5: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 5

Memory Organization Computer memory is organized

into memory cells. Each cell has a unique address, which allows the accessing of each cell individually.

Programs are transferred from secondary storage into primary storage before they can be run.

Page 6: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 6

The Central Processing Unit (CPU) The CPU is responsible for coordinating all

computer operations and performing the operations specified in a program.

The CPU fetches an instruction from a program loaded in memory, decodes the instruction, retrieves necessary data, performs the operation, and then saves the result.

The CPU contains very high speed memory cells termed registers, which holds the data being operated on.

Page 7: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 7

Input and Output Devices Input devices are used to

communicate from some external source to the computer. They include the keyboard and the mouse.

Output devices are used to communicate from the computer to some external source. They include the monitor and the printer.

Page 8: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 8

Computer Software All major computers run an

operating system. An operating system is a special

type of program which controls the interaction between all hardware components and the user.

Page 9: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 9

Operating Systems Tasks Responsibilities of the OS include:

Communicating with the user(s) Managing resources including memory

and processor time among programs Collecting data from input devices Providing data to output devices Accessing data from secondary storage Writing data to secondary storage

Page 10: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 10

Binary MathA binary digit or bit for short is the smallest unit of

computer information. Just as our familiar decimal number system has 10 digits,(0,1,2,3,4,5,6,7,8,9) the binary number system has only 2 digits (0,1). This is the perfect number system for computers since we can store a binary digit by making an electrical or magnetic field either on or off, positive or negative, 1 or 0. In the decimal system we can count 10 (we start counting with 0) items with one decimal place, 100 with two decimal places, 1000 with three decimal places and so on.

Page 11: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 11

Binary MathThe binary number system works the same way

except since we only have 0s and1s our base is 2.

So we can count 2 permutations of 1 bit: 0 14 permutations of 2 bits: 00 01 10 118 permutations of 3 bits: 000 001 010 011 100 101

110 11116 permutations of 4 bits: 0000 0001 0010 0011

0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

...and so on.

Page 12: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 12

Binary MathSo in an eight bit byte, the numbers are represented this

way:

Bit: - - - - - - - -Value: 128 64 32 16 8 4 2 1

Example: 1 0 1 1 0 1 1 0

Values: 128 + 0 + 32 +16 + 0 + 4 + 2 + 0 = 182

The minimum number is 0 (all 0s) and the maximum number is 255 (all 1s), so you can represent 256 numbers (0-255) with one byte.

Page 13: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 13

Computer Programming - Machine Language Computer programs were originally written

in machine language. Machine language is a sequence of binary numbers, each number being an instruction.

Each instruction is computer-understandable.

000000000001010100010110

Page 14: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 14

Computer Programming - Assembly Language To make machine language more

abstract, assembly language was introduced.

Assembly language provides a one-to-one mapping between a machine instruction and a simple human-readable instruction.00000000

0001010100010110

CLR AADD AADD B

Page 15: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 15

Computer Programming – Assembly Language Assembly language is converted to

computer-understandable machine language by an assembler.

Although assembly language is much more clear and understandable than machine language, it is still very difficult to program.

The assembly code for the sqrt() function in C is composed of hundreds of assembly instructions.

Page 16: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 16

Computer Programming – High-Level Languages In order to get around these

obstacles, high-level languages were introduced.

High-level languages provide a one-to-many mapping between one high-level statement and multiple assembly language instructions.

High-level language is converted to assembly instructions by a compiler.

Page 17: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 17

Computer Programming - Compilation

MOV EAX, 0 // initialize EAX to 0MOV EBX, 3 // set multiplicand

LABEL1:ADD EAX, 6 // multiplierDEC EBX // decrease countJNZ LABEL1 // loop if need toSTOR A, EAX // store result in A

A = 6 X 3

Page 18: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 18

Modern Software Development

Modern software development is done in high-level languages, with few exceptions.

High-level language is first compiled from source code to assembly and then assembler into machine code. Modern compilers perform the assembler function as well.

Compiled source code is called an object file.

Page 19: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 19

Modern Software Development Programmers often use library functions,

which are pre-written functions provided as part of the compiler/development toolset.

A library is an object file. After the source code is compiled into

machine code, a linker resolves cross-references among these object files, including libraries. The object files are linked into an executable file.

Page 20: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 20

Modern Software Development

The executable file can now be run. The operating system loader loads the

executable file into memory and schedules the program for execution.

Page 21: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 21

Modern Software Development

Source Code File Compiler

Object File

Executable FileOther Object Files(perhaps libraries) Linker

Loader

Page 22: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 22

The Software Development Method Specify the problem. Analyze the problem. Design an algorithm to solve the

problem. Implement the algorithm. Test and verify the program. Maintain and update the program.

Page 23: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 23

Review Name the principle components of a

computer.

What advantage does assembly language have over machine language?

What are three responsibilities of the operating system?

What advantages do high-level languages have over assembly language?

Page 24: Topic 1: Introduction to Computers and Programming “ A journey of a thousand miles must begin with a single step.” - Lao Tzu

CISC 105 – Topic 1 24

Review What computer program translates a

source code file into an object file? What program combines object files and

produces an executable file? What part of the operating system is

responsible for the loading and scheduling of programs?

What are the steps in the software development method?