Principles of Programming-I / 131101 Prepared by: Dr. Bahjat Qazzaz -------------------------------------------------------------------------------------------- Chapter One Introduction to Computer System Computer System Introduction and Computer Definition Computer System Computer Architecture and Data processing (Principle of work) Hardware I/O devices Central Processing Unit Memories Busses
Computer Introduction A Computer is an electronic device that can process and manipulate, display, and store information in a very short period of time. It is capable of manipulating several different data types. These include numerical data (integer and real numbers), character data (names, addresses, etc.), graphic data (charts, drawings, photographs, etc.), sound, and video (sound and moving picture). The beginning programmers are usually concerned primarily with numerical data and character data. It is usually referred to the processed information as raw information or data. Also, it is always referred to the produced information as useful information, or simply, information. For example, if we decide to count the population of Palestine (e.g. how many males, females, children, old, educated person, etc), then the information that we gather, using questionnaire and interviews or any other collecting methods, is called data. The final results and numbers that we produce, as a result of processing and classifying the data, are called information. Different from the data, information can help to make decisions and draw conclusions. Computer System The computer system consists of two major components, which are the Hardware and Software: 1. Hardware: refers to the set of physical components and devices that compose the computer system. The hardware includes the screen, keyboard, mouse, cables, system box, silicon chips, printed circuits, memories, speakers, etc. However, the hardware cannot do any thing without the software. 2. Software: refers to the set of programs that operate and control the function of the hardware and tell each part of the hardware what to do. Examples of software include: operating systems programs, users and application programs, programming languages, translators and interpreters programs,, etc.
3. A third element that can be considered as part of the computer system is the human being (called user) who programs the computer and/or uses it as a tool to do some useful tasks. However, it is possible to see a computer sitting alone doing some tasks without seeing a human being sitting in front of it. Such computers are called dedicated computers, which are programmed to do specific tasks. Computer History The computer has passed through many developing phases until it reached to what we see nowadays. The books refer to these phases as Computer Generations. In this chapter, we preferred to familiarize the reader with the terminologies and the components of the computer system before talking about the computer history and generations. Therefore, at the end of this chapter, we will give a brief discussion about the history and the key design and major developments that took place in each generation. Computer Architecture and Data Processing Von Neumann and his colleagues have established an architecture model, referred to as IAS, at Princeton Institute of Advanced Studies that in 1945. This architecture (Von Neumann Architecture) dominates the computer systems and is still implemented with little changes by most of the computer factories. In general, and according to Von Neumann architecture, data processing passes through three main steps (operations), which are: 1. Data input. 2. Data processing 3. Data output As the next figure shows, the output of a processed data can be used as an input for processing of later data. This is called feedback.
Feedback Input Processing Output The principle function of the computer The Von Neumann architecture consists of four units (or sub systems), which are: 1. Input/Output Units (I/O devices) 2. Main Memory (RAM) 3. Arithmetic and Logical Unit (ALU) 4. Control Unit (CU) CPU Main Memory Arithmetic Logic Unit Program Control Unit I/O equipment Structure of ISA Computer Traditionally, the books use the term CPU (Central Processing Unit) to refer to the ALU, CU, and some small memory locations called Registers. The registers are used temporarily by the CPU for performing its tasks. The next figure shows the main registers used in the ISA architecture.
Arithmetic-logic unit (ALU) AC MQ Arithmetic-logic circuit Input- Output Equipment MBR IBR IR PC MAR Main Memory Control circuits control signals address Program control unit (CU) As the previous figure shows, Both the ALU and CU contain storage locations called registers. These registers are: Memory Buffer Register (MBR): ---contain data read from or to be written to memory Memory Address Register (MAR)---specifies address of word where to read from or write to memory Instruction Register (IR)---contain 8-bit op-code instruction being executed Instruction Buffer Register (IBR)---holds the right-hand instruction from a word in memory Program Counter (PC)---contains the address of the next instruction to be executed Accumulator (AC) and multiplier quotient (MQ)---holds operands and results of ALU operations temporarily
IAS operates by repetitively performing an instruction cycle, each instruction cycle consists of two sub-cycle: Fetch cycle: during this cycle, an instruction is taken from memory, then to MBR, down to the IBR, IR, and MAR. Or it can be taken from IBR. The opcode is loaded to IR, and the address portion is loaded into MAR. Execute cycle: during this cycle, control circuitry interprets the opcode and execute the instruction by sending out appropriate control signals to cause data to be moved or an operation to be performed by the ALU. Computer Hardware As we said before, the Von Neumann architecture defines 4 major parts to the computer system, which are Input/Output devices, Memories, and CPU. In this section we will come to each one of them with more details. However, we will add another important part, called buses, which refer to the communication lines installed between the computer parts. 1. Input devices: they allow users to enter their instructions and data. The major and common used input devices are keyboard and mouse. Other devices include light pen, microphone, scanners, communication line, digital cameras, video camera, joystick, track ball, etc. 2. Output devices: they are used to show and display, or store, the information in a form that can be understandable by the user. The major and common output devices are the screen and printer. Other output devices include speakers, plotters, storage media (floppy disk, hard disk, CDs) etc. It is usually referred to the Input and Output (I/O) devices as the computer peripherals. The peripherals include other special I/O devices such as Modem, touch screens, Disk drives, many types of printers, projectors, etc.
3. Memories: these are used to store data, programs instructions, and information temporarily and/or permanently. The data is stored and represented in memories using a system called Binary System which uses two symbols 1 and 0. Each of these symbols is called Bit (Binary Digit). Every 8 bits are called Byte. One Kilobyte is equal to 1024 bytes (2 10 ), One Mega byte is equal to 2 20, and One Giga byte is equal to 2 30. Name Symbol Equ. Value Kilo Byte KB 2 10 1024 Mega Byte MB 2 20 1048576 Giga Byte GB 2 30 1073741824 Tera Byte TB 2 40 1099511627776 Pita Byte PB 2 50 1125899906842624 Exa Byte EB 2 60 1152921504606846976 Now we turn our focus to the Memories types which include: a. Main memory: it is usually called Random Access Memory (RAM). This memory is fast and expensive. Also, it is called volatile memory since it loses the data stored in it when the power is turned off. (Technology: Static RAM (SRAM), Dynamic RAM (DRAM)). b. Auxiliary memory: also called Secondary Memory. This memory is not as fast as main memory, but the data can be stored in it permanently. Examples of this type of memory are the hard disk and floppy disk. Even though the power is turned off, the data remains stored in these disks unless they are subjected to physical damaged or overheated. Different from the RAM, the hard disk is capable of storing a huge amount of memory. Under the secondary memory category we can list the following types of memories: i. Hard disc: the next figure shows the structure of the hard disc. It consists of a set of magnetic discs rotating around an access and a set of
read/write arms used for writing data on the discs and reading data from them. Tracks Rotating Access Read/Write Arm Magnetic disc Sectors Hard disc structure The disc consists of tracks and sectors and it has gabs between sectors and gabs between tracks in order to avoid interference and mis-allignment. See the next figure. Tracks Gabs between tracks Gabs between sectors Sectors Structure of one of the surface of a hard disc ii. Floppy disc: it is an elastic single magnetic disc capable to store 1.4 Mega Byte. It also consists of tracks and sectors. Like the hard disc, it may come unformatted or formatted by the manufacturer. Suppose that this disc has 80 tracks and 36 sectors, and each sector (which the smallest unit in the disc) can store up to 512 bytes, then the capacity of
the disk is 80*36*512 = 1474560 byte, and this is equal to 1.4 Megabyte. iii. iv. Magnetic Tape: It was used for its high capacity and low cost. It is still used by some companies for backup purposes. Its problem is that it is slow and it is accessed sequentially. CD-ROM (Compact Disk-Read Only Memory): It uses laser technology for reading the data stored on it. The CD-ROM allows storing a large amount of data (measured in hundred of mega bytes) that cannot be erased or changed. This kind of CD is called CD-R. However, there is a variation for the CD-ROM so that it can be erasable and writable. This kind is called CD-RW. Speed 1x 2x 4x 8x 24x 32x 40x 52x Data Rate, Bytes/second 153600 Bytes 307200 Bytes 614400 Bytes 1228800 Bytes 3688400 Bytes 4915200 Bytes 6144000 Bytes 79872000 Bytes v. DVD (Digital Versatile Disk): It is a variation to the CD-ROM, however it can stores more data (measured in several Giga bytes) such as 120 minutes of video data. vi. Flash memory: The flash allows storing and erasing its contents (blocks of data) in a very fast way. c. Read Only Memory (ROM): the data is stored once in this memory and cannot be changed or deleted. It is very fast but with a very small capacity of storage. The BIOS (Basic Input Output System) is an example of ROM. It
keeps instructions (code) and data which make the computer work when turning it on. ROM has different variations such as Programmable ROM (PROM), Erasable ROM (EROM), and Erasable Programmable ROM (EPROM) as well EEPROM. With the EPROM, the user takes off the memory and uses ultra violet ray to delete its contents the reinstalls it back in the computer. However, with the EEPROM the data is deleted by using electronic pulses and without the need to take it from the computer. d. Cache memory: it is an intermediate memory that links the CPU with the main memory. It has very fast chips, and its main goal is to speed up the processor by keeping the most frequently used instructions and data in it for future use by the CPU. When the CPU needs specific data it tries to fetch it from the cache, if it finds it (this is called hit) then the cache send the data to the CPU, otherwise (this is called miss), the CPU tries to fetch it from the main memory and keeps copy of it in the cache for future possible use. Cache Memory Central Processing Unit Main Memory Cache memory 4. Central Processing Unit (CPU): it is considered as the computer brain. The CPU (also called microprocessor) is a chip attached to the computer motherboard. The CPU is responsible for fetching the software instruction and executing them in order to produce information. The CPU consists of three parts (Draw figure ) a. Arithmetic and Logic Unit (ALU): it performs all the arithmetic operations (such as area = length * width, x = 10 + 20, w = x + y/2, etc.) and logical
operations (such as: if(average > 90) printf ( Excellent ), if(x == y) printf ( x and y are equal), etc). b. Registers: these are small yet fast memory locations which are used by the CPU to store instruction and data temporarily. Registers includes: Data Register, Address register, Instruction Register, Program Counter etc. c. Control Unit (CU): it controls all the operations of the CPU. It controls the movement of the electronic signals between the ALU and main memory, and between the I/O devices and the memory. 5. Buses (connecting cables): The computer system has four major types of cables (buses) as the next figure shows. a. Address bus: carries the address of the memory location where to read from or write to. This bus can be of 8, 16, or 32 bit or may be more. b. Data bus: carries the data moved from memory to CPU and vice versa c. Control bus: carries the signals generated by the control unit to the system parts. These signals inform the computer parts what to do. d. Power lines: provide the computer components with the power. Motherboard: is a circuit board that combines and holds most of the computer hardware such as CPU, memory, busses, cards slots, transistors, capacitors, resistors etc.
Central Processing Unit Data Adress Control signals Main Memory Input/Output devices Main components of a computer