0% found this document useful (0 votes)
52 views55 pages

SP UNIT I-Module II

The document provides information about the machine structure of IBM System/360 and System/370 computers. It discusses the general CPU components including the instruction interpreter, location counter, instruction register, working registers, and general purpose registers. It also describes the memory structure, addressing techniques using base registers, instruction formats, and different data types including fixed-point, floating-point, packed decimal, and unpacked decimal numbers.

Uploaded by

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

SP UNIT I-Module II

The document provides information about the machine structure of IBM System/360 and System/370 computers. It discusses the general CPU components including the instruction interpreter, location counter, instruction register, working registers, and general purpose registers. It also describes the memory structure, addressing techniques using base registers, instruction formats, and different data types including fixed-point, floating-point, packed decimal, and unpacked decimal numbers.

Uploaded by

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

Unit - I

Module I
Background: Machine Structure, Evolution of the
Components of a Programming System, Assembler,
Loaders, Macros, Compliers, Formal Systems.
Module II
Machine Structure, Machine Language and assembly
language: General Machine Structure,Machine
Language, Assembly Language
Module 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
(Hardware or software that is compatible with earlier versions of the product). 
 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 were created and enhanced the
performance of 370. 
 System/370 had an execution time 3 to 5 times faster than system/360 model.
General machine structure
 The CPU consists of

 An instruction interpreter

 A location counter

 An instruction register

 Various working registers and

 General purpose registers


General machine structure
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.
location counter
It is also known as program counter or instruction counter which holds the
location of the current instructions being executed
instruction register
It holds the copy of current instructions to execute.
Working registers
These are registers which are meant for internal usage by the interpreter
during the execution of instruction. Also called “SCRATCH PADS‟ (a plurality
of multibit storage locations).
General purpose register
General purpose registers are used by the programmer as storage
locations and for special functions.
General machine structure
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 ,i.e. it stores the data being transferred to and from the
 

immediate access storage.


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

With a neat diagram describe the General Machine Structure for IBM
360/370.
Instruction Format
 The basic instruction format (of small computer SC-6521)is

Operation code Register number Memory location


(op) (reg) (addr)

 Ex: ADD 2,176


 ADD-operation code, 2- register, 176- memory location address
 And instruction means add the content of register 2 with data stored in memory
location 176 and store the result in register 2
 Machine structure of IBM 360
I. 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. Nibble 4bits
 Bits are grouped into words, characters or bytes. Byte 8bits 1byte
Half word 16bits 2bytes

Word 32bits 4bytes

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
Address=value of offset + contents of a base register + contents of an index register
II Registers
General purpose registers
 IBM 360 machine has 16 general purpose registers denoted by R0 to R15 and 4 floating
point registers consisting of 64bit each and a 64bit Program Status Word(PSW) that
  contains the value of location counter, protection information and interrupt status.
 The general purpose register may be used for
 various arithmetic and logical operations (then these registers acts as scratch pads)
 base-registers(then they aid in the formation of the address). 

Name of the register


number size

General purpose registers 16 32bits each

Floating point registers 4 64bits each

Program status word 1 64bits


Registers
For example
A 1,901(2, 15) where
A- add opcode
  1- Registers number 
901- offset (ie. location of no is 901)
2 - Index register
15 - Base register
Location of value = offset(901) +content of reg 2 (index reg) + content of reg 15(base reg)

The total number of bits for an add instruction would be 32

 Base address- is an address serving as a reference point ("base") for other addresses.


 Offset- offset usually denotes the number of address locations added to a base address in order to get to a
specific absolute address
 Index register-a processor register or assigned memory location used for modifying operand addresses during the
run of a program. 
Registers contd…
 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

Without base register With base register

 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.
 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. 
III. DATA

 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
Short form fixed point numbers & Long form fixed point numbers

 Fixed point numbers may be stored in either a half word or a full word.
 Used to represent integer numbers.
 First bit for sign and remaining bytes to represent actual number in binary form.
 Decimal formats ae useful fin data processing

 For example +541 can be represented as:0000 0010 0001 1101


S(+) binary equivalent
0 000 0010 0001 1101
Packed decimal numbers

 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(021) sign bit(-)


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/inter
nibble 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.
Example
 How +21544 is stored
Short form floating point number
& Long form floating point numbers

 Short form floating point numbers consists of 32bits (4 bytes)


 1st bit is a sign bit. 0->+ve, 1->-ve
 7bits represent exponent and 24bits represents fraction
 Long form floating point numbers consists of 64bits (8 bytes)
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

0100 0001
1byte
DATA FORMATS OF IBM 360
IV 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
 Arithmetic instructions
 Control or transfer instructions
 Special interrupt instruction
 The different types of operands
 Register operands
 Storage operands
 Immediate operands
Operands
 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.
Instruction Formats

 The different instruction formats are

 RR format
 RX format
 RS format
 SI format
 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( content of general register 4 to be added to


content of general register 3 and store it in reg 3.)
RX instruction
 RX instruction denotes a register and indexed storage operand. 
 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
 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)
 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
 Content of 1016 is added to content of register 3
RS instructions
 RS instruction denotes register and storage operand. 
 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)
4 bytes
 
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
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: MVI I2, 4(5)

 Move the byte (0100 0000) to location 1004


 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 79 (32, 5), 300(5)

 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
2. Fixed point arithmetic
3. Logical instructions
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 & Disadvantages of machine language

 Advantages
 Instructions of a machine language program are immediately executed, they
require no compilation or translation. 
 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: 
 The 10 numbers are contiguous full words beginning at absolute location 952. 
 The program is in core memory starting at absolute location 48. 
 The number 49 is a full word at absolute location 948.  Figure shows the core memory
structure
 Register 1 contains a 48.

 This program can be written in different ways


 Long way, no looping. 
 Address modification using instruction as data. 
 Address modification using index registers. 
 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.
Long way, no looping
 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) -stores content register 2 to storage operand


 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.
 The three operations are repeated for the remaining 9 data by just changing the offset.
Long way, no looping

 Advantages 
 Implementation is easy. 
 Disadvantages
  Instructions are repeated for all the data items. 
 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.(offset limitation)
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 by adding 4 to them.
 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 4th byte is treated as data
and is incremented by 4. 
L+4=904+4=908
Address modification using instructions as data

 Program is as follows:
Address modification using instructions as data
 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(12 bit of offset can support displacement upto 4095)
3.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, by
adding 4 to the contents of the index register during each pass. 
 Register 4 is used as an index register.
 SR 4,4 
 Clear register 4 by subtracting the contents of register 4 from register 4. 
 The contents of register 4=0
 L2,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.
 ST 2,904(4, 1) 
 Replace data element
 Address of the storage operand register1 =904+contents of index register 4+contents of base
=904+0+48= 952
 Contents of memory location 952= =contents of register2= Data1+49
Address modification using index registers

 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 location 944
=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 
 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
  
Address modification using index registers
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(B1)=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
 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 register 3=9
 BC 2, 2(0,1)
 Branch if result is positive.
 2 denotes a condition code
Looping
Assembly language
 Definition 
 Assembly language is a low level programming language that allows and uses to write
programs using mnemonics (symbols) .
 Advantages 
 It is mnemonic.
 Reading is easier. 
 Addresses are symbolic. 
 Introduction of data to program is easier.
  It can be easily modified into machine language programs. 
 Disadvantages
  An assembly language program(source program) is required to translate into object
program. 
 It is machine dependent. 
 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 assembler which General Purpose Register to use as a base
register and what its content will be. 
 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 
Pseudo opcodes
 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.
 It is used for very long programs
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 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 loop
Differences between USING & BALR

USING BALR
 A pseudo op that indicates to the  It is an instruction to the computer to load
assembler which general register a register with the next address and
branch to the address specified in the
to use as a base and what its second field. 
content will be. 
 Loads the base register.
 Only provides the information to
the assembler but does not load
the register.  Ex: : BALR 15,0
 Ex: USING BEGIN 15  Loads base register 15 with next
address, and since second operand is
 Specifies that 15 is the base 0,the execution proceeds with next
register instruction
Sample program
END OF UNIT I
THANK YOU

You might also like