Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Basics Computer system: hardware + software

Similar presentations


Presentation on theme: "Computer Basics Computer system: hardware + software"— Presentation transcript:

1 Computer Basics Computer system: hardware + software
Hardware: the physical components Central Processing Unit (CPU) Memory Input/Output devices Software: the instructions that tell the hardware what to do Operating Systems Application Software User programs

2 Common Hardware Components
Processor (CPU) Memory Input device(s) Output device(s) CPU and memory are physically housed together Memory Input Devices Output Devices Processor

3 CPU and Memory The CPU is the “brain” of the computer
Understands and executes computer programs Memory is the storage unit Holds computer programs to be executed and their data Main and auxiliary memory

4 Inside the CPU Control Unit To main memory, and input / output devices
Arithmetic / Logic Unit Registers This is the CPU’s internal memory

5 Kinds of Memory Main Often referred to as Random-Access Memory (RAM)
Temporarily stores program and data (while program is executing) Requires power to retain its contents Auxiliary Additional storage capacity Permanent (more or less) Saves program and results Includes floppy & hard disk drives, CDs, flash memory sticks, etc.

6 Main Memory Organization
Comparable to a collection of numbered mailboxes. Each memory cell has two important attributes Address or location Contents or values, represented digitally as a binary number Address Contents 3021 3022 3023 3024 3025 3026 3027 3028 3029

7 Main Memory Organization
Bit = Binary digIT A binary digit can have only one of two values: 0 or 1 Byte = 8 bits Also called “octet” Main memory is a list of numbered locations that contain one byte of data in each location Number of bytes per data item may vary Address Contents 3021 Item 1: 2 octets 3022 3023 Item 2: 1 octet 3024 Item 3: 3 octets 3025 3026 3027 Item 4: 1 octet 3028 Item 5: 2 octets 3029

8 Binary Numbers Internally, computers store values as binary (base 2) numbers, rather than decimal (base 10) numbers Decimal: Binary: = 165 ×102 ×101 ×100 ×27 ×26 ×25 ×24 ×23 ×22 ×21 ×20

9 Decimal to Binary Conversion
Convert 106 to binary by repeatedly dividing by 2. Use the remainders as the binary digits, with the first remainder being the right-most digit 106 / 2 = 53, remainder 0 53 / 2 = 26, remainder 1 26 / 2 = 13, remainder 0 13 / 2 = 6, remainder 1 6 / 2 = 3, remainder 0 3 / 2 = 1, remainder 1 1 / 2 = 0, remainder 1 Result: 106 = indicates a binary number

10 Storage of character data
Once again, we have only 0 and 1 digits to work with. Each character is assigned its own numeric code: ASCII character set (ASCII = American Standard Code for Information Interchange) 128 characters most common character set (if you speak American English ) used in older languages and computers UNICODE character set over 64,000 characters (international) includes ASCII as a subset used in Java

11 Unicode In the computer, every character is stored using a numeric code. The most commonly used characters in Java have codes in the range 0 through 127. For these characters the UNICODE code is the same as the ASCII code. Examples: Character codes are chosen so that ordering the numeric codes equates to alphabetical order. Note that while order is preserved among upper case and among lower case characters, the two cases have different codes. character a b A B (space) ? UNICODE value 97 98 65 66 32 48 63

12 Storage of Floating-point Data
How would be stored? One approach: Adjust all numbers so that they are of the form Z x 10E, where -1 < Z < 1 Use 1 bit to store the sign (+ or -) of the digits Use 23 bits to store the digits Use 1 bit to store the sign of the exponent Use 7 bits to store the value of E SDDDDDDDDDDDDDDDDDDDDDDDSEEEEEEE Approximate decimal equivalent: 0.ddddddd x 10ee

13 Range and Precision Range represents the scope of values that can be stored: Using the format from the previous slide: Most positive number: ~ +3 x 1038 Most negative number: ~ -3 x 1038 Positive number closest to zero: ~ +1.5 x 10-45 Precision represents how many significant digits are stored In the format from the previous slide, six digits are generally the maximum that can be reliably stored.

14 Effects of Range Exceeding the range of legal values results in OVERFLOW number greater than most positive, or less than most negative A number that is too close to zero to be properly stored results in UNDERFLOW Suppose that we can store numbers between -99 and +99, with one decimal place allowed.  (overflow) 15 / 0.1  (overflow) 0.5 × 0.1  (underflow)

15 Effects of precision Suppose we were using decimal digits, and we had only three digits for storage 1 / 3 = … “Nearest” value that can be stored: 0.333 What about (1 / 3) x 3 ? 0.999 What about ? 0.226 E3 This is called “round-off” error

16 Auxiliary Memory Organization
Directory “root” or “home” directory Directory File File File Directory File File Directory Directory File File File File

17 (input for the program)
Running a Program Program—a set of instructions for a computer to follow Program Computer Data / Events (input for the program) Output

18 Input/Output Devices Communication between computers and the outside world. Transforming information form different non-digital forms into digital form, and vice versa.

19 Input/Output Devices Common input devices
Keyboards (converts each key or key combination to digital code) Pointing devices (mouse, track balls, touch pads, etc.) Scanner (converts an image to a grid of pixels) Common output devices Monitors Printers Speakers for audio output Some devices do both:

20 Types of Programs Operating System (OS)
Windows (98, Me, NT, 2000, XP), MacOS, UNIX / LINUX, etc. Application Software word-processor/editor web browser compiler or assembler User Software

21 Functions of the Operating System
Software responsible for directing all computer operations, and managing all computer resources. Manages allocation of memory, processing time, etc. Collects input from the input devices and provides this information to the currently running program Conveys program output to the screen, printer, etc. Reads/writes data to/from auxiliary storage Security management

22 Application Software Software used for a specific task such as word processing, database management, environments for developing user programs, spreadsheets, etc. Runs on top of the OS using its services; therefore, must be compatible with it

23 User Programs Developed by the user with the help of specialized application software. Runs on top of the OS. We will be developing many user programs during the next four months.

24 Types of User Interfaces
Command-line All functions performed by typing commands on keyboard. Text-only display. Examples: DOS, UNIX GUI (Graphical User Interface) Icons, Menus, Buttons on graphical display. Typically uses additional input devices as well as keyboard: mouse, pointer, … Also called “event-driven” MacOS, Windows

25 Programming Language Hierarchy
High-Level Language (HLL) Assembly Language Machine Language Hardware

26 Machine Language (low level)
A collection of binary instructions understood by a specific type of CPU chip. Non-standard; low-level of detail related to the given hardware Very hard to understand by human programmers Hardware dependent in order to be executed, any program must have been previously translated into machine language

27 Assembly Language (middle level)
A (supposedly ) human readable version of machine language Words, abbreviations, letters and numbers replace 0s and 1s Easily translated from human readable to machine executable code (that is, from assembly language to machine language) Like machine code, assembly language is hardware dependent.

28 High-Level Languages “Closer” to the human way of expression, using higher-level of abstraction concepts from the application area for which it is intended. Mostly standardized, thus independent of a given hardware. Computers do NOT understand high-level languages Need a compiler (a translation program) to convert programs written in high-level languages into machine language.

29 High-level languages Language When invented Typical uses FORTRAN 1956
Scientific computation LISP 1958 Expert systems COBOL 1960 Business APL 1962 Mathematics, statistics Basic 1971 Teaching, business C 1972 Operating system creation C++ 1984 General purpose, communications Java 1993 General purpose, internet applications

30 Other languages Language When invented Known for… Pascal 1971 Teaching
Smalltalk 1972 Object-oriented Prolog Logic, expert systems Ada 1979 US Defence Dept. software standard language *SQL = Structured Query Language Databases *HTML = HyperText Markup Language 1992 Web page formatting *XML = eXtensible Markup Language 1996 Internet data exchange C# 2002 Microsoft’s answer to Java * Special-purpose languages: not for general programming.

31 Getting from Source to Machine Code
Source code: Input to a translation program. Examples: The program you write Intermediate-level code that needs further translation. Must (eventually) be translated to machine code. Object code: Output from a translation program Object code is usually machine code or a lower level language.

32 Getting from Source to Machine Code
Compiler A program that translates from source code to object code. Source code in this case is normally a high-level language Object code could be machine code, an intermediate language, or assembly language. Assembler Specific name for a compiler of the assembly language for particular hardware. Output is always machine code. Interpreter: A program that does both program translation and execution Interpreter translates one statement at a time, and then executes the translated statement. Source code can be either a high-level language, or an intermediate language.

33 Example of language levels
Suppose that we want to add two numbers.

34 Low-level problem steps (1)
Suppose that we want to add two numbers. Where is the first number? Where is the second number? What should we do with the two numbers? Where should the result be put?

35 Low-level problem steps (2)
Suppose that we want to add two numbers. Where is the first number? Location 0201 Where is the second number? Location 0202 What should we do with the numbers? Add them Where should the result be put? Location 0203

36 Low-level problem steps (3)
Suppose that we want to add two numbers. Step 1 Fetch a copy of the contents of memory location 0201 and bring the value to the CPU register 0 Step 2 Fetch a copy of the contents of memory location 0202 and bring the value to the CPU register 1 Step 3 Add contents of CPU register 1 to CPU register 0. Step 4 Move the value from CPU register 0 to memory location 0203 (which replaces the value currently stored there!)

37 In Machine Code Command Operands (data) 00110011 11001001 00000000
Each CPU type has a set of commands, each of which has a given arbitrary code number.

38 In Assembly Language (1)
Command Operands (data) Load $0201, R0 Load $0202, R1 Add R0, R1 Store R0, $0203 There is a direct correspondence between the machine codes of the previous page, and the elements of the assembly language. example: Load 

39 In Assembly Language (2)
Command Operands (data) Load A, R0 Load B, R1 Add R0, R1 Store R0, C The assembler will need a symbol table to know the actual locations of A, B, and C. Symbol Actual location A $0201 B $0202 C $0203 This version is easier to move around in the computer’s main memory: just change the locations in the symbol table.

40 In a High-Level Language
C = A + B The computer will still need a symbol table, but this is produced as part of compiling the program. The compiler will ask the operating system for suitable locations in memory. Symbol Actual location A $0201 B $0202 C $0203

41 The highs and lows of programming languages ...
High-Level Language (HLL) closest to natural language words, numbers, and math symbols not directly understood by hardware “portable” source code (hardware independent) Machine Language (lowest level) least natural language for humans, most natural language for hardware just 0s and 1s directly understood by hardware not portable (hardware dependent)

42 The important point Everything stored in a computer – data, program instructions, etc. – eventually has to be stored as a collection of 0s and 1s. Programs have to be converted to 0s and 1s using a compiler or interpreter. Data of any type also has to be stored using 0s and 1s. Files essentially consist of a long set of 0s and 1s. Internet communication is based on sending and receiving 0s and 1s. Humans don’t work well with long collections of 0s and 1s, and so we need translation of programs, and (re-)formatting of data.


Download ppt "Computer Basics Computer system: hardware + software"

Similar presentations


Ads by Google