66
305171 Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University

Introduction to Computer

Embed Size (px)

DESCRIPTION

305171 Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University. Introduction to Computer. What is computer?. A COMPUTER is an electronic device that can: Receive information Perform processes - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction  to  Computer

305171 Computer Programming

Rattapoom WaranusastDepartment of Electrical and Computer EngineeringFaculty of Engineering, Naresuan University

Page 2: Introduction  to  Computer

A COMPUTER is an electronic device that can:– Receive information– Perform processes– Produce output– Store info for future use.

2

Page 3: Introduction  to  Computer

Personal computers (PC)

3

Page 4: Introduction  to  Computer

Mobile devices

4

Page 5: Introduction  to  Computer

Game consoles

5

Page 6: Introduction  to  Computer

Servers

6

Page 7: Introduction  to  Computer

Mainframe computers

IBM zEnterprise

7

Page 8: Introduction  to  Computer

Super computers

Fujitsu’s K - Computer

8

Page 9: Introduction  to  Computer

Embedded systems

9

Page 10: Introduction  to  Computer

Robots

10

Page 11: Introduction  to  Computer

Hardware Software

Peopleware

PCMainframeMobileEtc.

ProgrammerSystem AnalystUserAdministratorEtc.

OSApplicationsFirmwareContentEtc.

11

Page 12: Introduction  to  Computer

Input(Input Devices)

Process(CPU)

Output(Output Devices)

Storage(Memory)

Feedback

12

Page 13: Introduction  to  Computer

13

Page 14: Introduction  to  Computer

14

Page 15: Introduction  to  Computer

15

Page 16: Introduction  to  Computer

Arithmetic and logic unit (ALU)– performs arithmetic and logical operations

Control unit– controls the flow of data through the

processor, and coordinates the activities of the other units within it

Registers– small amount of storage available on the CPU

whose contents can be accessed more quickly than storage available elsewhere

16

Page 17: Introduction  to  Computer

Main (primary) memory– Stores programs and data while computer is

running. Main memory is fast and limited in capacity. The CPU can only directly access information in main memory.

– Random Access Memory (RAM)– Read-Only Memory (ROM)

17

Page 18: Introduction  to  Computer

• Size :• Kilobyte KB 210 ~103

• Megabyte MB 220 ~106

• Gigabyte GB 230 ~109

• Terabyte TB 240 ~1012

• Petabyte PB 250 ~1015

• Exabyte EB 260 ~1018

• Zettabyte ZB 270 ~1021

• Yottabyte YB 280 ~1024

Memory mappingAddress Values0000 00010002......

..

FFFF

1 0 1 1 1 0 0 1

0 0 0 0 1 1 1 1

1 1 1 0 0 0 1 1

0 0 1 0 0 1 0 018

Page 19: Introduction  to  Computer

External (secondary) memory– Holds information too large for storage in

main memory. – Information on external memory can only be

accessed by the CPU if it is first transferred to main memory.

– It retains information when the computer is switched off.

19

Page 20: Introduction  to  Computer

BUSClock

ALU

CURegiste

rs

CPU

Main Memor

y

VDO controll

er

Diskcontroll

er

I/O ports

20

Page 21: Introduction  to  Computer

A clock signal is a signal generated by quartz crystal circuit that oscillates between a high and a low state and is utilized to coordinate actions of circuits.

Clock rate is measured in cycles/sec (Hertz ).

21

Page 22: Introduction  to  Computer

Problem oriented language level

Assembly Language

Operating System

Instruction Set Architecture

Micro-architecture level

Digital Logic Level

Level 5

Level 3

Level 2

Level 1

Level 0

Level 4

User

Translation (compiler)

Translation (assembler)

Circuits

Partial interpretation (operating system)

Interpretation (microprogram) or direct execution

Hardware

22

Page 23: Introduction  to  Computer

The interesting objects at this level are gates; Each gate has one or more digital inputs

(signals representing a 0 or 1) and computes as output some simple function of these inputs, such as AND or OR;

A small number of gates can be combined to form a 1-bit memory, which can store a 0 or 1;

The 1-bit memories can be combined in groups of, for example, 16, 32 or 64 to form registers.

23

Page 24: Introduction  to  Computer

A collection of 8-32 registers that form a local memory and ALU

The registers are connected to the ALU to form a data path over which the data flow;

The operation of the data path may be controlled by a microprogram, directly by hardware, or even by software.

24

Page 25: Introduction  to  Computer

The ISA level is defined by the machine’s instruction set

This is a set of instructions carried out interpretively by the microprogram or hardware execution sets;

Machine languages – Strings of numbers giving machine specific

instructions

25

Page 26: Introduction  to  Computer

The Operating System Machine (OSM) level is a complete set of instructions available to application programmers. This includes all ISA level instructions and a new set of instructions that the operating system adds called system calls.

The OSM level is always interpreted. For instance, if reading data from file, the operating system carries it out step by step.

26

Page 27: Introduction  to  Computer

This level is really a symbolic form. This level provides a method for people to write programs

for levels 1, 2 and 3 in a form that is more readable. Programs in assembly language are first translated to

level 1, 2 or 3 language and then interpreted by the appropriate virtual or actual machine.

The program that performs the translation is called an assembler.

Example:LOAD R1, #FFFFADD R2,R1MOV R3,R2

27

Page 28: Introduction  to  Computer

This level usually consists of languages designed to be used by applications programmers.

These languages are generally called higher level languages, for examples: C, C++, Java, BASIC, LISP, Prolog, Pascal, FORTRAN, COBOL, etc.

Programs written in these languages are generally translated to Level 3 or 4 by translators known as compilers, although

occasionally they are interpreted instead.

28

Page 29: Introduction  to  Computer

Computers use binary numbers internally because storage devices like memory and disk are made to store 0s and 1s. A number or a text inside a computer is stored as a sequence of 0s and 1s. Each 0 and 1 is called a bit, short for binary digit. The binary number system has two digits, 0 and 1.

Binary numbers are not intuitive. When you write a number like 20 in a program, it is assumed to be a decimal number. Internally, computer software is used to convert decimal numbers into binary numbers, and vice versa.

29

Page 30: Introduction  to  Computer

The digits in the decimal number system are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. The value that each digit in the sequence represents depends on its position. A position in a sequence has a value that is an integral power of 10.

We say that 10 is the base or radix of the decimal number system. Similarly, the base of the binary number system is 2 since the binary number system has two digits and the base of the hex number system is 16 since the hex number system has sixteen digits.

5892 = 5 x 103 + 8 x 102 + 9 x 101 + 2 x 100

30

Page 31: Introduction  to  Computer

A positional number system Has only 2 symbols (0 and 1), so that base = 2 The maximum value of a single digit is 1

(base – 1) The maximum value of N digits is 2N-1 Used mostly in computer system

31

Page 32: Introduction  to  Computer

5 digits binary can store number up to 25-1 = 32-1 = 31

Example101012 = (1x24)

+ (0x23) + (1x22) + (0x21) + (1x20)= 16 + 0 + 4 + 0 + 1 = 2110

32

Page 33: Introduction  to  Computer

A positional number system Has only 8 symbols (0, 1, 2, 3, 4, 5, 6, 7), so that

base = 8 The maximum value of a single digit is 7

(base – 1) The maximum value of N digits is 8N-1 Used mostly in computer system

33

Page 34: Introduction  to  Computer

Example20578 = (2x83)

+ (0x82) + (5x81) + (7x80)= 1024 + 0 + 40 + 7 =107110

34

Page 35: Introduction  to  Computer

A positional number system Has only 16 symbols (0-9, A, B, C, D, E, F), so

that its base = 16 The maximum value of a single digit is 15 (F)

(base – 1) The maximum value of N digits is 16N-1 Used mostly in computer system

35

Page 36: Introduction  to  Computer

Example1AF16 =

(1x162) + (10x161) + (15x160)= 256 + 160 + 15 = 43110

36

Page 37: Introduction  to  Computer

Method1. Determine the column (positional) value of

each digit.2. Multiply the obtained column values by the

digits in the corresponding columns.3. Calculate the sum of these products.

37

Page 38: Introduction  to  Computer

Division-Remainder Method1. Divide the decimal number by the value of the

new base.2. Record the remainder from step 1 as the right

most digit of the new base number3. Divide the quotient of the previous divide by the

value of the new base.4. Record the remainder from step 3 as the next digit

(to the left) of the new base number.5. Repeat step 3 and 4 until the quotient become 0,

the last remainder will be the most significant digit of the new base number.

38

Page 39: Introduction  to  Computer

Example95210 = ?8

Solution8 )952 Remainders)119 0)14 7)1 6 0 1

Hence, 95210 = 016708

39

Page 40: Introduction  to  Computer

Example95210 = ?16

Solution16)952 Remainders)59 8)3 11 0 3

Hence, 95210 = 3B816

40

Page 41: Introduction  to  Computer

Method1. Convert the original number to a decimal

number2. Convert the decimal number that obtained

on in step 1 to the new base number

41

Page 42: Introduction  to  Computer

Method1. Divide the digits into groups of three

starting from the right.2. Convert each group of three binary digits to

one octal digit using the method of binary to decimal conversion.

42

Page 43: Introduction  to  Computer

Example11010102 = ?8

Solution1. Divide the binary into groups of three digits

001 101 0102. Convert each group into one octal digit

0012 = 0x22 + 0x21 + 1x20 = 1

1012 = 1x22 + 0x21 + 1x20 = 5

0102 = 0x22 + 1x21 + 0x20 = 2

Hence, 11010102 = 1528

43

Page 44: Introduction  to  Computer

Method1. Convert each octal digit to 3 binary digits.2. Combine all the resulting binary groups into

a single binary number.

44

Page 45: Introduction  to  Computer

Example5628 = ?2

Solution1. Convert each octal digit to 3 binary digits.

58 = 1012 68 = 1102 28 = 0102

2. Combine all the resulting binary groups into a single binary number. 5628 = 101 110 010 2

Hence, 5628 = 1011100102

45

Page 46: Introduction  to  Computer

Method1. Divide the digits into groups of four starting

from the right.2. Convert each group of four binary digits to

one hexadecimal digit using the method of binary to decimal conversion.

46

Page 47: Introduction  to  Computer

Example1111012 = ?16

Solution1. Divide the binary into groups of four digits

0011 11012. Convert each group into one hexadecimal digit

00112 = 0x23 + 0x22 + 1x21 + 1x20 = 3

11012 = 1x23 + 1x22 + 0x21 + 1x20 = 13 = D

Hence, 1111012 = 3D1647

Page 48: Introduction  to  Computer

Method1. Convert each hexadecimal digit to 4 binary

digits.2. Combine all the resulting binary groups into

a single binary number.

48

Page 49: Introduction  to  Computer

Example2AB16 = ?2

Solution1. Convert each hex digit to 4 binary digits.

216 = 00102 A16 = 10102 B16 = 10112

2. Combine all the resulting binary groups into a single binary number. 2AB16 = 0010 1010 1011 2

Hence, 2AB16 = 0010101010112

49

Page 50: Introduction  to  Computer

All information that is processed by computers is converted in one way or another into a sequence of numbers. This includes – numeric information– textual information and– Pictures, sound, video, etc.

Therefore, if we can derive a way to store and retrieve numbers electronically this method can be used by computers to store and retrieve any type of information.

50

Page 51: Introduction  to  Computer

Computers Store ALL information using binary numbers

Computers use binary numbers in different ways to store different types of information.

Common types of information that are stored by computers are :

– Whole numbers (i.e. Integers). Examples: 8 97 -732 0 -5 etc.

– Numbers with decimal points. Examples: 3.5 -1.234 0.765 999.001 etc.

– Textual information (including letters, symbols and digits)

51

Page 52: Introduction  to  Computer

Unsigned integers– Given n bits, it is possible to represent the

range of values from 0 to 2n - 1– For example an 8-bit representation would

allow representations that range 0 to 255

52

Page 53: Introduction  to  Computer

Signed Magnitude– An extra bit in the most significant position is

designated as the sign bit which is to the left of an unsigned integer. The unsigned integer is the magnitude.

– A 0 in the sign bit means positive, and a 1 means negative

MMMMMMMMMMMMMMMS

53

Page 54: Introduction  to  Computer

Signed Magnitude (cont.)– Given an n bit signed magnitude number the range

of values that it can represent is -(2n-1-1) to +(2n-1-1)

for example: 8 bits -127 to 12716 bits -32767 to 32767

– Signed magnitude representation associates a sign bit with a magnitude that represents zero, thus it has two distinct representation of zero:

00000000 and 10000000

54

Page 55: Introduction  to  Computer

1’s Complement representation– For positive numbers, the representation is

the same as for unsigned integers where the most significant bit is always zero

– The additive inverse of a 1’s complement representation is found by inverting each bit.

– Inverting each bit is also called taking the 1’s complement

55

Page 56: Introduction  to  Computer

1’s Complement representation Examples

0000 0011 (3)1111 1100 (-3)

0001 0111 (23)1110 1000 (-23)

0000 0000 (0)1111 1111 (0)

56

Page 57: Introduction  to  Computer

2’s Complement representation– The additive inverse of a 2’s complement integer

can be obtained by adding 1 to its 1’s complement

– The 2’s complement representation for a negative number is the additive inverse of its positive representation

– An advantage of 2’s complement is that there is only one representation for zero

– Given an n bit 2’s complement number the range of values that it can represent is

-(2n-1) to +(2n-1-1)57

Page 58: Introduction  to  Computer

2’s Complement representation Examples010001 (17) 000000 (0)

101110 + 111111 +

1 1

101111 (-17) 1000000 (0)

take the 1’s complement

58

Page 59: Introduction  to  Computer

6.0210 x 1023

radix (base)decimal point

mantissa exponent

Normalized form: no leadings 0s (exactly one digit to left of decimal point)

Alternatives to representing 1/1,000,000,000

–Normalized: 1.0 x 10-9

–Not normalized: 0.1 x 10-8,10.0 x 10-10

59

Page 60: Introduction  to  Computer

1.02 x 2-1

radix (base)“binary point”

exponent

Computer arithmetic that supports it called floating point, because it represents numbers where the binary point is not fixed, as it is for integers

mantissa

60

Page 61: Introduction  to  Computer

61

Normalized format: +1.xxxxxxxxxx2 x 2yyyy2

Multiple of Word Size (32 bits)

031S Exponent

30 23 22Mantissa

1 bit 8 bits 23 bits

S represents Sign Exponent represents y’s Mantissa represents x’s

Page 62: Introduction  to  Computer

To store letters and symbols, the computer assigns every character a numerical value.

Computers remember letters and other symbols by storing the binary number for the symbol.

For this system to work a standard numbering system needs to be defined and consistently used for all symbols that the computer needs to process.

62

Page 63: Introduction  to  Computer

ASCII (American Standard Code for Information Interchange) is the standard numbering given to all characters.

“ASCII values” range in number from 1 to 128 (8 bits).

63

Page 64: Introduction  to  Computer

Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems.

Unicode can be implemented by different character encodings. The most commonly used encodings are UTF-8 (which uses one byte for any ASCII characters, which have the same code values in both UTF-8 and ASCII encoding, and up to four bytes for other characters.

64

Page 65: Introduction  to  Computer

65

A raster image, or bitmap, consists of a rectangular array of pixels.

Each pixel has a corresponding red, green, and blue value that combine to determine the color displayed by that pixel.

Page 66: Introduction  to  Computer

Audio analog to digital converters work by repeatedly measuring the amplitude of an incoming electrical pressure sound wave, and outputting these measurements as a long list of binary bytes.

66