CS 125 Lecture 2 Martin van Bommel
Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk drive Software - instructions for hardware –e.g. operating system, compiler, word processor
Software Development Early computers - complex coding schemes –machine language - 0’s and 1’s Later on - introduction of system software –assembly language - mnemonics for operations –assembly program assembler machine lang Even later - compilers created –high-level languages (HLL) - natural language –HLL program compiler machine language
High Level Languages Ada Agusta - analytical engine John Backus - FORTRAN 1958, 60, 64 - ALGOL, COBOL, BASIC US Dept. of Defence - Ada Nicklaus Wirth - Pascal Dennis Ritchie - C Nicklaus Wirth - Modula ANSI C adopted
Computer Components CPU - Central Processing Unit –controls operation of entire systems –performs arithmetic and logic operations –stores and retrieves instructions and data contains ALU - Arithmetic-Logic Unit Control Unit
Components (con’t) Main memory (internal or primary memory) –RAM - Random Access Memory –stores instructions and data temporarily Secondary memory (external or auxiliary) –magnetic disk (hard disk or floppy) –magnetic tape Peripherals - used for Input/Output –keyboard, printer, monitor, etc.
Internal Representation Each unit of memory a two-state device –off or on, 0 or 1 –represent in Binary, two Binary Digits (bits) Organized into groups of 8 bits - bytes –represents single keyboard character Larger grouping of 16 or 32 bits - word –represents single integer value –identified by address for access
Memory Sizes Kilobyte (K) = 2^10 = 1,024 bytes Megabyte (Mb) = 2^20 = 1,048,576 bytes Gigabyte (Gb) = 2^30 = 1,073,741,824 bytes
Decimal Number Systems Base 10 Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 e.g = = 3 x 10^2 + 4 x 10^1 + 2 x10^0 = 3 x x x 1 =
Binary Number System Base 2 Digits 0, 1 e.g = = 1 x 2^2 + 1 x 2^1 + 0 x 2^0 = 1 x x x 1 = = 6
16-bit Memory Word To store number 6, use Value 0 is Largest value is = 65,535 = 2^ bit word gives largest value > 4 billion
Converting Decimal to Binary Repeatedly divide by 2, recording remainders in reverse order e.g. 53 / 2 = 26 R 1 26 / 2 = 13 R 0 13 / 2 = 6 R 1 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 giving
Converting Binary to Decimal Repeatedly multiply by 2 and add next bit e.g x 2 = = 1 1 x 2 = = 3 3 x 2 = = 6 6 x 2 = = x 2 = = x 2 = = 53
Storing Negative Values Sign Magnitude –use first bit as sign bit, 0 = positive 1 = negative –e.g. 8-bits = = = = -1… = = -127 –problem -0 ????
Negatives (2) One’s complement - complement bits if neg –e.g = = –e.g. 8-bits = = = = -1… = = -127
Negatives (3) Two’s complement –if positive, use binary –if negative, complement bits and add one –e.g magnitude complement add
8-bit Two’s Compement = = = = = -2… = = = -128
16-bit two’s complement 8-bit two’s complement range is - 2^7 to 2^ to bit two’s complement range is - 2^15 to 2^ ,768 to 32,767