CHAPTER 1 Introduction To Programming

Total Page:16

File Type:pdf, Size:1020Kb

CHAPTER 1 Introduction To Programming

Introduction to Programming

Objective

1. Be able to name and describe the major components of the computer systems in terms of the hardware system and the software systems.

Introduction

This lesson provides an introduction to computer systems with respect to the hardware system and the software system. It surveys the concept of programming paradigms with emphasis on the procedural paradigm versus the object oriented paradigm. The lesson also presents an overview of the Java Programming environment. It covers in a general sense Integrated Development Environment (IDE). The lesson concludes with a survey of how to create a Java application program, how to compile the program, and how to execute the program.

Overview of Computer Systems

A system may be defined as a combination of interrelated components, real or abstract, organized as an integrated whole to ensure the efficient functioning of the entire unit as a whole. Computer systems possess these characteristics. From a functional point of view computer systems can be view as electronic devices that have the capability of performing the following tasks:

1. Respond to input. 2. Process the input according to a set of instructions 3. Store the instructions and results of the processing 4. Provide output in the form of information 5. Transmit data among machines.

Looking closely at this definition we see that items 1, 3, 4 and 5 require physical components or devices. For input, it requires input devices; for storing, it requires storage devices; for output, it requires output devices; and for transmission of data, it requires communication devices. These physical devices constitute the hardware system. The second bulleted item is not a tangible item. It refers to the programs that cause the machine to function. In this next section we will examine these components and their subcomponents in more detail.

Hardware System

The hardware system of a computer has four major components. These are input devices, output devices, the central processing unit, external storage device, and communication devices. These devices are connected by a set of interconnecting wiring system called a bus. There are three types of buses. There is the bus that carries data, the data bus; and the bus that carries control signals, the control bus; and those that carry addresses, the address bus. Figure 1.1 shows a schematic view of the hardware system.

Figure 1.1 The hardware System

Input Devices Computers communicate with the outside world by means of input devices. There are eight categories of input devices. There are: keyboards, pointing devices, scanners, sensors, voice input devices, modems, magnetic tape and discs, and laser devices. All of these input devices have one thing in common. They all convert or encode events that they capture into machine readable codes.

Figure 1.2 Input devices - Keyboard, Mouse, Camera, Barcode scanner

The Central Processing Unit The Central Processing Unit (CPU) for short is the heart of the computer. Its function is to execute programs stored in main memory by fetching each instruction, examining the instruction, interpreting the, and finally executing it. Before we look at how things get done in the CPU, let us look at its structure. The CPU is composed of three major functional units. These are the control unit, the arithmetic logic/unit - (ALU) for short and the set of registers. Figure 1.2 shows a schematic view of the CPU; and Figure 2.3 shows the photograph of two CPUs.

Figure 1.3 View of Two Central Processing Units -CPU

Instruction Execution The CPU executes instructions in a series of small steps. This process may be divided into distinct phases. These are, taken in order: fetch instruction, decode instruction, and execute instruction. The steps for executing a programming are as follows: 1. Control Unit fetches the next instruction from memory into the instruction register. 2. The Program Counter updates its contents to hold the address/point to the address of the next instruction in line to get executed. 3. The Instruction register deciphers the type of instruction just fetched. 4. If the instruction uses data in memory, determine where in memory it is. 5. Fetch the data, if any, and place it into one of the CPU registers. 6. Execute the instruction. 7. Store the result(s) in the proper place. 8. Repeat step 1 through 8 until there is no more instruction left.

The Control Unit This unit is responsible for fetching the instructions from memory, and determining their type.

The Arithmetic Logic Unit.

The ALU carries out arithmetic operations on numeric values; in addition, it is responsible for carrying out comparision (Boolean Arithmetic) on data values.

The Registers.

Registers are high-speed memory devices. The store intermediate results of processing, only temporarily. There are two kinds of registers, namely:-  Special purpose registers  General purpose registers.

The special purpose registers are designated specific task, by the manufacturer. Examples of special purpose registers are:

 The Program Counter (PC) register. This register keeps track of the address of the next instruction that is to be executed.  The Memory Data Register (MDR). This register acts as a temporary resting place for data moving to or from memory.  The Memory Address Register (MAR). This register holds the address of the memory location involved in an operation.  Instruction Register (IR). This register is used to hold instructions that come from memory.

These registers are not accessible by programmers. The general purpose registers are designed for use by programmers. In this regard, the programmer can store data values in these registers.

Incidentally, the time taken to carryout activities 1 - 5 is called the Instruction Time, IT; and the time taken to carryout activities 6 and 7 is called the Execution Time. The total time to carryout one instruction is called the Machine Cycle Time, MCT. This is the sum of the instruction time and the execution time (MCT = IT + ET). The unit of measurement for the Machine Cycle Time is usually quoted in Megahertz (MHz).

Software The term Software is the name given to the set of instructions that allows the computer to function. Computer software can be divided into three broad categories:

 Systems Software  Processing Programs  Application programs

Software Systems

Systems software is programs that manage the hardware resources of a computer. Example:  Operating Systems. Windows XP or Unix  Utility programs. Example: Anti-virus programs and disk formatting programs.

Processing programs This category of programs translates/converts user programs into machine language for execution. Example:  Assembler Example: IBM assembler  Compilers. Example: Java  Interpreters. Example: BASIC Application Software Application software can be broken into two categories. These are:  General-Purpose Software Example: word processors, database management software, among others.

 Application Specific Software. Example: Programs written to solve a specific problem.

A payroll program is a typical example.

Summary

In summary the computer system is composed of three major components. These are:

 Hardware - the physical device  Software – the set of instructions/programs that manages the operations of the hardware.

Recommended publications