0% found this document useful (0 votes)
37 views32 pages

Unit 1

unite wise class note

Uploaded by

pathakaashish993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views32 pages

Unit 1

unite wise class note

Uploaded by

pathakaashish993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

srizanaryal.blogspot.

com 1
Chapter-1

Introduction
Software
Software is as set of instructions or programs written to carry out certain task on digital
computers
Types of software
1. System software
2. Application software
System software
 System software consists of a variety of programs that support the operation of a
computer

 Ex:OS,compiler,loader linker ,assembler,macroprocessor

 System software acts as an intermediary between the users and the hardware. It creates a
virtual environment for the user that hides the actual computer architecture.

 Virtual machine is a set of services and resources created by the system software and
seen by the user.

Application software
 An application is a program, or group of programs, that is designed for the end user.

 The special purpose programs are also know as packages

 Ex. database programs, word processors, Web browsers and spreadsheets, library
management system.

srizanaryal.blogspot.com 2
Difference between system software and application program
System software Application software
1. It is used in the operation of the computer. 1.it is used to perform some user task
2. it is machine dependent software 2.it is machine independent software
3.the programmer should know the architecture 3.not necessary to know the
of the computer architecture of the computer
4. System software is not meant to be run by 4. Application software can be run by
the end user. the end user.
5.inventory, payroll preparation,
5.ex compiler,loader,os,assembler etc. banking system etc

The role of system software

Components of system software


The various components of system software are:
1. Assemblers
2. Loaders
3. Macros
4. Compilers or interpreters
5. Operating system
Assemblers
Assemblers are the programs that translate the assembly language program (source code)
into machine language program (object code)
Loader
Loader is system software that places the program into memory and prepares them for
execution.
Macros:

srizanaryal.blogspot.com 3
Macro processor is a program that substitutes and specializes macro definitions for macro
calls.
Compilers:
The programs that translate the high level language program (source code) into machine
language program (object code)

Operating system
It contains programs which manage and it is concerned with allocation of resources and
services such as memory, processor, devices and information.

Machine structure

Memory
 Memory is the device where information is stored and retrieved.

 Information is stored in the form of 1‟s and 0‟s.

 Each 1/0 is a separate binary digit called bit.

 Bits are grouped into words, characters or bytes.
o Nibble 4bits
o Byte 8bits
o Half word 16bits
o Word 32bits
o Double word 64bits
Basic unit of memory is a byte
 the content of memory are

o DATA- values to be operated on

o INSTRUCTIONS-operation to be performed

 Instructions and data shares the same memory or storage medium

srizanaryal.blogspot.com 4
Processor
 Processor is a device that performs a sequence of operations specified by instructions in
memory.

 There are two types of processors,

1. Central processing units
2. Input and output processors
Central processing units
 It is the brain of the computer

 It controls all internal and external devices, performs arithmetic and logic operations

 It also carries out the instructions of a computer program

 It is concerned with manipulations of data stored in memory
Input and output processors
 Input and output processors transfers data between memory and peripheral devices such
as disks, drums, printers etc.

 An I/O processor executes these instructions which are activated by a command from the
CPU.

 Programming the I/O processor is called as I/O programming

srizanaryal.blogspot.com 5
Evolution of the components of a programming
system Assembler
 In the earlier stages the computer programmers are used to write programs using 0‟s and
1‟s.programmers found difficult in writing programs using machine language

 Assembly language is a low level programming language that allows a user to write
programs using letters and symbols (mnemonic) which are more easily remembered.

 Assembler is a system program supplied by the computer manufacturer

 Assemblers are the programs that translate the assembly language program(source code)
into machine language program(object code)

Loaders
 The purpose of a loader is to assure that object programs are placed in memory in an
executable .the assembler itself could place the object program directly in memory and
transfer control to it, then that machine level language program is executed. But there are
two disadvantages

1. Wastage of memory-assembler itself occupies more space in memory during
execution.
2. Wasting translation time-need of retranslation of the program with each
execution.inorder to avoid this the new system software called loader is introduced
 If the program size is very large then subdivide the program into smaller routines called
sub-routines

 There are two different types Subroutines

srizanaryal.blogspot.com 6
1. Closed subroutines
2. Open subroutines

 The task of adjusting programs, so that they may be placed in arbitrary memory locations
is called relocation

srizanaryal.blogspot.com 7
 Relocating loader perform four functions

1. Allocate space in memory for the programs (allocation)
2. Resolve symbolic references between object decks(linking)
3. Adjust all address dependent locations(relocation)
4. Physically place the machine instructions and data into memory(loading)
 Based on the loading function the loader is divided into different types they are

1. Compile and go
2. Absolute loader
3. Relocating loader
4. Direct linking
5. Dynamic loading and linking
Macros
 To eliminate the need of repeating identical parts of the program, operating systems
provide a macro processing facility

 Macro permits to define an abbreviation for a part of program and use the abbreviation in
anywhere in a program. The macro processor treats the identical parts of program defined
by the abbreviation as a macro definition.

 The macro processor substitutes the definition for all occurrences of the abbreviation in
the program
Compiler
 As the user started concentrating problems into areas such as scientific, business, statistica l
areas. High level languages were developed to express certain problems more easily.

 COBOL,FORTRAN,PASCAL,ALGOL ,C etc are high level languages, which is
processed by compilers and interpreters

srizanaryal.blogspot.com 8
Formal systems
 A formal system is an uninterrupted calculus. It consist of
o An alphabet

o A set of words called axioms and

o A finite set of relations called rules of inference

 Examples of formal systems are set theory,boolean algebra, post systems

 Uses of formal systems

o Used in the design, implementation and study of programming language s
o Used to specify the syntax and the semantics of programming languages

o Used in syntax directed compilation, compiler verification and complexity studies of
languages

Operating system
 OS is a program that controls the execution of an application program and acts as an
interface between user and computer hardware.

srizanaryal.blogspot.com 9
 The main functions of operating system are
o Job sequencing

o Job scheduling

o Input/output programming

o Secondary storage management
o User interface

o Error-handling

Answer the following questions:


1. Differentiate between system software and application software. (5M, June 2013)
2. Differentiate between compiler and interpreter. (5M, June 2013)
3. Define loader. Mention the functions of loader. (3M, May 2012)

srizanaryal.blogspot.com 10
Chapter-2
Machine structure, machine language and assembler language

History of IBM System/360/370


  IBM System/360 was announced in April 1964.
  System/360 was the first line of processors with upward and downward compatibility.
 System/360 was the first major product line designed for both business and scientific
 need.
 IBM System/370 was announced in June 1970.

 Addressing and virtual memory architectures are created and enhanced the performance
 of 370.
 System/370 had an execution time 3 to 5 times faster than system/360 model 50 and 60.

General machine structure


The CPU consists of
  An instruction interpreter
  A location counter
  An instruction register
  Various working registers and
 General purpose registers

srizanaryal.blogspot.com 11
Instruction interpreter
 It is a group of electrical circuits that performs the purpose of the instructions fetched
 from the memory.
 It is like a decoder that decodes the type of the instruction.

It is also known as program counter or instruction counter which holds the location of the
current instructions being executed

 WR are memory devices that serves as „SCRATCH PAD‟S‟ (a plurality of multibit


 storage locations) for instruction interpreter.
 WR are general purpose registers.
General purpose register
GPR‟S are used by the programmer as storage locations and for special functions.
Memory address registers (MAR)
It contains the address of memory location that is to be read from or stored into.
Memory buffer register (MBR)
It contains a copy of the designated memory location specified by the MAR, after read or
write.
Memory controller

It is hardware that transfers data between the MBR and the core memory location the
address of which in the MAR
I/O channels
It may be through of as separate computers which interpret special instructions for
inputting and outputting information from the memory.

Machine structure of IBM 360


Memory
  Memory is the device where information is stored and retrieved.
  Information is stored in the form of 1‟s and 0‟s.
  Each 1/0 is a separate binary digit called bit.
 Bits are grouped into words, characters or bytes.
o Nibble 4bits
o Byte 8bits 1bytes
o Half word 16bits 2bytes
o Word 32bits 4bytes
o Double word 64bits 8bytes
  Size of the IBM 360 memory is up to 224 bytes
 Address: Memory locations are specified by addresses, where each address identifies a
specific byte or word. The addressing scheme used in IBM 360 contents of it may be data
 or instructions

srizanaryal.blogspot.com 12
 Address=value of an offset + contents of a base register + contents of an index register

Registers
Types of register are
Name of the register number size
 General purpose registers 16 32bits each
 Floating point registers 4 64bits each
 Program status word 1 64bits

General purpose registers


  IBM 360 machine has 16 general purpose registers denoted by R0 to R15.
 The general purpose register may be used for various arithmetic and logical operations
these registers acts as scratch pads and base-registers they aid in the formation of the
 address.
 For example
A 1,901(2, 15)
Where A - add opcode
1 - Argument registers number

901 - offset
2 - Index register
15 - Base register
The total number of bits for an add instruction would be 32

Advantage of base register


 It helps in the process of relocation of a program.i.e., an entire program may be
moved from one series of locations to another by changing the contents of the base
 register
  Efficient addressing of core
 Saves 8 bits per address reference.
Disadvantages of base register
  Overhead associated with the formation of the address during execution
 Difficult to reach the data.
When we were not using the base register, to address all the 224 bytes locations, we
would have needed 24 bits for every address, whose format would be

srizanaryal.blogspot.com 13
i.e., if base register is not used 40 bits is required for each instruction which leads to an addition
of bits and thus wastage of memory.

Program status word(PSW)


It contains the value of the location counter, protection information and interrupts status
which is 64bits in length.

Data formats
The different types of data formats present in IBM system 360 are
1. Short form fixed point numbers
2. Long form fixed point numbers
3. Packed decimal numbers
4. Unpacked decimal numbers.
5. Short form floating point number

6. Long form floating point numbers


7. Logical or character data

1.Short form fixed point numbers

Example 1: Decimal number +257 is represented as


S(+) binary equivalent
0 000 0001 0000 0001
16bits

2. Long form fixed point numbers

Example: The byte address starting from 1016 it occupies four locations
4 bytes =32bits
0 000 0000 0000 0000 0000 0001 0000 1011
S(+) 1016 1017 1018 1019
Byte address
3. Packed decimal numbers

srizanaryal.blogspot.com 14
  The numbers are represented in binary coded decimal format
  Sign bit contains the BCD of hexadecimal digits A,B,C,D,E & F
  The hex digits C,A,F,E indicates a +ve numbers
 While D & B indicates a –ve numbers
Example:-021 is represented as
2bytes
0000 0010 0001 1101

BCD 0f 021 sign bit(-)

4. Unpacked decimal numbers.

 The last 1byte (4+4 bits) is reserved for sign and data.

 In between the BCD of each numbers a 4 bit zone code/padding bit/internibble bit is
 introduced which contains 0/1.
  The hex digits C,A,F,E indicates a +ve numbers
 While D & B indicates a –ve numbers

5. Short form floating point number

Example:-118.625e5
4byts(32bits)
1bit 7bits 24bits
1 1000010 0111 0110 1010 0000 0000 0000
S Exponent Fraction

srizanaryal.blogspot.com 15
 1bit-sign bit(-ve)

 7bits represent exponent-in this example 5 is the exponent the range of the 7bit is 127.so
add 127+5=132 then 132 is convert to binary(2) by division method

 24bits represents fraction- in this example 0.625 is the fractional part then convert 0.625
to binary by repeated multiplication by 2

6. Long form floating point numbers

It is same as short form floating point numbers but in Long form floating point numbers
consists of 64bits (8 bytes) are allocated for the floating point number which contains the
exponential and fractional part

7. Logical or character data


In character data each character code is stored in 8 bits (1byte) and its length varies from 1
to 256 bytes.

Example: „A‟ is represented in IBM 360 as


1byte
0100 0001
Instructions
  An instruction includes an opcode, specifying the operation to be performed, such as
“add contents of memory to register” and zero or more operands, which may specify
registers, memory locations or literal data. The operand may have addressing modes
determining their meaning or may be in fixed fields.

 The size or length of an instruction varies from 2 bytes to 6 bytes depending on the
 instruction formats
 Instructions are of different types they are
o Arithmetic instructions
o Control or transfer instructions.
o Special interrupt instruction
  The different types of operands
o Register operands
o Storage operands
o Immediate operands

srizanaryal.blogspot.com 16
Register operands
Register operands refer to data stored in one of the 16 general purpose registers, which
are addressed by 4 bit field in the instruction.
Storage operands
Storage operand refers to data stored in core memory. The length of the operand depends
upon the specific data type.
Immediate operand
Immediate operands are single byte of data and are stored as part of the instruction.

The different instruction formats are


o RR format
o RX format
o RS format
o SI format
o SS format

RR instruction:
  RR instruction denotes register to register operation.i.e, both the operands are register.
  The length of RR instruction is 2 bytes (16 bits)
 The general format of RR








 Example: the instruction is Add 3, 4

RX instruction:
  RX instruction denotes a register and indexed storage operation
  The length of RX instruction is 4 bytes (32 bits)
 The general format of RX instruction is

 Indexed storage operand refers to the data stored in core memory. The address of the
storage operand is calculated as follows

srizanaryal.blogspot.com 17
 Address=value of an offset or displacement + contents of a base register + contents of an
index register

 =C(B2)+C(X2)+D2
 Example: ADD 3,16(0,5)
4 BYTES

OP R1 X2 B2 D2
0101010 0011 0000 0101 0000 0001 0000

ADD FROM STORAGE 3 0 5 16


TO REGISTER

  Assume base register 5 contains the number 1000


 The address of the storage operand= C(B2)+C(X2)+D2
=C(5)+0+16
=1000+0+16
=1016

RS instructions
  RS instruction denotes register and storage operation
  The length of RS type instruction is 4 bytes (32 bits).
 The general format of RS instruction is

 Address=value of an offset or displacement + contents of a base


 register =C (B2)+D2
 Example 1: LM 1, 3 16(5)

4bytes
OP R1 R3 B2 D2
1001 1000 0001 0011 0101 0000 0001 0000
Load multiple
register 1 3 5 16
  Address =C (B2) + D2
= C(5)+16
=1000+16
=1016
 The load instruction loads register 1 and 3 with the contents of location 1016

srizanaryal.blogspot.com 18
SI instruction
  SI instruction denotes storage and immediate operand operation
 Immediate operands are single byte of data and stored as part of the instruction

  The length of SI type instruction is 4 bytes (32 bits).


 The general format of SI instruction is

 Address=value of an offset or displacement + contents of a base


 register =C (B1) +D1
 Example: MOV I2, 4(5)

 Address of storage operand =C(B1)+D1


=C(5)+4
=1000+4
=1004

SS
 instruction
  SS instruction denotes a storage to storage operation
  The length of SS instruction is 6 bytes(48 bits)
 The general format is

 Example 1: MVC 32 (79, 5), 300(5)

srizanaryal.blogspot.com 19





  In SS format, the length is always on less than the data moved.i.e. If L=0 move 1 byte.
 Here L=79, therefore move 80 bytes from location 1032[till 1111(1032+79)] to 1300[till
1379(1300 + 79)]
Instruction set
The various categories of instructions are
1. load-store registers instructions
2. Fixed point arithmetic
3. Logical instructions
4. Transfer instructions
5. Miscellaneous instructions

1. load-store registers instructions

srizanaryal.blogspot.com 20
2. Fixed point arithmetic

3. Logical instructions

srizanaryal.blogspot.com 21
4. Transfer instructions

5. Miscellaneous instructions

Machine level language


Machine language is the basic language of the computer, representing data as 1‟s and
0‟s. Example1: L 2,924(0, 1)
OP R1, D2(X2, B2)

Advantages of machine language


 Instructions of a machine language program are immediately executed, they require no
compilation or translation.

srizanaryal.blogspot.com 22
  Machine language make efficient use of storage
Disadvantages

 Machine languages are machine dependent

 Machine language is difficult to program, since the programmers has to know the
 architecture of the system.
 Writing, reading, correcting or modifying a machine language program is difficult.

Example program:
Write a program that will add the number 49 to the contents of 10 adjacent full words
(32bits or 4 bytes) in memory with the following assumptions:
1. The 10 numbers are contiguous full words beginning at absolute location 952.
2. The program is in core memory starting at absolute location 48.
3. The number 49 is a full word at absolute location 948.
4. Register 1 contains a 48.

Fig shows the core memory structure.

This program can be written using three different ways


1. Long way, no looping.
2. Address modification using instruction as data.
3. Address modification using index registers.
4. Looping

1. Long way, no looping.


  Register 2 is used as an accumulator
  Index register is 0.therefore the contents of the index register is also 0.
 Address of the storage operand=offset + contents of the base register.

 Content of register 1 is 48.

srizanaryal.blogspot.com 23
L 2,904(0, 1)
  Load the first number into register 2
 Address of the storage operand =904+contents of base
register1 =904+48 =952

 Contents of register 2=contents of memory location 952=Data1

A 2,900(0, 1)
  Add 49 with data1
 Address of the storage operand =900+contents of base
register1 =900+48 =948

 Contents of register 2 =contents of register2+contents of memory location 948
=Data1+49
ST 2,904(0, 1)
 Address of storage operand =904+contenet of register1
=904+48
=952
 Content of register 2 =content of base register2
=Data1+49

L and ST are RX type instruction. Whose size is 4 bytes. Therefore absolute and relative
address is incremented by 4.

Advantages
  Implementation is easy.
Disadvantages

  Instructions are repeated for all the data items
srizanaryal.blogspot.com 24
 It is impossible to access both the first data item and the last data item using register 1 as
 the base
  Wastage of memory
  Need of relocation.
 Instruction would overlap data in the core.

Address modification using instructions as data

 In this approach the problem consisting only of those 3 instructions followed by a the
sequence of commands that would change offset of the load and store instruction by
adding 4 to them.

srizanaryal.blogspot.com 25
 In addition to the 4 assumptions given in the problem statement, we are going to make
 one more assumptions.
 Assumption 5: relative location 896 contains a 4.

 Here instruction is treated as data. Therefore adding 4 to an instruction will update its
 offset.
  For example, if location 48 contains the instruction L 2,904(0, 1)
 The instruction is stored as follows from byte number 48

Now when we add 4 to this instruction, the offset present in the 4 th byte is treated as data
and is incremented by 4.
L+4=904+4
=908

srizanaryal.blogspot.com 26
Advantages
  Saves memory
 Address is modified easily using the instruction.

Disadvantages
  Treating instructions as data is not a good programming practice
 Separate instructions are used for increasing the displacement(offset) of load and store

Address modification using index registers


 In this approach,we use the same 3 instructions i.e.,load,add and store.we simply loop
through these 3 instructions,updating the storage operands of load and store instructions,b y
 adding 4 to the contents of the index register during each pass.
 Register 4 is used as an index register.

srizanaryal.blogspot.com 27
SR 4, 4
  Clear register 4 by subtracting the contents of register 4 from register 4.
 The contents of register 4=0

L 2,904(4,1)
  Load data element of array
 Address of the storage operand=904+contents of index register 4+contents of base
register 1
=904+0+48
=952
 Content of register 2 =contents of memory location
952 =data1.
A 2,900(0, 1)
 Add 49
 Address of the storage operand =900+contents of base register 1
=900+48
=948
 Contents of register 2 =contents of register 2+contents of
memory =Data1+49
ST 2,904(4, 1)
 Replace data element

 Address of the storage operand =904+contents of index register 4+contents of base


register1
=904+0+48
=952
 Contents of memory location 952 =contents of register2
=Data1+49
A 4,896(0,1)
 Add 4 to index register
 Address of the storage operand =896+contents of base register1
=896+48
=944
 Contents of index register 4 = Contents of index register 4+contents of memory
location944
=0+4=4
Note
  SR is RR type instruction, whose length is 2 bytes
  L is RX type instruction, whose length is 4 bytes
  A is RX type instruction, whose length is 4 bytes

srizanaryal.blogspot.com 28
  ST is RX type instruction, whose length is 4 bytes
 Contents of index register 4 will be 4,8,12 etc during the subsequent passes

Advantages
  Easy to understand
 Saves memory



4. Looping

  Assumption 6: relative location 892 contains a 10


 Assumption 7: relative location 888 contains a 1.

L 3,892(0, 1)
 Load data into register 3
 Address of the storage operand =892+C(B 1)
=892+48
=940.
 Content of register 3 =contents of memory location
940 =10
S 3,888(0, 1)
 Subtract 1
 Address of the storage operand =888+contents of register 1
=888+48
=936

srizanaryal.blogspot.com 29
 C(R3) =C(R3) -contents of memory location936
=10-1
=9
ST 3,892(0, 1)
 Store temp
 Address of the storage operand =892+C(R1)
=892+48
=940
 Content of memory location 940 =contents of regis ter 3
=9
BC 2, 2(0,1)
 Branch if result is positive.

 2 denotes a condition code


 Address of the storage operand =2+C(B1)
=2+48
=50

Assembly language
Definition
Assembly language is a low level programming language that allows and uses to write
programs using mnemonics (symbols)

srizanaryal.blogspot.com 30
Advantages
1. It is mnemonic
2. Reading is easier
3. Addresses are symbolic
4. Introduction of data to program is easier
5. It can be easily modified than machine language programs.

Disadvantages
1. An assembly language is required to translate source program into object program
2. It is machine dependent.
3. Lack of portability of programs between computers of different makes.

Pseudo opcodes
Pseudo opcode is an assembly language instruction that specifies an operation of the
assembler.

USING
Using is a pseudo opcode that indicates to the assemble which General Purpose
Register to use as a base register and what value it contained at execution time
Syntax
USING <content of base register><GPR to be used as base register>
Ex:
USING * 5

START:
Start is a pseudo opcode that tells the assembler where the beginning of the program
is and allows the user to give a name to the program
Ex:
START sum
Or
sum START

END:
End is a pseudo opcode that tells the assembler that the last statement of the program
has been reached
Ex:
END

EQU:
EQU is the pseudo opcode which allows the program to define variables
Ex:
BASE EQU 15

srizanaryal.blogspot.com 31
DC (data constant)/(define constant):
DC is a declarative pseudo opcode used to create a memory area to hold a constant
value
Syntax:
<Label>DC „constants‟
Ex:
FOUR DC „F4‟
DS (data storage)
DS is the pseudo opcode that reserves storage for the data and gives them a name
Syntax

<Label> DS „size‟
Ex:
FOUR A DS 1F

DROP:
Drop is a pseudo opcode which indicates an unavailable base register and its contents
Syntax:
DROP<BS register number>
Ex:
DROP 15
LTORG:
LTORG is a pseudo opcode which tells the assembler to place the encountered literals
at an earlier location

Machine opcodes
BALR:
 BALR is a branch and link instruction. It is an instruction to the computer to load a
register with the next address and branch to the address specified in the second field.

 BALR loads the base register and it is not an executable statement it is an RR type
 instruction whose length is 2 bytes.
Ex: BALR 15,0

BR:
BR is a machine opcode indicating branch to the location whose address is in general
register
Ex: BR 14

BCT:
BCT indicates branch and count it is a RX type instruction whose size is 4
bytes. Ex: BCT 3, loop
Decrements register 3 by 1 if result is not 0 branch back to loo

srizanaryal.blogspot.com 32

You might also like