2ND YEAR  (B.TECH)  

COMPUTER SCIENCE AND ENGINEERING

RTMNU , NAGPUR 

SUB-     SYATEM PROGRAMMING

 INTRODUCTION TO SYSTEM PROGRAMMING

INTRODUCTION

·         The main aim of system programming is to design of system software and to provide basic for judgment in the design of software. And we will do it through discuss of design and implementation of the major system component.

·         Computers are basically machines that follow very specific and primitive. Computer now a day’s cannot understnd such languages with the aid of some program which are called as system programs.

·         System program (i.e. compiler, loader, macro processors, operating system) were developed to make the computers better adapt to needs of the users.

Fig. Foundation of System Programming

EVOLUTION OF THE COMPLEMENTS OF A SYSTEM PROGRAMMING 

·         Assembler:

1.    Assembler is a program for converting instructions written in low-level assembly code into reloadable machine code and generating along information for the loader.

·                                      Loader:

1.Loader is the part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution.

2.      Loading a program involves either memory-mapping or copying the contents of the executable file containing the program instructions into memory, and then carrying out other required preparatory tasks to prepare the executable for running.

  Macros:

1.  The macro processor substitutes the definition for all occurrences of the abbreviation (macro call) in the program. Basically it is used in design of operating systems where a number of macro calls are written.

2.      Macro represents a group of commonly used statements in the source programming language.

3.      Macro Processor involves definition, invocation, and expansion.

·                                Compiler:

1.      A compiler is a program that accepts a program in high level language and produces an object program where an interpreter is a program that executes a source program as if it were in machine language.

2.      Basically the name of the language and the compiler are same i.e. C, C++, FORTRAN.

·                            Linker:

1.      Linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program.

2.      A linker is a program in a system, also known as a link editor and binder, which combines object modules into a single object file. Generally, it is a program that performs the process of linking; it takes one or multiple object files, which are generated by compiler.

OPERATING SYSTEM

·         An operating system (OS) is a collection of software that manages computer hardware resources and provides common services for computer programs. 

·         Operating System lies in the category of system software. It basically manages all the resources of the computer.

·          An operating system acts as an interface between the software and different parts of the computer or the computer hardware. 

·         It controls and monitors the execution of all other programs that reside in the computer, which also includes application programs and other system software of the computer.

·         Examples of operating system are Windows, Linux, Mac OS, etc.

Function of operating system

 • Job sequencing, scheduling, and traffic controlling application.

 • Input/ output programming.

• Protecting it from uses and protecting the user from other users.

 • Secondary storage management.

 • Error handling. 

The primary functions of an operating system include:

1.  Resource management: The operating system manages and allocates memory, CPU time, and other hardware resources among the various programs and processes running on the computer.

2.  Process management: The operating system is responsible for starting, stopping, and managing processes and programs. It also controls the scheduling of processes and allocates resources to them.

3. Memory management: The operating system manages the computer’s primary memory and provides mechanisms for optimizing memory usage.

4.    Security: The operating system provides a secure environment for the user, applications, and data by implementing security policies and mechanisms such as access controls and encryption.

5.  File management: The operating system is responsible for organizing and managing the file system, including the creation, deletion, and manipulation of files and directories.

Computer Language

·        A computer language is a group of instructions that are used to create computer programs. This is the brief of computer languages. The main goal is to achieve human-computer interaction

Types of Computer Languages

Different types of Computer languages are given below.

1. Low Level Language:

Ø  A Low-level computer language includes only 1’s and 0’s. This language was used in first and second generation computers.

Ø   A Low level language is very easily understood by a computer but hard to understand for Humans. 

Ø  Low level languages are designed to interact with computer hardware, which are categorized into two types: Machine level language and Assembly level language.

2.    Machine Language:

§  As discussed above, Machine level language is a type of Low level language. Machine language is considered to be the oldest computer language.

§  Machine language is developed by only using binary numbers i.e., 0 and 1. So, the instructions or the statements in this language use a sequence of 0’s and 1’s.

Machine Architecture of IBM 360/370

The structure above consists of -

1. Instruction Interpreter
2. Location Counter
3. Instruction Register
4. Working Registers
5. General Register

·         The Instruction Interpreter Hardware is basically a group of circuits that perform the operation specified by the instructions fetched from the memory.

·         The Location Counter can also be called as Program/Instruction Counter simply points to the current instruction being executed.

·         The working registers are often called as the "scratch pads" because they are used to store temporary values while calculation is in progress.

·         This CPU interfaces with Memory through MAR & MBR

·         MAR (Memory Address Register) - contains address of memory location (to be read from or stored into)

·         MBR (Memory Buffer Register) - contains copy of address specified by MAR

·         Memory controller is used to transfer data between MBR & the memory location specified by MAR
The role of I/O Channels is to input or output information from memory.

·         Instruction interpreter: A group of electronic circuits performs the intent of instruction of fetched from memory.

·         Location counter: LC otherwise called as program counter PC or instruction counter IC, is a hardware memory device which denotes the location of the current instruction being executed.

·         Instruction register: A copy of the content of the LC is stored in IR.

·         Working register: are the memory devices that serve as “scratch pad” for the instruction interpreter.

 

·         General register: are used by programmers as storage locations and for special functions.

·         Memory address registers (MAR): contains the address of the memory location that is to read from or stored into.

·         Memory buffer register (MBR): contain a copy of the content of the memory location whose address is stored in MAR. The primary interface between the memory and the CPU is through memory buffer register.

·         Memory controller: is a hardware device whose work is to transfer the content of the MBR to the core memory location whose address is stored in MAR.

 

·         I/O channels: may be thought of as separate computers which interpret special instructions for inputting and outputting information from the memory.

 

To illustrate how these components of machine structure interact, let us take a command ADD 2,176.

This instruction has three parts first the opcode i.e. ADD, second is the number of the register that contain the first operator, third is the memory location address that contain the second operand.

 

·         At first, the address from the IC is copied to the MAR.

·         Then the instruction is fetched to the MBR.

·         The instruction is then transferred to the IR.



·         Then the operand of the instruction is checked and the corresponding branch is taken, here ADD branch is chosen.

·         Then the memory location of the second operand is placed in the MAR.

·         Then the content is placed in MBR.

·       Now the first operand is placed in the WR.

·       Finally the sum of WR and MBR is calculated and the stored in WR.

·       The content of WR is stored to the register that contained first operand.

·       And then IC is incremented to point to the next instruction.

 

·         GENERAL APPRACHES TO A NEW MACHINES

·         In order to know a new machine we have a number of questions in mind. These questions can be categorized as follows.

·         Memory: Basic unit, size and addressing scheme.

·         Registers Number of registers, and size, functions, interrelation of each register.

·         Data: Types of data and their storing scheme. 

·         Instruction: Classes of instructions, allowable operations and their storing scheme.

·         Special Features: Additional features like interrupt and protections.

·         Machine structure -360 and 370

·         All the parameter defined above will be discussed for IBM 360 and 370 machines.

 

Registers

·    There are a total of 16 general purpose registers of 32 bits each. In addition there are 4 floating point register of 64 bits each. It also has a 64 bits program status word (PSW) that contains the value of the location counter, protection information and interrupt status.

·    The general purpose registers are basically used in arithmetic and logical operations as base registers and helps in address formation. The general purpose registers also used as scratch pads for the programmers. Let us take an instruction A 1,901(2,15).A(opcode)1(operand in register 1),901(offset) (2(index register),15(base register))

·   This is how the memory locations are addressed in case of 360 and 370. The use of base registers in addressing is twofold

·    First it helps the loader in the process of relocation (changing the content of base register causes the code to be relocated to the specified location).

·    Secondly it decreases the size of instruction as follows: since the memory of 360 is of 224 hence a total of 24 bits are required to specify a particular location of memory. This increases the size of instruction as opcode takes 8 bits and the registers require 4 bits each and the address requires a 24 bits hence the size of the instruction is 8+4+4+24=40 bits (without base register)



Fig. Addressing without the use of base register.

Data:-

The 360 may store several different types of data as is depicted in the figure.


 



The groups of bits stored in memory are interpreted by 360 processor in several ways. The list of different interpretation are shown in the figure are as follow.

 

·         Short form fixed integer         

·         Long form fixed integer

·         Decimal packed                      

·         Unpacked

·         Short form floating point        

·         Long form floating point Logical



Instruction Format

There are five types of instructions that differ in the type of operands they use.

1.       Register operand refers to the data stored in the 16 general purpose registers (32 bits each). Registers being high-speed circuits provide faster access to data than the data in the core. E.g. Add register 3, 4 causes the contents of the contents of the register 4 to be added to that of register 3 and stored back in the register

2.       Stored Operand refers to the data stored in the core memory. The length of the operand depends on the specific data types. For operand of length more than one byte the address is specified by the lowest address byte (leftmost).

E.g. 32 bits binary fixed point fullword with value   +237(X’00 00 01 0B’ in hexadecimal), stored in location 1016, 1017, 1018 and 1019 as depicted below is said to be located at 1016.

   3. The instruction is represented as given in the diagram. The is called as RR format. A total of two bytes are   required to represent the RR instruction 8 bits for opcode and 4 bits each of register(8+4+4=16 bits =2 bytes).

Text Box: Page9The address of ith storage operand is computed from the instruction in the following manner:

Address = c(Bi)+c(Xi)+Di      (RX format)

or          = c(Bi) +Di                 (RS, SI, SS format)

 

Where c(Bi) and c(Xi) represents the content of base and index register respectively. If Xi=0 the c(Xi)=0 likewise for Bi. E.g. here in the figure Bi=5 and it contain i.e. c(Bi)=1000 and Xi=0 so c(Xi)=0.

Then the address of the second operand is calculated as follows for the RX instruction in the figure.


Address = c(B2) + c(X2) + D2

      = c(5) + c(0)   + 16

    = 1000 + 0   +16

= 1016

Hence the instruction cause the content of the word (32 bits) located at address 1016 to be added to the contents of general purpose register 3 (32 bits), with the resulting sum left in general register 3




MACHINE LANGUAGE

In this section we will deal with the machine language of 360 machines. We will not be using 0’s and 1’s or hexadecimal, rather we will be using mnemonics for writing machine level programs.

The figure shows a load instruction as a series of 0’s and 1’s that can be easily represented in the mnemonic code as L 2, 924(0,1). The program that would be used over here adds the number 49 to the contents of 10 adjacent full words in memory, under the following assumptions

1.       The 10 numbers that are to be added to are in contiguous full words beginning at absolute core location 952.

2.       The program is in core starting at absolute location 48.

3.       The number 49 is a full word at absolute location 948.

4.       Register 1 contains a 48.

ASSEMBLY LANGUAGE

·         The era of programming languages starts with machine language and end in English language, thereby making a move from the language that are best for machine to that are best for programmers.

·         So far we have machine language and mnemonic machine language. Now we will be using assembly language for the follows reasons (advantages).

 

1.     It is mnemonics, e.g. we use ST instead of the bit stream 0101000 for the store instruction.

2.     Addresses are symbolic, not absolute.

3.     Reading is easier.

4.     Introduction of data to program is easier.

·         The main drawback of assembly language is that it makes use of an assembler to translate a source program to object code. The assembly language for 360 is much similar to assembly languages that are meant for other machines.