Professional Documents
Culture Documents
PROGRAMMING
PART - 1 STUDENT NOTE BOOK
ASSEMBLY LANGUAGE
PROGRAMMING
PART - 2 STUDENT NOTE BOOK
STUDENT NOTEBOOK
Contents
Course Description Agenda ..
Units Unit 1. Computer System Concepts.1-1 1.1 Computer System Concepts 1-1 Objectives. 1-1 Computer System Concepts. .1-2 Assembly Language Programming1-4 Organization1-5 Assembling your Assembler Language Program & Link-Editing. 1-6 Language Compatibility..1-7 Relati onship of assembler to Operating System.1-8 Operating System1-9 Relationship of Assembler and Loader 1-10 Typical Output Process1-11 Processing Modes1-12 Relationship of Program Components.1-13 BITS and BYTES 1-15 Memory Location and Address.. 1-16 Contents of BYTES.1-17 Machine Language Instruction format1-18 Program Location Counter..1-19 Registers .1-20 Representation of data in Memory..1-21 Character Codes..1-22 Binary and Hexadecimal Integers1-23 Number System ..1-24
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Position Notation Decimal Number System1-25 Binary Numbering.. 1-28 Decimal Numbering 1-29 Conversion of Decimal to Binary1-30 Second Method for converting numbers of Binary.1-32 Number Representation..1-33 Binary Integers1-34 32-Bit Signed Binary Integers.1-35 Signed Binary Integer Arithmetic Overflow & carries part 11-36 Signed Binary Integer Arithmetic Overflow & carries part2.1-37 Unsigned Binary Integer Arithmetic ..1-38 Decimal Integers.1-39 Floating Point Numbers1-40 Conversion of Positive integer from one base to another base1-41
Unit 2. Fundamentals of Assembly Language.2-1 2.1 Fundamentals of Assembly Language....2-1 Objectives2-1 Statement Format2-2 Formats for Instructions and Directive2-4 Valid Symbols.2-5 Invalid Symbols..2-6 Statement Format Variations...2-7 Source Module Requirement-1....2-9 Source Module Requirement-2...2-10 Source Module Requirement-32-11 Executable vs. Non-Executable Statements.2-12 Object Module..2-13 Input and Output Operations2-14 OS I/O Macros.2-15 Sample Program Using Files2-16 DOS I/O Macros 2-18 Sample Program for DOS.. 2-20 ANSI Carriage-Control Characters... 2-21
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Assembly Listings.2-22 Unit 3. Instructions and Address.3-1 3.1 Instructions and Address...3-1 Objectives......3-1 Addresses...3-2 Schematic Representation of Memory...3-3 Schematic Diagram of the 16 General Register.....3-4 Registers..3-5 Base Displacement Address...3-6 Instructions......3-7 Memory Location Counter (MLC)..3-8 Machine Language Instruction Format...3-9 Assembly Language Operand Formats.....3-10 Examples for each Formats...3-11 RS Format3-12 SS1 Format3-13 Implicit Length.3-14 The BALR Using Sequence..3-15 Mnemonic Opcodes ...3-16 Unit 4. Basic Operations: Looping and Arrays.4-1 4.1 Basic Operations: Looping and Arrays.4-1 Objectives4-1 Basic Operations, Looping and Arrays..4-2 Types of Constants for DC Directive.4-3 The DS Directive4-4 Subdivisions4-5 Equivalence Constants (EQU)4-6 Relocatable and Absolute Constants..4-7 Control Sections.4-8 Source Module4-9 Sample Program to Print the sum of two Binary integers.4-10 Program to print the sum of two unsigned Decimal Integer.4-12 The LA Instructions..4-15
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
The BXH and BXLE Instructions.4-16 Printing Nonnegative Integers..4-17 Allocating Memory Areas.4-18 Conversion from Binary to Character representation ..4-19 Reading Nonnegative Integer Input Data.4-20 Allocating memory Areas.4-21 Conversion from Character form to Binary..4-22 Unit 5. Integer Arithmetic5-1 5-1 Integer Arithmetic 5-1 Twos Compliment Arithmetic ..5-2 Arithmetic Instruction ..5-3 Subtraction . 5-4 Multiplication ... .5-5 Division. .5-6 Branching Instructions...5-7 Comparison .5-8 Complement Instructions ...5-9 Byte Operations....5-19 Moving Bytes5-21 Comparison of Bytes...5-22 Shifting Bits..5-26 Logical Shifts ...5-28 Altering Bits..5-29 Boolean Instructions on IBM 360 and 370-Systems 5-31 File Status Informations . ..5-32 Testing Bits ..5-33 The BC Instruction .. 5-35 Changing Sign and Generating Absolute Values .5-38 Unit 6. Constants and Data Areas...6-1 6.1 Constants and Data Areas..6-1 Objectives6-1 Constants.6-2 Relocatable and Absolute Constants...6-3
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Run-Time Constants6-4 Types of Constants..6-5 Defined Constants (DC)..6-6 DC Operand Subfield Format..6-7 Value Based Constants.6-8 Literals.6-9 Self Defining Terms...6-10 Assembly Time Constants..6-11 Memory Location Symbol (*) ..6-12 Equivalence Constants.....6-13 Value to Tedious to Compute by hand.6-14 Value can Change if Program is changed6-15 Value used Symbolically ..6-16 Symbolic Register Addresses & Symbolic Displacements...6-17 Symbolic register Addresses.6-18 Invalid use of EQU6-19 Relocatable vs. Absolute Constants..6-20 Data Areas 6-21 Boundary Alignment and Length of an Area6-22 Boundary alignment .6-23 Forced and Natural alignment...6-24
Unit 7. Byte and String Manipulations 7.1 Byte and String Manipulations7.1 Character Constants .7-3 Copying Bytes ..7-5 Copying Bytes to and from Registers .7-6 Copying Bytes from one area of Memory to another .7-8 Comparing Bytes .7-9 Comparing Bytes when one of the Strings is in a register7-10 Comparing Bytes when both Strings are in Memory locations.. 711
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Determining the result of a String comparison7-12 String processing examples ..7-13 Destructive Overlap ..7-15 Non Destructive Overlap ..7-17 Substring Operations 7-22 String-Editing Delete Procedure ..7-24 The Execute Instruction 7-26 CLCL and MVCL Instructions .7-27 CLCL Instruction .. ..7-28 CLCL Loop ..7-30 MVCL ..7-31 TR and TRT Instructions .7-33 General Descriptions 7-34 Unit 8. Bit Manipulations.8-1 8.1 Bit manipulations... . 8-1 Objectives. 8-1 Bit Manipulations. 8-2 Shifting Bits. 8-3 Arithmetic Shift Instruction. 8-4 Arithmetic Shifts. .8-5 Logical Shifts. ..8-7 Altering Bits .8-9 Use of Bits as Indicators.. 8-10 Bit Variations8-11 Boolean Operations..8-12 Boolean OR Operation 8-13 Boolean AND Operation..8-14 The Boolean Exclusive OR Operation..8-15 Testing Bits..8-16 Test Under Mask..8-17 Test and Set..8-18 Condition Code.8-19 Condition Code Value..8-20 BC and BCR Mask Field..8-21
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Condition Code settings for Non privileged Instructions.8-22 Integer Operations.8-23 Byte Operations.....8-24 Bit Operations8-25 Decimal...8-26 Floating Point..8-27 Miscellaneous..8-28 Non Privileged Instructions that do not set Condition Code.8-29 Bit Manipulation Examples...8-30 Status Byte.8-31 Definitions for a file Status Byte8-32 Use of a Status World8-33 Testing or Resetting Bit N.8-34 Setting or Inverting Bit N..8-35 Conversion of HEX digits to EBCDIC.8-36 Translate from Decimal to Binary.8-37 Convert HEX digits to EBCDIC Codes8-38 Translating a Non-Negative Integer from EBCDIC to Binary8-39 Unit 9. Macros9-1 9.1 Macros9-1 Objectives9-1 Macro Definition.9-2 Macro Prototype Statement..9-3 Macro - Header Statement .9-4 A Sample Macro..9-5 A Macros Definition..9-6 Example 19-7 Use of Control directives.9-8 Return Macro Definitions9-9 MEXIT Directive..9-10 VSAM Processing Assembler9-11 Creating ACBs and RPLs ..9-12 ACB MACRF Parameter..9-13 RPL OPTCD Parameter ..9-14
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Assembler Error Handling9-15 Unit 10. Sequential Organization10-1 10.1 Sequential Organization10-1 Objectives.10-1 Sequential Organization ..10-2 The System Input and Output data set.10-3 SYSIPT and SYSLST in DOS System10-4 Processing fields in a Logical record...10-5 Processing variable Length Records.10-7 Move Mode..10-8 Locate Mode10-9 Printer Output..10-10 Title.10-11 Date and Time Macros10-12 Dormitory Room Master File..10-13 Transaction record Format..10-14
Copyright MCPL. Course Materials may not be reproduced in whole, or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
11-1
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
13-1
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Unit 20.
Pseudo OPS
Pseudo OPS...20-1 Objectives 20-1 Control Sections. 20-2 CSECT. 20-3 START.. .. 20-4 ORG.. .. 20-5 LTORG. 20-6 END.. . 20-7 DSECT . . 20-8 COM. 20-9
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL.
Course Material may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPUTER SYSTEM CONCEPTS Hardware Software Program Machine language Programming language Source module Instructions
Figure 1-1. Computer system concepts NOTES: Hardware refers to a computer systems electronic, electromagnetic, electromechanical components: in short, its physical equipment. and
Software consists of the computer programs, procedures, rules, and documentation used in the operation of a computer system.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Program or computer program means a sequence of actions and conditions written in such a way That they may either be processed directly by hardware or be translated into a form that may be processed directly by the hardware. A program that can be processed directly by the hardware is known as a machine language program. A program that can be translated into machine language is said to be written in a computer programming language. An assembly language program consists of the statement that processed by a program known as assembler. The statements are collectively called the source code, or source module. A significant position of an assembly language program consists of statements that represent the detailed operations- known as instructions- that the hardware is capable of executing. An instruction is a symbolic representation of a single machine language operation that will be executed by the hardware at run time. A directive is a request to assembler to perform a function other than translating instructions into machine language.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ASSEMBLY LANGUAGE PROGRAMMING Object module Assembly time Load time Run time
Figure 1-2. Assembly language programming. NOTES: The object module contains the numeric instructions and data formats that constitute the machine language representation of the source module statements. When the assembler is processing a programmers source module, it is the assembler program that is being executed by the hardware, not the programmers. The period of time during which this happens is known as assembly time. When a object module is being processed by the loader, it is the loader program that is being executed, not the programmers. This is known as load time. The period of time during which the programmers program is being executed by the program is known as run time.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ORGANIZATION
ETR CP U EXPANDE D STORAGE CP U CHANNEL SUBSYSTEM Serial channel paths
DYNAMIC SWITCH DYNAMIC SWITCH
MAIN STORAGE
CU
CU
CU
CU
CU
CU
Fig 1- 3: Logical structure of an ESA/390 system with two CPUs. NOTES: Logically a system consists of a main storage, one or more central processing units (CPUs), a channel subsystem and I/O devices. I/O devices are attached to the channel subsystem through control units. ETR is an external time reference. The maximum number of sub-channels is 65536.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SOURCE MODULE
OBJECT MODULE
MESSAGE S& LISTINGS Figure 1-4 Assembler language program and link-editing NOTES:
LINKAG E EDITOR
LOAD MODUL E
Your program becomes the source module that is input to the assembler. The assembler output is the object module. The Linkage editor processes the object module to give the load Module which is loaded into main storage.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LANGAUGE COMPATIBILITY
DOS/VSE ASSEMBLER
Migration from Assembler H V2 or DOS/VSE Assembler to High Level Assembler will require an analysis of existing assembler language programs to ensure that they do not contain Macro instructions with names that conflict with High Level Assembler symbolic operation codes, SET symbols and variable symbols that conflict High Level Assembler system variable symbols. HLA supports assembly of programs using Extended Architecture Instructions and ESA instructions. A generated object program using 370-XA/ESA/370 instructions can only be run on a 370-XA/ESA/370 mode processor.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MVS/ESA
MVS/XA VSE/ESA
Figure: 1-6 Relationship of assembler to operating system NOTES: The operating systems provide the Assembler with services for assembling a source module and running the assembled object module as a program.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OPERATING SYSTEM
OS Vs DOS In many IBM 360 and 370 computers, the operating system is known as OS; in others it is DOS.
Figure : 1-7 Operating system NOTES: In IBM 360 and 370, the master control program is known as the operating system. OS is essentially more complex and more versatile than dos.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Source Module
Object module
listing
Figure 1-8. Relationship of loader and assembler NOTES : Source module is input data processed by the assembler. The loader processes the object module one step further in order to prepare it for execution by the hardware.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Operating system 1. process that occur when a file is opened 2. processes that occur when a write operation is performed Figure 1-9. Typical output processes. NOTES :
Two mechanisms for communicating with operating system: (I) by means of job control language (jcl) statements and (2) by means of instructions. The principal functions of jcl statements are to identify the user and the users accounting parameters, to initiate and terminate jobs, to describe files and request certain activities related to files. Job is a unit of work such as assembling , loading, and running a program that is to be performed by the computer system. File is a set of related data that is treated as a unit and is identified by name. The process of reading data is known as input , that of writing data as output.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 1-10 Processing mode. NOTES : When a users program is being run, the hardware, or more precisely , the central processing unit is in what is known as problem mode; this means that only those instructions that can not be used to affect the system integrity are allowed to be executed When the operating system is being run, the central processing unit is said to be in supervisor mode, in which all the instructions of the computer can be executed. Since input and output instructions are among those that can be used to affect system integrity , they can be executed in supervisor mode and are therefore known as privileged instructions.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Main memory
I/o Devices
I/o Processor
I/o Processor
Secondary Memory
Figure 1-11. Relationship of program component. NOTES : Main memory contains the operating system and any other program that is being executed by the hardware. It contains data and control information required by the operating system and the programs that are being executed. The central processing unit (CPU) contains electronics required to interpret and execute machine language instructions, to control the transfer of data and programs into and out of main memory, and to detect the various errors as they arise.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The i/o (input/output) processors, called data channels in IBM systems , contain the electronics required to transmit data between main memory and input /output devices , and between main memory and secondary memory. Secondary, or auxiliary, memory serves as storage space for data and for programs when they are not been executed. Secondary memory commonly consists of magnetic tapes, disks, and drums. Input devices generate signals required for the transmission of the data into main memory from sources external the computer system. Output devices receive signals transmitted from main memory for use outside the computer system.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Bit number
0 1 2 3 4 5
k-2 k-1
K bits
In a unit of information consisting of k consecutive bits , the bits are usually numbered from 0 to k-1, starting at high order bit position.
Figure 1-12. Bits and bytes. NOTES : The fundamental unit of information in main memory is the binary digit ,or bit , which may be either a 0 or a 1. All data and programs are represented as sequences of bits. The term byte is used to denote a small number of consecutive bits. The term word is generally used to denote a some what a larger number of consecutive bits.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Byte address
0 1
2 3 4 5
N-2 N-1
N bytes In a one megabyte memory there are approximately one million byte locations N = 220 = 1,048,576.
Figure 1-13. Memory location and address. NOTES : A byte consists of 8 bits. A word consists of 32 bits. A half word consists of 16 bits (2 bytes) , and a double word consists of 64 bits (8 bytes) . Each byte in a main memory is said to occupy a location, or physical position, in memory, and each location is identified by a numeric name called its address.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Opcode field identifies the particular instruction to be executed by the CPU, e.g. ADD, SUBTRACT. Operand field identifies either the address of the data to be operated on by the instruction or the data itself.
Figure: 1-14. Machine language instruction format. NOTES : The CPU executes instructions that it obtains from main memory and, in doing so , frequently processes data that is also obtains from main memory. The instructions and data are represented in machine language. Machine language is numeric language. In many instructions, two items of data is represented in operand field, and some instructions three are represented. These are known as two operand or three operand instructions respectively.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The PC is part of the program status word (PSW) , which records various information about the instantaneous state of running program .
Figure 1-15. Program location counter. NOTES : The address in the PC is initially set by the operating system to refer to the first instruction in a program, but once program execution is under way, the CPU controls the address in the PC. When an instruction is obtained from memory, the CPU anticipates that the next instruction will be obtained from the next sequential location in memory.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
REGISTERS
Registers are special memory elements designed to provide faster access to data than is possible through main memory. Registers contribute substantially to the speed with which a program can be executed.
Figure 1-16 Registers NOTES : In addition to fetching instructions and data directly from main memory, the CPU and main memory often are interfaced to one- another through registers. Registers are specifically designed to be used by the CPU for various arithmetic and logical operations. Registers are more expensive than the main memory elements, there are far fewer registers than main memory locations in a computer system.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Data are represented as one or more sequences of bits. The bit sequences that are used generally depend on how the data to be processed by the CPU.
Fig 1-17. Representation of data in memory. NOTES : A different representation is used for numbers that participate in arithmetic processes than is used for numbers that participate in non-arithmetic processes. An example of a number used in an arithmetic process is the mathematical constant pi = 3.14159 An example of a number used in non-arithmetic process is a telephone number, such as 5551346. All data that are transmitted between computers main memory and external input or output devices are almost invariably transmitted in a form known as character data.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CHARACTER CODES ASCII American National Standard Code for Information Interchange EBCDIC Extended Binary-coded Decimal Interchange Code
Figure 1-18. Character codes. NOTES : ASCII is a 7-bit code, giving 128 possible character representation. EBCDIC is used in IBM devices and computer systems, as well as the computer systems.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
In the binary number system, only two digits are used in the representation of numbers: 0 and 1. In the hexadecimal system, there are sixteen digits, represented by the symbols 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. the first ten symbols have their usual meaning; the remaining six represent the values ten through fifteen when used as hexadecimal digits.
Figure 1-19. Binary and hexadecimal integers. NOTES : Calculations involving address are of critical importance in assembly language programming, and almost such calculations are based on binary systems. The range of integers that can be represented in computer systems is not infinite and attempts to generate an integer whose value is outside the allowable range usually produce erroneous Results.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NUMBER SYSTEM
Programming in assembler language requires a working knowledge of three different number systems: BINARY HEXADECIMAL DECIMAL
Not only will you be expected to count in all three number systems, but also to perform arithmetic in any of them, and to convert numbers represented in one form to another. In addition, because negative signed binary integers are represented internally in two's complement notation; you must be able to make the necessary transformations when examining the contents of binary fields.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 1-21 Numbering system NOTES: The decimal number system will be discussed first because it is more familiar. The decimal number system, which takes its name from the Greek dekas (group of 10), has 10 digits - 10 unique symbols or characters that can be used when representing a number. The digits are 0,1,2,3,4,5,6,7,8, and 9. Every number in the decimal system is comprised of one or more of these digits. The value that each digit contributes to the number depends on its position in that number. In this positional notation a particular digit has a value equal to that digit multiplied by the base of that number system raised to a power that reflects its relative position in the number. (Power of a number are the result of multiplying the base of the number system times itself that number of times) The 0,1, and 2 in the previous example are called exponents. An exponent of 1 always results in the number itself. Copyright MCPL. Unit 1.Computer System Concepts 1-24
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 1-22 Numbering system NOTES: Another term to learn at this point is what's called the expanded form in which a number is shown as the sum of the values contributed by each of its digits. The decimal number 743 in its expanded form would be : One last process to consider while was we are still working in the familiar decimal number system is the simple process of counting. In counting we advance through the range of symbols or digits in the system until the range is exhausted. We then carry 1 to the next, more significant, position and start through the range again. In the Copyright MCPL. Unit 1.Computer System Concepts 1-25
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
decimal system, we count from 0-9; once 9 is reached, we carry 1 to the tens positions and begin over with 0 in the units position. This process is the same regardless of the number system in which we are counting.
Figure: 1-23 Numbering system NOTES: Because of its importance in modern computer systems, a programmer should acquire a working knowledge and understanding of the binary number system. As in the decimal system, the value of a particular digit in a binary number is a reflection the position of that digit in the number. Binary means base 2.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BINARY NUMBERING
Figure 1-24 Binary number NOTES: Thus the number 101101 in the binary number system is equivalent to (represents the same value as) the decimal number 45. Whatever we have done is to use the expanded form of binary to convert the binary number to its decimal equivalent. In fact, the digit equivalent of a number to its decimal equivalent. In fact, the decimal equivalent of a number in any base can be obtained by multiplying each digit by its positional value and summing the results. Try converting the following to their decimal representation.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DECIMAL NUMBERING
Subscripts indicate the base of a number, with no subscript indicating a decimal number.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 1-26 Conversion of decimal numbers to binary NOTES: There are two ways to convert a decimal number to a binary number. The first way is the multiple-division method. The number to be converted is divided repeatedly by the value of the base of the number system to which the conversion is being made. The division operation is repeated on the quotient until the quotient finally reaches 0. The remainder from the first division operation is used as the digit in the rightmost (leastsignificant) position in the resultant binary number; the remainder from the second Copyright MCPL. Unit 1.Computer System Concepts 1-29
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
division operation becomes the next digit, and so on, until the evaluation is complete. For example, converting the decimal number 45 to binary takes the following series of division operations:
Thus 45 and 1011012 are equivalent. Convert the following decimal values to binary:
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
A second method for converting decimal numbers to binary utilizes a table of the powers of 2.
Figure 1-28 Second method of conversition NOTES: Copyright MCPL. Unit 1.Computer System Concepts 1-31
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NUMBER REPRESENTATION
Binary integers Signed binary integers Unsigned binary integers Decimal integers Floating point numbers Conversion examples
Figure:1-29 Number representation NOTES:
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BINARY INTEGERS
+ 26 Invert Add 1 - 26
0000 1111
0000 1111
0001 1110
1111
1111
1110
0110
Figure 1-30 Binary system NOTES : Positive binary integers have a zero in sign bit position. Negative binary integers have a one in sign bit program and are denoted in twos compliment form.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 1-31. 32-bit signed binary integers NOTES : The signed binary integer is a weighted code, negative numbers are represented in twos complimented form.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Ex : 3 + 35 = -57 = -----22 = ----Ex : 5 -57 -35 -----92 ----= = = 1100 1101 -----1010 ------
Ex :4
Ex : 6 0111 1101 -----0100 ------57 -92 -----149 ----= = = 1100 1010 -----* 0110 -----1011 0100 -----1011 ------
Figure 1-32. Signed Binary Integer Arithmetic Overflow and carries NOTES :
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Ex 1&3 2 &5 4 6
Figure 1-33 Signed Binary Integer Arithmetic Overflow and carries NOTES :
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 1-34 Unsigned Binary Integer Arithmetic. NOTES : A carry out of the left most bit position may or may not imply an overflow, depending on the application.
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Zoned Form F1 F2 C3 or F1 F2 F3 F4 F3 F2 D1 D7
Figure 1-35 Decimal Integers NOTES : The decimal digits are in BCD with the values 0-9 encoded as 0000-1001. The sign is represented as 1100 (C Hex) for plus and 1101 (D Hex) for minus. Copyright MCPL. Unit 1.Computer System Concepts 1-38
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
31
Extended Floating-Point Number S 0 S 64 High-order Part High-order Leftmost 14 digits of characteristic 28-digit Fraction 1 8 63 Lower-order Part Low-order characteristic Rightmost 14 digits of 28-digit Fraction 72 127
Figure:1-36 Floating point number N0TES: Copyright MCPL. Unit 1.Computer System Concepts 1-39
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
A floating-point number has two signs: One for the fraction and one for the exponent. The fraction sign, which is also the sign of the entire number, is the leftmost bit of each format (0 for plus, 1 for minus). The exponent sign is obtained by expressing the exponent in excess-64 notation that is, the exponent is added as a signed number to 64. The resulting number is called the characteristic.
The method of converting a positive integer from its representation in one base to its representation in another depends on each number system the competitions are performed in . Conversion from base 10 to base 2 18 = 10010 Conversion from base 16 to base 10 12 = 18 Conversion from base 10 to base 16 18 = 12
Figure 1-37 Conversion of positive integers from one base to another base NOTES :
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL.
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OBJECTIVES: STATEMENT FORMATS STATEMENT FORMAT VARIATIONS SOURCE MODULE REQUIREMENTS INPUT AND OUTPUT OPERATIONS ASSEMBLY LISTINGS
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
STATEMENT FORMAT
General format for all statement The format used for comment statements The format used for instructions and directives.
Figure 2-1. Statement formats NOTES : The general format is designed to accommodate the constraints imposed by an 80 column input line.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
STATEMENT FORMATS
Comment statement format 1 Comment filed Comment Indicator
71 72 73
Identification
80
Continuation
Format for instructions and directives. 1 9 15 39 72 80 name opcode operand comment identification Continuation
Figure 2-2 Statement format NOTES: The first column of a comment statement begins with an asterisk (*); continuation column 72 contains any nonblank character for continuation onto next line. Each continuation line begins in position 16. Name field. When the first character in main field is not blank, the name field must consist of from one to eight characters followed by a blank. Opcode field. The opcode field must contain availed assembly language code of from one to five alphabetic characters that identifies one of the instructions of directives that exist in the language. Operand field. The format of the operand field depends on whether the opcode field designates an instruction or a directive, and it also depends on which instructions or directive is specified.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
name
opcode
15
operand
39
comment
72
identification
80
Continuation
Figure 2-3. Formats for instructions and directives NOTES: Continuation field. The statement may be extended over two or more lines by means of the continuation field. If the continuation field contains any none blank character, then following line will be assumed to be a continuation of the line whose continuation field is non blank. Each continuation line must be in position sixteen called the continuing position. Identification field. Its purpose is twofold: (1.) to identify the source module in which the statement appears and (2) to record the sequential position of the statement within the source module.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
VALID SYMBOLS
Example of valid symbols
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
INVALID SYMBOLS
Example of invalid symbols:
first character not a letter parentheses not among the allowable characters blank period to many characters : maxmum 8
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 2-6. Statement format variations NOTES: The field positions for the statement format are said to be in the standard fixed format of the IBM 360 and 370 assembly language.
Other characteristics of standard fixed format include the following: Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Any field that is omitted must be blank. All none blank fields must be left justified within the field boundaries and be field with trailing blanks. Positions 9,15 and 39 must be blank. Information of the operand or / and comment fields of one line of a statement may be continued on the following line, provided that the continuation field contains a nonblank character.
Free format permits longer operands than can fit in the fixed position 16 through 38; alternately, it permits comments to be started before position 14. It permits one to indent the opcode and operand fields. In both standards fixed format or standard free format, the positions of the continuation and identification fields remain fixed in positions 72 and 73-80,respectively; and the beginning, ending, and continuing positions remain fixed in positions 1,71,and 16, respectively.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Name field Modname This symbol Used as name Of the source module
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 - 9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The last executable statement of source module should be NAME FIELD Exit name Any valid symbol OPCODE L LM BR OPERAND 13, SAVE+4 14, 12, 12 (13) 14
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The last executable statement of source module should be NAME FIELD Save This symbol must be SAVE OPCODE DS END OPERAND 18F
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 2-10. Executable vs. non-executable statements NOTES: Instructions are translated into machine language by the assembler and executed at run time by the hardware.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OBJECT MODULE
If the object module size is greater than 4096 bytes it may not run properly.
Figure 2-11. Object module size NOTES: All executable statements and those non-executable statement that defined constants and data areas, are assembled into object module that can be loaded into main memory and executed at run time.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 2-12. Input output operations NOTES: The OPEN, CLOSE, GET and PUT macros are directives that cause the assembler to generate the instructions needed to request that the corresponding operations to be performed by the operating system. The areas of memory to be used for the input and output data must be reserved by the defined storage (DS) and define constants (dc) directives. There must be DCB macro associated with each file that is used in a program, the DCB macro informs the operating systems how you intend to use the file.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OS I/O MACROS
Input file Symbol 1 DCB DSORG =-----, MACRF = (---), DDNAME = SYSIN, EODAD = Symbol2, RECFM =-----, LRECL = ---, BLKSIZE = --X X
Printer file Symbol 1 DCB DSORG = ---, MACRF = (---), DDNAME = SYSPRINT, RECFM=---, LRECL = ---, BLKSIZE = -----X X
Figure: 2-13 OS I/O macros NOTES: The input file parameters DSORG = PS for a sequential file, MACRF = (GM) for a GET macro. DDNAME = SYSIN for the standard system input file. The parameter EODAD names the symbol of the statement to which control is to be transferred when the end-offile condition is reached. The RECFM parameter describes the type of records, which is either FB or VB. LRECL is for logical record length and BLKSIZE parameter stands for block size for storing records. The printer file parameter has MACRF = (PM) for put macro. RECFM = FBA which says that records are of fixed length and ANSI carriage control character will be used for printer line spacing.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
10LOOP
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
X X
Figure: 2-14 DOS I/O mode NOTES: DTF stands for define the file. The input file parameter DEADDR is coded as DEVADDR=SYSIPT for reading from the standard system input device. The IOAREA1= symbol parameter identifies the area into which each input record will be read. WORKA=YES indicates that after the input data has been read, it will be available to your program in the work area whose name is specified in the GET macro. The EOFADDR = parameter names the symbol of the statement to which control is to be passed on reaching the end-of-file condition. For printer file DEVADDR=SYSLST for writing to the standard listing device. IOAREA1=______ identifies the area from which each output record will be written. WORKA = yes means that the output line will be created in the work area whose name is specified in the PUT macro. CTICHR=ASA means than an ANSI carriage-control character will be used for printer line-spacing. The first byte of every record is a ANSI control character and the remaining 132 bytes contain the character to be printed.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -17 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Carriage control character and their functions are function single spacing double spacing Triple spacing skip to new page suppress spacing
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -18 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
IOLOOP
FINISH EXIT INDTF OUTDTF INAREA INBUF OUTAREA OUTCARR OUTLINE OUTBUF SAVE
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -19 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 2-15 ANSI carriage-control. NOTES: These characters are in the standard character set of the computer, but when they are in the first position of the print line they are not printed; instead they cause the printer to adjust the paper position before printing the line.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -20 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ASSEMBLY LISTINGS
The appearance of the assembly listing can be enhanced by using the following simple assembly language directives: EJECT starts a new page on the listing TITLE puts a title line at the beginning of each page SPACE inserts one or more blank lines on a page PRINT NOGEN, NODATA limits the amount of detail printed
Figure 2-16 Assembly listing. NOTES: The assembler produces a listing of your program that shows the machine language together with your source language statements and indicates what (if any) errors have been detected during the assembly process. The listing also includes an index of the name field symbols defined in the source module. The index is known as the cross-reference list (XREF). It is very useful when debugging and modifying programs. It identifies the statement in which each symbol is defined and the statement in which each is used. The cross-reference list also gives the value of each symbol and the length of the instruction or data field that the symbol is associated with.
Copyright MCPL. Unit2.Fundamentals of Assembly Language Page 2 -21 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ADDRESSES
Figure 3-1 Addresses NOTES: Each byte in the memory is referred to by its address. A memory address is an unsigned integer in the range 0 through 2 N-1 where 2n is the total number of bytes available in memory, , i.e. , the memorys capacity. Memory addresses are written in hexadecimal notation.
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
0 4 8 C last byte
FFFFFC
Figure 3-2. Representation of memory NOTES: A full word is any four consecutive bytes in which the address of the first byte is a number exactly divisible by 4. In a half word, the address of the first byte is exactly divisible by 2. In a double word, the address of the first byte is exactly divisible by 8. The first byte of the full word is said to be at the full word boundary. Half word and double word boundaries are at the beginning byte of each half and double word, respectively.
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
REGISTERS 16 GPRS Each 32 bit Numbered as 0 to 15 Base-displacement form of address used for XA / ESA
Figure: 3-4 Registers NOTES: Using the base-displacement form of addressing 16 bits are used to represent a 24 bit address.
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
B = Base register address (4 bits) D = Displacement (12 bits) M = Contents of base register + Displacement M = Base address displacement = Effective address
Figure-3-5 Base displacement register NOTES: The 16 bits that are used to represent a memory address do not represent a single integer; they represent two integers, each with a different purpose. One of the integers is 4 bits long and designates the address of a register known as the base register. The other integer is 12 bits long and represents an adjustment factor known as the displacement. This 16-bit representation of a memory address is known as the base-displacement form of that address. At run time, base displacement form of an address is translated by the central processing unit (CPU) into a 24-bit memory address. M is known as the effective address generated from the base-displacement address.
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
INSTRUCTIONS
Each machine language instruction consists of a certain number of bytes. The number of bytes comprising an instruction is known as the instructions length. In many computers, length of all instructions is same. In some computers the length of an instruction depends on type of instruction it is. We speak of a variable-length instruction set in latter case and fixed-length instruction set in former. The IBM systems 360 and 370 have a variable-length instruction set. The use of a variable-length instruction set, though apparently more complex than use of a fixed-length set, has one significant advantage, . The number of bytes required for any instruction is just sufficient to provide only the information required in that instruction. This results in an overall saving of memory space in a program. In fixed-length sets, the length used for all instructions is the length needed by the instructions that contain the most information. This can result in unusable memory space. Figure: 3-6 Instructions NOTES:
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 3-7. Memory location counter NOTES: The assembler maintains a list of all symbols defined in an assembly language program, together with the address values it has assigned to them. This list is known as the assemblers symbol table.
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OPCODE R1 X2 0 8 12
RS 0 SI
OPCODE R1 8 OPCODE 0
SS2
OPCODE L1 L2 B1 D1 D2 0 8 12 16 20
48
Figure: 3-8 Machine language instruction format NOTES: The opcode is 1 byte and operand can be 1, 3 or 5 bytes in length. There are seven different instruction formats namely RR, RX, RS, SI, S, SS and SS2. The S format is available on IBM 370 machines only.
Copyright MCPL. Unit3.Instructions and Address Page 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Implicit RS SI S SS1 Explicit Implicit Explicit Implicit Explicit Implicit Explicit Implicit Mixed
SS2
Figure: 3-9 Operand format NOTES: 1. When the index field X2 is omitted, X2 =0. 2. I2 field is one byte long and is used for storing immediate data. 3. L, L1, L2 are the length fields and are represented by a number that is one less than that used in assembly language.
Copyright MCPL. Unit3.Instructions and Address Page 3 - 10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 3-10 Format examples NOTES: X2 is omitted has a value of zero and is denoted as OP R1, D2 (, B2). A comma denotes the absence of X2.
Copyright MCPL. Unit3.Instructions and Address Page 3 - 11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
RS FORMAT
OP R1 D3 R2 B3 OP R1, R2, D3 (B3)
8A 004
10
SRA
7, 4 (10)
Eg 4:
SI Format OP I2 B1 D1 OP D1 (B1), I 2
95 020
30
CLI
32 (12), X 30
Figure: 3-11 RS format NOTES: Considering the RS format R1, R2, D3 (B3), the second operand, R2, is not written in assembly language and not used in machine language. In the above Eg 3 R1 denotes register to be shifted and D3 (B3) specifies number of positions to be shifted.
Copyright MCPL. Unit3.Instructions and Address Page 3 - 12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SS1
FORMAT
Machine Language OP D2 L B1 D1 B2 Assembly Language OP D1 (L, B1), D2 (B2)
D5 0C8
04
040
Eg : 6 SS2 Format OP D2 0 8 F8 8 F8 0C8 L1 12 4 L2 B1 D1 32 040 B2 36 C ZAP B(8), A(4) OP D1(L1, B1), D2 (L2,B2)
16 20 C
Figure: 3-12 SS1 format NOTES: SS1 type instruction is used to compare bytes at one memory location with those at another. SS2 type instruction is used to compare L1 number of bytes starting from memory address designated by B1, D1 with L2 number of bytes starting at B2, D2.
Copyright MCPL. Unit3.Instructions and Address Page 3 - 13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
IMPLICIT LENGTH
A 3, Z ? D2 + operand A, R = memory address of Z base address implied displacement
Figure: 3-13 Implicit Length NOTES: The USING directive is used at assembly time and must occur before any statement in the source module that contains an operand for which an implied displacement must be calculated. If memory address of Z = 80 A & Base address is 6, then implied displacement = 80A 6 = 804.
Copyright MCPL. Unit3.Instructions and Address Page 3 - 14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Implied Displacement
Copyright MCPL. Unit3.Instructions and Address Page 3 - 15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MNEMONIC OPCODES
The letters used in the opcodes are designed to help you remember each opcode and its purpose. For this reason the opcode are said to be mnemonic, from Greek words meaning mindful and remember
Copyright MCPL. Unit3.Instructions and Address Page 3 - 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Define constant (DC) directive Name field Any symbol Or blank DC operand sub-field components Optional Duplicator Constant Required Figure: 4 1 Basic operations NOTES: The DC directive is used to denote constants in various forms. The duplicator denotes the number of consecutive representations of the constant. The modifier can be a length scale or exponent modifier. DC FL1 50 This generates a 1-byte binary integer representation of 50. Type Modifier Opcode DC Operand One or more sub-fields, separated by comma
Eg:
DC
FS10 8
10
= 3072
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 4-2 DC directives NOTES: Each character is converted to its 8-bit EBCDIC representation. The characters are stored 75 in consecutive bytes. For D format the maximum approx. is 7.2 x 10 with about 1675 digit accuracy. For E format the maximum approx. is 7.2 x 10 with about 7-digit 75 accuracy. For L format the max approx. is 7.2 x 10 with about 32-digit accuracy. For P format each digit is converted to a 4 bit binary integer and decimal point is ignored. For Z format each digit is converted to its 8-bit EBCDIC form.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
THE DS DIRECTIVE
Name Opcode Operand
DS
Modifier
Optional
Eg 1
DATE
DS
2 CL 8
Modifier Type Duplicator
Eg 2:
MVC MVC
DATE(10),=C09/10/1998 DATE,=C09/10/1998
DATE DS 2CL10 Figure: 4 3 DS directives NOTES: The DS directive is used to reserve an area of memory for future data. If the length field is omitted when specifying a symbolic address in an SS 1 or SS2 instruction, the assembler uses the length attribute of that symbol.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SUB DIVISIONS
DATE MONTH DAY YEAR DS DS DS DS DS DS 0CL10 CL2 C CL2 C CL4
DAY 1 4
01
02 02 02 02 02
DATE.
Figure: 4 4 Sub divisions NOTES: Subdivisions are convenient for defining areas within an area. In the above example DATE and MONTH both will have the same address.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Eg 4
EX1
EX2
EQU
DC
* - EX2
CHELLO
Figure: 4 5 Equivalence constants NOTES: EQU directive is to define a value for a symbol. This value cannot be changed in the program. The EQU does not cause any bytes to be generated on the object module. The assembler at assembly time uses the constant defined by the EQU directive.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Valid relocatable constants : R+A, R-A, R+(S-T), R-(S-T),-R Invalid constants : R + S, R*S, R/S, R+(S-A)
Where R,S and T are non-negative re-locatable constants, A, B and C are absolute constants.
Figure: 4-6 Relocatable and absolute constants NOTES: An assembly language constant consists of an algebraic expression of one or more terms. Each item is re-locatable if it is used to represent a memory address, if not it is an absolute term. The value of an absolute term remains unchanged during run time and assembly time whereas the value of a re-locatable term may change from assembly time to run time.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CONTROL SECTIONS
SOURCE MODULE OBJECT MODULE
Input
output
Figure: 4-7 Control sections NOTES: There are 2 types of control sections namely executable control section and reference control section. An executable control section consists of instructions, constants and data areas whereas a reference control section consists of directives only. The assembler keeps a separate memory location counter for each control section in the source module.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SOURCE MODULE
7FC 328 800 0 A 0 B A CSECT . .. DSECT CSECT END Opcode CSECT Operand blank
CSECT Name field Any symbol Or blank START Name field Any symbol
Opcode START
Operand blank or
Or blank
Figure: 4-8 Source module. NOTES: CSECT specifies the beginning of any executable control system in a source module. Symbol in the name field of a CSECT is considered to be entry point for the CSECT; it can be referred as an external symbol from another source module. START specifies the beginning of the first executable control section in a source module. The START pseudo-op cannot be used to resume an executable control section. The value of the selfdefining term in the operand (if present) designates the initial value for the memory location counter of the control section. If the operand is blank, the initial value is zero.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SAMPLE PROGRAM TO PRINT THE SUM OF TWO BINARY INTEGERS * * * * * * * * * * PRINTEX CSECT This program will compute the sum of two binary integers Convert the sum to a 10-byte character form suitable for Printing and print the result. The conversion process used is valid only for nonnegative Integers. i.e. the sum in this process is printed as a 10-digit Number without punctuating commas, with leading zeroes Printed as zeroes, and with the sign not printed. The integers used to compute the sum are defined within the PROGRAM: they are not read as input data. STM BALR ST LA OPEN 14, 12, 12 (13) 12,0 13,SAVE+4 13,SAVE (PRINTER, (OUTPUT)) 3,X 3, Y 3, Z 5, Z 5,BCD SUM, BCD SUM+9, X F0 STANDARD ENTRY
USING
*, 12
FILE * ADD L INTEGERS A Y, AND ST ADDRESS * CONVERT L REGISTERS CVD UNPK OI LOW-ORDER
OPEN THE PRINTER OUTPUT COMPUTE THE SUM OF THE AT SYMBOLIC ADDRESSES X & STORE THE SUM AT SYMBOLIC COPY THE SUM INTO CONVERT IT TO BCD FORM CONVERT THAT TO EBCDIC ELIMINATE SIGN CODE IN
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* PRINT PUT PRINTER, LINE WRITE THE SUM, TOGETHER WITH TEXT, ONTO THE PRINTER. * EXIT CLOSE (PRINTER) L 13, SAVE+4 STANDARD EXIT LM 14,12,12(13) BR 14 * INTEGER CONSTANTS, AND AREA RESERVED FOR THEIR SUM X DC F437 BINARY REPRESENTATION OF DECIMAL +437 Y DC F562 BINARY REPRESENTATION OF DECIMAL +562 Z DS F BINARY SUM, TO BE CONVERTED TO EBCDIC BCD DS D 8 BYTES RESERVED ON DOUBLEWORD * AREA RESERVED FOR 132-BYTE PRINT LINE LINE DS 0CL132 BEGINNING AND LENGTH OF LINE DC CL7 COLS 1 7 BLANK DC CTHE SUM IS SUM DS CL10 DC CL104 * * DATA CONTROL BLOCK FOR OUTPUT TO PRINTER PRINTER DCB DSORG=PS, MACRF=(PM), DDNAME-SYSPRINT, X RECFM=FB, LRECL=132, BLKSIZE=4092 * REQUIRED STATEMENTS : SAVE DS 18F END NOTES: The program computes the sum of 2 positive binary integers and converts the sum to a 10-byte character form for printing.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
PROGRAM TO PRINT THE SUM OF TWO UNSIGNED DECIMAL INTEGER RDPRT CSECT
* THIS PROGRAM READS TWO NON-NEGATIVE INTEGERS FROM A DATA CARD THAT IS IN * THE INPUT DATA STREAM, COMPUTERS THEIR SUM, AND PRINTS THE RESULT IN A * SINGLE LINE ON THE PRINTER.THE INPUT DATA IS ASSUMED TO BE REPRESENTED AS * 10-BYTE UNSIGNED DECIMAL INTEGERS, WITH EITHER LEADING ZEROES OR LEADING * BLANKS. * THE SUM IS PRINTED AS A 10-BYTE UNSIGNED DECIMAL INTEGER, WITH LEADING * ZEROES PRINTED AS ZEROES. STM 14, 12, 12(13) BALR 12, 0 USING *, 12 ST 13, SAVE+14 LA 13, SAVE * OPEN STANDARD ENTRY
INPUT AND OUTPUT FILES OPEN (TRANS,(INPUT) CARDS FROM INPUT DATA STREAM OPEN (PRINTER,(OUTPUT) PRINTER IS SYSOUT GET ONE DATA CARD TRANS, CARD INPUT AREA IS CARD
* READ
CONVERT EACH NUMBER TO 32-BIT BINARY PACK BCD,INT1 FIRST INTEGER IS AT INT1 CVB 5, BCD ITS 32-BIT BINARY INTEGER FORM IS STORED AT X. PACK BCD,INT2 SECOND INTEGER IS AT INT2. CVB 5,BCD ITS 32-BIT BINARY INTEGER FORM IS ST 5, Y STORED AT Y.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPUTE THE SUM, AND STORE BINARY INTEGER RESULT AT Z . L 3, X INTEGERS GIVEN A 3, Y AND ST 3, Z ADDRESS Z. COMPUTE THE SUM OF THE AT SYMBOLIC ADDRESSES X & Y, STORE THE SUM AT SYMBOLIC
CONVERT THE SUM TO UNSIGNED 10-BYTE CHAR, FORM WITH LEADING ZEROES. L S, Z PUT THE SUM IN A REGISTER CVD 5, BCD CONVERT IT TO BINARYCODED DEC. UNPK SUM,BCD CONVERT THAT TO CHAR (EBCDIC) OI SUM+9, X FO ELIMINATE SIGN CODE * PRINT THE RESULT PUT PRINTER, LINE EOJ CLOSE (PRINTER) CLOSE (TRANS) L 13, SAVE+14 LM 14,12,12(13) BR 14
* AREAS RESERVED FOR TWO BINARY INTEGERS AND THEIR SUM X DS F BINARY REPRESENTATION OF INTEGER AT INT1 Z DS F SUM OF X AND Y INTEGERS * AREA RESERVED FOR INTERMEDIATE BINARY-CODED DECIMAL REPRESENTATION BCD DS D SAME AREA USED FOR ALL CONVERSIONS * AREA RESERVED FOR 80-BYTE INPUT CARD CARD DS OCL 80 BEGINNING AND LENGTH OF AREA DS CL5 COLS 1 5 UNUSED INT1 DS CL10 6 15 FIRST 10-BYTE DECIMAL INTEGER DS CL5 16 20 UNUSED INT2 DS CL10 21 - 30 SECOND 10-BYTE DECIMAL INTEGER DS CL50 31 80 UNUSED
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* AREA RESERVED FOR 132-BYTE PRINT LINE LINE DS OCL132 BEGINNING AND LENGTH OF LINE DC CL7 COLS 1- 7 BLANK DC CTHE SUM IS 8 18 EXPLANATORY TEXT SUM DS CL10 19 28 10 BYTE SUM DC CL104 29 132 BLANK TRANS DCB DSORG-PS, MACRF-(GM), DDNAME-SYSIN,EODADEOJ, X RECFM=FB, LRECL-80,BLKSIZE=4080 PRINTER DCB DSORG=PS,MACRF=(PM),DDNAME=SYSPRINT, X RECFM=FB,LRECL=132,BLKSIZE=4092 REQUIRED STATEMENTS SAVE DS 18F END
NOTES: The program uses instructions such as PACK to convert from Zoned to BCD form and CVB convert form BCD form to Binary integer form. The resulting sum is printed as a 10 byte unsigned decimal integer.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
THE LA INSTRUCTION
General form 1. 2. 3. 4. LA LA LA LA R1, S2 R1, D2 R1, D2 (X2) R1, D2(X2, B2)
Eg 1: Eg 2: Eg 3 : Eg 4 :
LA LA LA LA
Figure: 4-9 LA Instructions NOTES: Eg 1: Is used to initialize register 5 with an implicit memory address. Eg 2: Is to initialize register 5 with a displacement of 4. Eg 3: Is to use register 5 as a counter and add a displacement of 4 to the contents of register 5. Eg 4: Is to add a displacement of 4, and contents of register 6 to the contents of register 5.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Implicit form :
Figure: 4-10 BXH and BXLE instruction NOTES: BXLE 7,8, LOOP means add the increment which is contents of register 8 to the index that is in register 7 and compare the sum to the limit that is in register 9. If the sum is less than or equal to the limit then branch to symbol called LOOP otherwise do not branch.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Binary vs. Character data Conversion of binary integer to character Allocating a memory area
Figure 4 - 11 Printing nonnegative integers NOTES: Integer data used for arithmetic purposes are represented in the binary number system, where as all data transmitted between memory and most input and output devices are in character format. In the IBM 360 and 370 systems, EBCDIC character format is used. To print an integer that is represented in binary form in memory, it must first be converted to its character form. The sequence of instructions must be used to converts a binary integer to its representation as a decimal integer in character form. The instructions (DS and DC directives) are also used to allocating memory areas for the characters that are to be printed.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 17 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
To define text that is to be printed on the line: DC C The three dots represent any text characters other than an apostrophe () or an ampersand (&) .
To assign m blanks to unused print positions : DC CLm m , an unsigned decimal integer, and is the number of consecutive blanks to be printed; the apostrophes enclose a single blank.
Figure 4 - 12 Allocating memory area. NOTES : The number of print positions per line is usually 132 for high speed printers. To allocate a memory area sufficient to accommodate any printed line , 132 bytes of memory must be reserved for the entire line, some of these bytes must be allocated for the integers . that are to printed, others for any text that is also to be printed, and the remainder for blanks that fill out the line.each such allocation will designate the print position that are to be used.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 18 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Binary representation of 12 : 0000 0000 0000 0000 0000 0000 0000 1100 character representation of 12 : 1111 0001 1111 0010
Figure: 4 13. Conversion from binary to character NOTES : The address of the binary integer must be specified in the second operand of the Load(L) instruction. The address of the ten-byte memory area that is allocated for the character representation of the number must be specified in the first operand of the UNPK instruction. The address of the low-order byte of the ten-byte character area must be specified in the first operand of the OI instruction. The address of the area reserved for the intermediate binary coded decimal representation must be specified in the second operand of both the CVD and the UNPK instructions.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 19 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 4 14 Reading non - negative integer input data NOTES : The PACK instruction converts from character form to binary coded decimal(BCD), and the converts to binary(CVB) converts from BCD to 32-bit binary integer form. The PACK CVB sequence , the counter part of the CVD UNPK sequence used for printing. The character form of the decimal integer occupies exactly ten positions ,right justified with either leading zeroes or leading blanks. Its sign is omitted; it is assumed to be nonnegative.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 20 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The Directives required to allocate memory area for the data : CARD DS DS INT DS DS 0CL80 CL5 CL10 CL65
DEFINE BEGINNING AND LENGTH OF CARD RESERVE 5 BYTES FOR UNUSED POSITIONS 10 BYTES FOR CHARACTER FORM OF INTEGER 65 BYTE POSITION FOR REMAINDER OF CARD
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 21 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CONVERSION FROM CHARACTER FORM TO32-BIT BINARY INTEGER FORM THREE INSTRUCTIONS ARE REQUIRED FOR CONVERSION : PACK BCD , INT CONVERT FROM CHAR. TO BCD CVB 5 , BCD CONVERT THAT TO 32-BIT BINARY IN REGISTER 5 ST 5,X STORE THE BINARY FORM AT SYMBOLIC ADDRESS X THE SYMBOLIC ADDRESS INT: INT DS CL10 RESERVE 10 BYTES FOR THE CHARACTER FORRM
THE SYMBOLIC ADDRESS BCD : BCD DS D RESERVEV 8 BYTES ON A DOUBLE WORD BOUNDARY
THE SYMBOLIC ADDRESS X : X DS F RESERVE ONE FULL WORD FOR A BINARY INTEGER
Figure: 4 16 Conversion NOTES : The address of the 10-byte memory area that is allocated for the input character representation of the number must be specified in the second operand of the PACK instruction. The address of the area reserved for intermediate BCD representation of the number must be specified in the first operand of the PACK instruction and in the second operand of the CVB instruction. The address of the area reserved for the binary integer must be specified in the second operand of the ST instruction.
Copyright MCPL. Unit 4.Basic Operations: Looping and Arrays Page 4 - 22 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 5 1 Twos compliment NOTES : The value of each integer b0,b1,b2,b3 can be computed as (1-2b0 ) The term integer arithmetic includes several types of instructions that operate on fullword and half-word binary numbers: copying data into and out of a register; addition, subtraction, multiplication and division of two binary integers; changing sign, and generating the absolute value of a binary integer; testing for positive, negative, or zero numeric result; and comparing two binary integers algebraically.
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ARITHMETIC INSTRUCTION
Addition Instruction A, AR, AH Al, ALR Condition codes 0 1 result was zero Result = -ve result was zero Result was not zero With no carry With no carry out Out of sign bit Of sign position Position 2 Result = +ve Result was zero With a carry out of sign bit position 3 Overflow Result was Zero with a carry out of sign bit position.
Eg 1: A Eg 2: AR Eg 3: AH 8, =H5 8, 9 5,=F15
Reg 5 Before : 0000 0030 After : 0000 003F Reg 8 Before: 0000 0001 After : 0000 0011 Reg 8 Before : 0000 0040 After : 0000 0045
= F15 0000 000F 0000 000F Reg 9 0000 0010 0000 0010 = H5 0005 0005
Figure: 5-2 Arithmetic Instructions NOTES: Condition code stores the status of each add instruction after execution.
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SUBTRACTION
Instruction Instruction S, SR, SH Sl, SLR 0 Result = 0 Condition Codes 1 Result = -ve Result was not zero with no carry out of sign bit position 2 Result = +ve Result was zero with a carry out of sign bit position 3 Overflow result was not zero with a carry out of the sign bit position.
Eg 1: S 5, = F10
=F10 0000 000A 0000 000A Reg 9 0000 1000 0000 1001 =H80 0050 0050
Eg 2:
SR
8, 9
Eg 3:
SH
8, =H80
Figure 5-3 Subtractions NOTES: If the result after subtraction is negative then the result is in twos complement form.
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MULTIPLICATION
even register Before After Eg 1 : : SR 4,4 L 5,=F3 M 4,=F2 odd register
Some Number Multiplicand 64 bit product even-odd pair Reg 4 Reg 5 Before : 0000 0000 0000 0003 After : 0000 0000 0000 0006
Eg 2
SR 6,6 L 7,=F65536 MR 6, 7
Before : After :
Reg 6 0000 0000 0000 0001 Reg 9 0000 0003 0000 000F
Eg 3
L 9,=F3 MH 9,=H5
Before : After :
Figure: 5 4 Multiplication NOTES: While using M and MR instructions, Multiplicand must always be in an odd-numbered register. The product is 64-bit signed integer that occupies two consecutive registers (called even-odd pair).
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DIVISION
even-odd register pair even numbered Register odd numbered register
Before
64 bit dividend
After Eg 1 L L D L L L DR
32-bit quotient Reg 6 0000 0000 0000 0001 Reg 8 Before : 0000 0000 After : 0000 001E Reg 7 0000 0009 0000 0004 Reg 9 0000 0096 FFFF FFFD FFFF FFFF FFD4 Reg
Before : After :
Eg 2 10 FFD4
Figure 5 5 Division NOTES: While using the D & DR instructions the dividend is a 64-bit integer. Divisor could be stored in any register. The remainder is stored in the even-numbered register and the quotient is stored in the odd-numbered register.
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BRANCHING INSTRUCTIONS
BZ BNZ BM BNM BP BNP
R1,R2
Figure 5 6 Branching Instructions NOTES: The conditional branch instructions do not set the condition code. They only test it. The LTR instruction sets the condition code according to whether register R1 is zero, negative or positive. Before testing, the LTR instruction first copies the contents of R2 to R1.
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPARISON
INSTRUCTION 3 C, CR, CH -----Opcode BE BNE BL BNL BH BNH L C BE BH 5, Z 5,=F6 EQ HIGH L CH BNE 3, Z 3,=H Z NEQ 0 N1 = N2 CONDITION CODE 1 N1 < N2 2 N1 > N2
Eg 1
Eg 3
Eg 2: L L CR BNH B
3, Z 4,=F6 3, 4 LORE GT
Figure 5 7 Comparison NOTES: One of the two numbers to be compared must be in a register and the other number can be in a register or memory location. None of the numbers are affected by the compare instruction.
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPLEMENT INSTRUCTIONS
Instruction LCR LPR LNR 0 result = 0 result = 0 result = 0 CONDITION CODE 1 2 result = -ve ------result = -ve result= +ve result=+ve ------Reg 5 Eg 1 LCR 5,5 before After Eg 2: LCR 5, 6 Before After Eg 3: LPR 5, 4 : : 0000 FFFF 0002 FFFE Reg 6 8000 0000 8000 0000 Reg 5 3 overflow overflow -----------
Before :FFFF FFFA 0000 00AB After Eg 4: LPR 4, 5 : FFFF FFFA 0000 0006 Reg 4 Before : FFFF FFFA After : 000 00AB Reg 5 0000 00AB 0000 00AB
Copyright MCPL. Unit 5. Integer Arithmetic 5 - 9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Eg 5:
LNR
4,5
Reg 5 0000 00AB 0000 00AB Reg 5 0000 00AB FFFF FFFA
Eg 6:
LNR
5, 4
Figure: 5-8 complement instruction NOTES: The LCR instruction loads the twos complement of a register. The LNR instruction is used to load the negative absolute value of a number. The LPR instruction is used to load the positive absolute value of a number.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* REQUIRED STATEMENTS * START CSECT STM 14,12,12(13) BALR 12,0 USING *,12 ST 13,SAVE+4 * WTO 'FIRST STEP' LA 13,SAVE OPEN (FILE,(OUTPUT)) * * ADDITION OF THE TWO INTEGERS * S LA 8,ARRAY L 9,N SR 10,10 ADD A 10,0(8) LA 8,4(8) BCT 9,ADD ST 10,Z * * CONVERSION OF BINARY O/P TO EBCDIC * CONVERT L 5,Z CVD 5,BCD UNPK SUM,BCD OI SUM+9,X'F0' PUT FILE,OUTREC CLOSE FILE * L 13,SAVE+4 LM 14,12,12(13) BR 14 * * DATA CONTROL BLOCK FOR WRITING THE O/P * FILE DCB DSORG=PS,MACRF=(PM),DDNAME=SYSOUT, RECFM=FB,LRECL=80,BLKSIZE=8000 * Copyright MCPL. Unit 5. Integer Arithmetic 5 -11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
*** DEFINING THE CONSTANTS USED IN THE PROGRAM Z DS F N DC F'10' ARRAY DC F'1,2,3,4,5,6,7,8,9,10' OUTREC DS 0CL80 DC CL25' THE SUM OF ARRAY IS' SUM DS CL10 DC 45C' ' BCD DS D *** REQUIRED STATEMENTS * DS 0D SAVE DS 18F
Copyright MCPL. Unit 5. Integer Arithmetic 5 -12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* * *
THIS PROGRAM ADDS FINDS AVERAGE OF AN ARRAY REQUIRED STATEMENTS CSECT STM BALR USING ST WTO LA OPEN 14,12,12(13) 12,0 *,12 13,SAVE+4 'FIRST STEP' 13,SAVE (FILE,(OUTPUT)) INTEGERS
START
* * S ADD
AVERAGE LA L SR A LA BCT ST M D ST ST
OF THE
8,ARRAY 9,N 11,11 11,0(8) 8,4(8) 9,ADD 11,Z 10,=F'1' 10,N 11,QUOT 10,REM OF BINARY O/P TO EBCDIC 5,Z 5,BCD SUM,BCD SUM+9,X'F0' FILE,OUTREC1 6,QUOT 6,BCD Q,BCD Q+9,X'F0' FILE,OUTREC2 7,REM
Copyright MCPL. Unit 5. Integer Arithmetic 5 -13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CVD UNPK OI
* * DATA CONTROL BLOCK FOR WRITING THE O/P * FILE DCB DSORG=PS,MACRF=(PM),DDNAME=SYSOUT, RECFM=FB,LRECL=80,BLKSIZE=8000 * *** DEFINING THE CONSTANTS USED IN THE PROGRAM Z DS F N DC F'3' QUOT DS F REM DS F ARRAY DC F'1,2,3' OUTREC1 DS 0CL80 DC CL25' THE SUM OF ARRAY IS' SUM DS CL10 DC 45C' ' OUTREC2 DS 0CL80 DC CL25' THE QUOTIENT IS' Q DS CL10 DC 45C' ' OUTREC3 DS 0CL80 DC CL25' THE REMAINDER IS' R DS CL10 DC 45C' ' BCD DS D SAVE DS 18F
Copyright MCPL. Unit 5. Integer Arithmetic 5 -14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* THIS PROGRAM MULTIPLIES EACH INTEGER IN AN ARRAY BY A CONSTANT * REQUIRED STATEMENTS * START1 CSECT STM 14,12,12(13) BALR 12,0 USING *,12 ST 13,SAVE+4 * WTO 'FIRST STEP' LA 13,SAVE OPEN (SNAPDCB,(OUTPUT)) SNAP DCB=SNAPDCB,ID=1,STORAGE =(START1,SAVE),PDATA=(PSW,REGS) OPEN (FILE,(OUTPUT)) * * AVERAGE OF THE INTEGERS * S LA 8,ARRAY L 9,N L 3,CONST MULT SR 10,10 L 11,0(8) MR 10,3 ST 11,Z ST 10,Y * * CONVERSION OF BINARY O/P TO EBCDIC * CONVERT L 5,Z CVD 5,BCD UNPK SUM,BCD OI SUM+9,X'F0' SNAP DCB=SNAPDCB,ID=2,PDATA=(PSW,REGS), STORAGE=(START1,SAVE) PUT L CVD UNPK FILE,OUTREC1 6,Y 6,BCD Q,BCD
OI Q+9,X'F0' Copyright MCPL. Unit 5. Integer Arithmetic 5 -15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* * DATA CONTROL BLOCK FOR WRITING THE O/P * FILE DCB DSORG=PS,MACRF=(PM),DDNAME=SYSOUT, RECFM=FB,LRECL=80,BLKSIZE=8000 * SNAPDCB DCB DSORG=PS,MACRF=(W),RECFM=VBA,BLKSIZE=1632,LRECL=125, DDNAME=SNAPSHOT *** DEFINING THE CONSTANTS USED IN THE PROGRAM Z DS F Y DS F CONST DC F'2' N DC F'5' ARRAY DC F'1,2,3,4,2147483647' OUTREC1 DS 0CL80 DC CL25' THE VALUE IN R11 IS' SUM DS CL10 DC 45C' ' OUTREC2 DS 0CL80 DC CL25' THE VALUE IN R10 IS' Q DS CL10 DC 45C' ' BCD DS D SAVE DS 18F
Copyright MCPL. Unit 5. Integer Arithmetic 5 -16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* THIS PROGRAM COUNTS THE NUMBER OF POSITIVE INTEGERS IN AN ARRAY * REQUIRED STATEMENTS START1 CSECT STM BALR USING ST WTO LA OPEN SNAP OPEN LA L L LTR BNP A LA BCT ST 14,12,12(13) 12,0 *,12 13,SAVE+4 'FIRST STEP' 13,SAVE (SNAPDCB,(OUTPUT)) DCB=SNAPDCB,ID=1,STORAGE=(START1,SAVE), PDATA=(PSW,REGS) (FILE,(OUTPUT)) 8,ARRAY 9,N 11,0(8) 11,11 LOOPCTL 10,=F'1' 8,4(8) 9,POSCHK 10,POSCTR OF BINARY O/P TO EBCDIC 5,POSCTR 5,BCD SUM,BCD SUM+9,X'F0' DCB=SNAPDCB,ID=2,PDATA=(PSW,REGS),
X * * S POSCHK
LOOPCTL
Copyright MCPL. Unit 5. Integer Arithmetic 5 -17 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* * DATA CONTROL BLOCK FOR WRITING THE O/P * FILE DCB DSORG=PS,MACRF=(PM),DDNAME=SYSOUT, X RECFM=FB,LRECL=80,BLKSIZE=8000 * SNAPDCB DCB DSORG=PS,MACRF=(W),RECFM=VBA,BLKSIZE=1632,LRECL=125, DDNAME=SNAPSHOT *** DEFINING THE CONSTANTS USED IN THE PROGRAM POSCTR DS F N DC F'11' ARRAY DC F'-1,-2,-3,-4,-5,0,1,2,3,4,5' OUTREC1 DS 0CL80 DC CL50'NUMBER OF POS NUMBERS IN THE ARRAY IS ' SUM DS CL10 DC 20C' ' BCD DS D SAVE DS 18F
L LM BR
13,SAVE+4 14,12,12(13) 14
Copyright MCPL. Unit 5. Integer Arithmetic 5 -18 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BYTE OPERATIONS
Type RX RX RS RS
Register 0 Mask 8 16 24
Eg 1: IC 8, A
Eg 2:
STC
4, Z
Before After
: 01 02 03 04 : 01 02 03 04
Copyright MCPL. Unit 5. Integer Arithmetic 5 -19 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Eg 3:
ICM
Reg 6 : 01 02 03 04 : A1 02 A2 04 1 0 0 1
Eg 4:
STCM 4, 0011, Z
Reg 4
mem loc. Z A1 A2 A3 A4 03 04 A3 A4
Before : 01 02 03 04 After : 01 02 03 04
Figure 5-9 Byte NOTES: Set of bytes can be copied from memory to register and vice-versa. The ICM and STCM instructions are available on the IBM 370 only and not on the IBM 360. The number of bytes that are inserted or stored is equal to the number of 1s in the 4-bit mask. The relative position of the bytes in the register is dependent on the position of bit 1s in the mask. A one-to-one correspondence from left to right is used.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -20 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MOVING BYTES
Opcode MV1 MVC MVC IN MVCL Type SI SS1 SS1 RR
Eg 1: MVI
Z+3, C !
Eg 2: MVC
Z(4), Y
Eg 3: MVC Eg 4: MVCIN
Figure 5-10Moving Bytes NOTES: The MVCL and MVCIN instructions are available on the IBM 370 only and not on the IBM 360. The MVC instruction has a length field which specifies the number of bytes that are to be copied. In Eg 3 the sending field 500-502 overlaps receiving field 501503. In the MVCIN instruction memory location Y is the sending field and memory location Y is the sending field and memory location Z is the receiver.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -21 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPARISON OF BYTES
OPCODE Opcode CL CLR CLM CLI CLC CLCL
Type RX RR RS SI SSI RR
Condition Code Instruction CL, CLC, CLR CLCL, CLI, CLM 0 S1 = S2 1 S1<S2 2 S1>S2 3 ----
Figure 5-11 Comparison Of Bytes NOTES: CLCL instruction is available only on IBM 370 and not on IBM 360. SI is the first string and S2 is the second string.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -22 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Sample program segment to replace the question mark symbols in a given text with periods.
CMP NXT
TXT LEN
Figure 5-12 Sample programs NOTES: The program uses register 4 to store the address of TEXT and register 5 to store the length of the TEXT. The string TEXT is searched for the question mark and replaced with period.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -23 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Sample program segment to find the first comma or blank and compute the length of the string preceding it. LA LA CLI BE CLI BE LA BCT LA SR STH . . DC EQU DS . . 4, text 5, LEN 0(4),C , DONE 0(4), C OVER 4, 1(4) 5, CMP 4, LEN 4, 5 4, POSIT
CMP
OVER EXIT
Figure 5-13 Sample programs NOTES: The assembler calculates the difference of two addresses ,the starting byte and the byte following last byte to compute the length of the string.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -24 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
REPEAT
EXIT
Figure 5 14 Program segment NOTES: The TABLE contains elements. ELEMTS contains number of entries in the TABLE. STR contains the string to be searched. If the string is not found then zero is stored in POSIT. If the string is found then the address of the matching string is stored.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -25 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SHIFTING BITS
ARITHMETIC LOGICAL Opcode SRA, SLA SLDA, SRDA RS RS Reg 9 Before : 0001 0001 0001 0001 0001 0001 0001 0001 After : 0000 0000 0000 0000 0000 0000 0000 0000 Eg 2: SRA 8,5 Reg 8 Before : 1111 1111 1111 1111 1111 1010 1010 1000 After Eg 3: SLA 4,4 (10) : 1111 1111 1111 1111 1111 1110 1101 0101 SHIFT SHIFT Type
Eg 1 : SRA
9, 31
Propagation of sign bits Reg 10: Displacement : 0000 0000 0000 0000 1000 0000 0000 00 1100 Reg 4
1000 0100
Before : 1111 1010 1111 1000 0000 0111 0000 0110 After : 0000 0000 0111 0000 0110 0000 0000 0000
Copyright MCPL. Unit 5. Integer Arithmetic 5 -26 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Eg 4 :
Reg 6 1A 1B 1C 1D 03 43 63 83
Reg 7 1E 1F 10 11 A3 C3 E2 02 1E 1F 10 11 F8 80 88 00
Eg 5 : SLDA
6, 11 Before : After :
1A 1B 1C 1D 58 ED E8 F0
Figure 5-14 Shifting bits NOTES: In an arithmetic shift the sign bit of a register or register pair is treated differently from the other, bits and the condition code has a value which denotes the status of the result. In a logical shift the sign bit is treated as similar to any other bit and the condition code is not set.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -27 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LOGICAL SHIFTS
Opcode SRL, SRL, SLL, SRDL, SLDL Type RS
SRL SLL
8, 5 8, 4(10)
Reg 8 Before : 1111 1111 1111 1111 1111 1111 1010 0100 After : 0000 0111 1111 1111 1111 1111 1111 1101 Reg 10 : Displacement : 0000 0000 0000 0000 1000 1000 0000 0000 0100
SRDL 6, 3 SLDL 6, 11
00 1100 Reg 8 Before : 0000 1001 0000 1000 0000 0111 0000 0110 After : 1000 0000 0111 000 0110 0000 0000 0000 Reg 6 Reg 7 Before : 1A 1B 1C 1D 1E 1F 10 11 After : 03 43 63 83 A3 C3 E2 02 Reg 6 Reg 7 Before : 1A 1B 1C 1D 1E 1F 10 11 After : D8 E0 E8 F0 F8 80 88 00
Figure 5-15 Logical shifts NOTES: When the contents of a register or register pair are shifted X bits to the right then X right most bits are lost and zeros are inserted into the X left - most positions. The sign bit is treated as any other bit. The condition code is not set.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -28 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ALTERING BITS
0 1 2 3
I/O
TYPE
EOF COMMENT File not open File open If open, file is used for input only If open, file is used for output only. Sequential file indexed sequential file 5 File has not reached end-of-file File has reached end-of-file
VALUE 0 1 0 1 0 1 1 2 0 1 4 3
Open
I/O
Type
EOF
Copyright MCPL. Unit 5. Integer Arithmetic 5 -29 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
VALUE 0 1 00 01 10 11 00 01 10 11 0 1
COMMENTS File not open File open No meaning Opened for input only Opened for output only Opened for input & output No meaning Sequential indexed sequential direct not end-of-file end-of-file
TYPE
EOF
Copyright MCPL. Unit 5. Integer Arithmetic 5 -30 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Opcode
Type
Location of mark
Locn of
O, N, X (Second operand) OR, NR, XR operand) OX, NI, XI operand) OC, NC, XC memory (First operand)
Register (second Operand) Immediate data field (Second operand) L byte memory
(Second operand)
Figure 5-16 Boolean Instructions NOTES: The OR, AND and EXCLUSIVE OR instructions are used to alter bits. The conditional branch instructions following boolean instructions are BZ, BZR, BNZ, BNZR.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -31 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
FILESTAT, OPEN FILESTAT, TYPISAM FILESTAT, IOOUT OUTPUT FILESTAT, IOIN INPUT FILESTAT, IOINOUT BOTH
Copyright MCPL. Unit 5. Integer Arithmetic 5 -32 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
TESTING BITS
Assembly language format Opcode operand TM D1 (B1), I2 TM S1, I 2 Machine Language format 91 D1 91 I2 I 2 Implied Displacement Base Register B1
TEST AND SET Assembly Language format TS TS D1 (B1) S1 Machine Language format 93 D1 93 0 8 16 B1
Figure 5-18 Testing Bits NOTES: TM instruction tests up to 8 bits at once without altering the bits that are tested. TS instruction tests only 1 bit, the sign bit and then sets all bits in the tested byte to 1. TS instruction is use in a program that controls the use of non sharable resources.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -33 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Eg 1 TM CHQ, X FO
Mask Byte = 1111 0000 Assumed target byte = 1010 1111 BM will branch whereas BO & BZ will not branch Eg 2 TM CHQ, XOF
Mask Byte = 0000 1111 Assumed target byte = 1010 1111 BO will branch whereas BM and BZ will not branch Eg 3 TM CHQ, B 0101 0000 Mark Byte = 0101 0000 Assumed target byte = 1010 1111 BZ will branch whereas BM and BO will not branch Eg 4 TS CHQ CHQ Before : 0111 1000 After : 1111 1111 BZ will branch whereas BNZ will not Eg 5 TS CHQ CHQ Before : 1000 0000 After : 1111 1111 BNZ will branch BZ will not NOTES: BM means branch on mixed zeroes and ones BZ means branch on zeros BO means branch on ones.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -34 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
THE BC INSTRUCTION
RX format for BC OP D2 M1 X2 B2 RR format for BCR OP R2 M1
CC = 3
CC = 2 Comment If condition code = 0, BC & BCR will branch If condition is 0 or 1, BC & BCR will branch Whatever the condition BC & BCR will not will not branch (no-op instruction) 8, FOUND = BE FOUND
Copyright MCPL. Unit 5. Integer Arithmetic 5 -35 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NOTES: The condition code settings are 2 bit, therefore condition codes can have a value of 0, 1, 2 or 3. ASM1 CSECT STM 14,12,12(13) BALR 12,0 USING *,12 ST 13,SAVE+4 LA 13,SAVE OPEN (OUTFILE,(OUTPUT)) MVC DATE1+2(2),D1 MVC DATE2+2(2),D2 MVC COMP+2(2),=C'60' CLC DATE1,COMP BH HIGH1 BL LOW1 HIGH1 MVC DATE1(2),=C'19' L 2,DATE1 B SUB1 LOW1 MVC DATE1(2),=C'20' L 2,DATE1 SUB1 CLC DATE2,COMP BH HIGH2 BL LOW2 HIGH2 MVC DATE2(2),=C'19' L 3,DATE2 B FIRST LOW2 MVC DATE2(2),=C'20' L 3,DATE2 FIRST MVC OUT1,DATE1 PUT OUTFILE,OUTLINE1 MVC OUT3,DATE2 PUT OUTFILE,OUTLINE2 C 2,DATE2 BH HIGH BL LOW HIGH MVC OUT5,=C'DATE1' PUT OUTFILE,OUTLINE3 B EXIT LOW MVC OUT5,=C'DATE2' PUT OUTFILE,OUTLINE3
Copyright MCPL. Unit 5. Integer Arithmetic 5 -36 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
EXIT
CLOSE OUTFILE L 13,SAVE+4 LM 14,12,12(13) BR 14 OUTFILE DCB DSORG=PS,MACRF=(PM),DDNAME=SYSOUT,RECFM=FB,LRECL=80, X BLKSIZE=8000 D1 DC CL2'00' D2 DC CL2'98' DATE1 DS CL4 DATE2 DS CL4 COMP DS CL4 OUTLINE1 DS 0CL80 DC CL20'FIRST DATE IS ' OUT1 DS CL4 OUT2 DC CL56' ' OUTLINE2 DS 0CL80 DC CL20'SECOND DATE IS ' OUT3 DS CL4 OUT4 DC CL56' ' OUTLINE3 DS 0CL80 DC CL20'LARGEST DATE IS ' OUT5 DS CL5 OUT6 DC CL56' ' SAVE DS 18F
Copyright MCPL. Unit 5. Integer Arithmetic 5 -37 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Opcode LCR
Meaning LOAD COMPLEMENT FROM REGISTER Copies the negative of V2 i,e its twos complement into the register occupied by V1;the result replaces V1. LOAD POSITIVE ABSOLUTE VALUES FROM REGISTER Copies the positive absolute value of V2 into the register occupied by V1;the result replaces V1. LOAD NEGATIVE ABSOLUTE VALUE FROM REGISTER Copies the negative absolute value of V2 into the register occupied by V1; the result replaces V1.
Type RR
LPR
RR
LNR
RR
Figure 5-20 Changing sign and generating absolute values NOTES: V1 , V2 are the operands. The nature of the result may be determined by use of the conditional branch instructions like BZ, BNZ, BM, BNM , BP and BNP.
Copyright MCPL. Unit 5. Integer Arithmetic 5 -38 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The condition code for LCR instruction : If result = 0 , condition code = 0 If result = - ve , condition code = 1 If result = +ve , condition code = 2 If result = overflow condition code = 3 The condition code for LPR instruction : If result = 0 , condition code = 0 If result = - ve , condition code = null If result = +ve , condition code = 2 If result = overflow condition code = 3 The condition code for LPR instruction : If result = 0 , condition code = 0 If result = + ve , condition code = 1 If result = +ve , condition code = null If result = overflow condition code = null
Copyright MCPL. Unit 5. Integer Arithmetic 5 -39 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
UNIT 6: CONSTANTS AND DATA AREAS OBJECTIVES: Relocatable and absolute constants Runtime constants Assembly time constants Data areas Boundary alignments
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CONSTANTS
Run-time constants Assembly-time constants Absolute constants Relocatable constants Data areas Address boundary
Figure: 6-1 Constants. NOTES: In assembly language, the source module can have two types of constants; Constants used by the program at run time, constants used by the assembler at assembly time. To differentiate the runtime constants and assembly time constants, all constants are classified as being either relocatable or absolute. Data Areas are memory locations that are defined by DS directives for specific type of data. The beginning address of the each runtime constants and data area is known as address boundary.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
RELOCATABLE Constants are dependent on the program memory location. RELOCATABLE Constants are MAIN MEMORY Addresses. CONSTANT consists of an Algebraic expression containing one or more terms. EXAMPLES: Let R, S, T are non-negative Relocatable constants. A, B, C are absolute constants. Valid absolute constants: -A, A+B, A-B, A*B, A/B, (A+B)/C, R-S Valid Relocatable constants: R+A, R-A, R+(S-T), R- (S-T), -R Invalid constants: R+S, R*S, R/S, R+(S-A)
Figure: 6-2 Relocatable and absolute constants NOTES: Any algebraic combination of two absolute terms or the difference between two allocatable terms is an absolute constant. If an absolute term is added to or subtracted from relocatable term is a relocatable constant.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
RUN-TIME CONSTANTS
RUN-TIME Constants can be specified by two ways: By means of DC Directive As VALUE-BASED Constants by use of literals or self-defining terms RUN-TIME Constants occupy memory location when program being executed. Type determines representation.
Figure: 6-3 Run-time constants NOTES: Run-time constants are represented by sequences of bits in memory. EX: The integer +3 is represented as; 0000 0000 0000 0000 0000 0000 0000 0011 The floating point representation of +3 : 0100 0001 0011 0000 0000 0000 0000 0000 The character representation of the 3 is ; 1111 0011
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
TYPES OF CONSTANTS
ASSEMBLY LANGUAGE TEXT Binary Integers Floating -point Single precision Double precision Decimal Hexadecimal Binary Digits Address FORTRAN COBOL Enclosed in quotes USAGE IS DISPLAY INTEGER(full word interger) USAGE IS COMP REAL DOUBLE PRECISION ---------Program names Variable names USAGE IS COMP-1 USAGE IS COMP-2 USAGE IS COMP-3 ----------Program names elementary, groups Record names Paragraph, sections
Representation of the constant in memory contains no indication of what type of constant it is.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
By using Define Constant (DC) directive we can generate the machine language constants. DC Directive format:
Name field Any symbol Or Blank Opcode DC Operand One or more sub fields, separated by commas
Figure: 6-5 Defined constants (DC) NOTES: Each use of the DC directive is written in the single assembly language statement. Comments, continuation and the identifications are also present with the Name field opcode and the operand. But those are optional. Each specification of the constant must be preceded by the type code identifying the form in which the constant is being specified.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Required
Duplicator
Type
Modifier
Constant
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Two types of value-based constants. Used to create data at run time. Literals Self-defining terms
Figure: 6-7. Value -based constants NOTES: The value-based constant allows the programmer to specify a constant in an operand without having to define that constant else where in the program.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LITERALS
Required = Duplicator Type Modifier Constant optiona l Statement1 Statement2 Statement3 FCON DC L L F 1 5,FCON 5, =F 1
Figure: 6-8 Literals NOTES: A literal is a symbolic representation of a constant to which the assembler assigns address. When single constant is needed in the operand of certain instructions, the programmer can use a literal to designate that constant without having to define the constant with a DC directive. The literal cant be used to designate a register address in any instruction, to specify the immediate data or mask field in any instruction, or to specify the length fields (L, L1, L2) in any instruction. They can, however, are specified in the second operand of any load, Add, Subtract, Multiply, Divide and Move an instruction that is not an RR or SI instructions.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SELF-DEFINING TERMS
SELF-DEFINING TERMS : Type of Term Decimal Integer Binary Integer Method of representation Comments Maximum, OS: 2 31-1 Maximum, OS: 32 bits Maximum, OS:8 hex digit DOS: 6 hex digit Maximum, OS: 5 char DOS:3 char Examples 3 12 B0001 B11 B 1011 X5A X6D X5100 CZ CCAT CA=B
Unsigned decimal integer B binary digits DOS :25 bits Hexa X Decimal hexadecimal Integer digits Sequence C Of text text Characters character Figure : 6-9 Self-defining terms NOTES:
A self defining term is an absolute constant that can be written 5 ways. Those are decimal integer, Binary integer and hexadecimal integer, sequence of text characters. The assembler substitutes its 5-bit binary representation.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ASSEMBLY-TIME CONSTANTS
Do not occupy memory locations in user program. Assembly-time constants: User defined symbols Assembly language itself Memory location symbol (*) EQU directive
Figure: 6-10 Assembly-time constants NOTES: The symbol (*) is used as assembly time constant , is the memory location symbol Assembly time constants those represented by the symbols that are the part of the assembly language itself and those represented by user defined symbols.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure : 6-11 Memory location symbol ( * ) NOTES: The value of the memory location symbol depends on the statement in which it is used.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
EQUIVALANCE CONSTANTS
EQU directive Used to define a value for symbol Format is same as dc directive format Value of operand is 006 HERE EQU *
Figure : 6-12 Equivalence constants NOTES: EQU directive provides an easy means of changing the value of the assembly time constant. We can use EQU directive any number of times in the program. EQU does not cause any bytes to be generated in the object module. The symbol HERE is assigned the current value of memory location symbol. The value is not known in advance by the programmer. HERE is the relocatable constant it represents the memory location.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MSG1 TLNG1
DC EQU
Figure : 6-13 Value too tedious to compute by hand NOTES: TLNG1 is assigned the value computed by subtracting the value that was assigned to the symbol MSG1. If the text value changed by the programmer the value TLNG1 is automatically changed when the program is reassembled. The TLNG1 is an absolute constant , since it equals the difference of two relocatable constants.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
TLNG2 TABLE2
TLNG2
Figure : 6-14. Value can change if program is changed NOTES: In first table the TLNG2 value is 20 ie number of bytes reserve for the above table of integers ( 4 bytes ). It is compute by the assembler by using the EQU directive. If the statements are added to or deleted from the TABLE2 table the value of the TLNG2 will be recomputed by the assembler.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
STATUS , ON POWERON THIS IS EQUIVALENT TO WRITING STATUS, XFF POWERON DS EQU EQU EQU CL 1 X00 XOF XFF device status byte device is off device is on but not in use device is on but being used.
Figure : 6-15. Value used symbolically NOTES: The use of ON has two advantages, each use of on will be recorded in the crossreference listing by the assembler and the change can be made to the value of ON without having to change any statements in the program except the EQU that defines ON. It is the good practice to use symbols that are equated to self-defining terms.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OFFSET
EQU 12
14,12,12(13)
14,R12,OFFSET(R13)
Figure: 6-16. Symbolic register addresses and symbolic displacements NOTES: So far we defined self-defining terms by symbolically. Similar advantage can be gained from symbolically defining the address of general registers and the value of the displacement constant.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 17 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 18 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SPLNG SPCHAR
EQU DC
* - SPCHAR C@#$%c&&*()+-=;;?/,.
SPCHAR SPLNG
DC EQU
C@#$%c&&*()+-=;;?/,. * - SPCHAR
Figure : 6-18. Invalid use of EQU. NOTES: In the first definition the EQU is an invalid attempt to define the SPLNG as the number of characters in the SPCHAR constant. The reason the first is invalid and the second is valid is that all the symbols appearing in the operand of EQU directive must have been defined prior to their appearance in the operand.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 19 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
RELOCATABLE
L LA LA LA L 4,Y 5,Y 6,W 7,Z 8,Z
VS
ABSOLUTE CONSTANT
IMPLICIT: USES IMPLIED BASE REGISTER IMPLICIT: USES IMPLIED BASE REGISTER IMPLICIT: USES IMPLIED BASE REGISTER EXPLICIT: SAME AS LA 7 , 4(0,0) EXPLICIT: SAME AS L 8 , 4(0,0)
Y DC F4 Y IS A RELOCATABLE CONSTANT (A SYMBOLIC ADDRESS) Z EQU 4 Z IS AN ABSOLUTE CONSTANT W EQU Y W IS A RELOCATABLE CONSTANT (EQUAL TO AN ADDRESS)
vs.
Absolute constant
The instruction L8, Z would load the contents of the location whose address is 000004; i.e. it does not load the value of Z, it loads the contents of Z. on the other hand the LA 7,Z instruction loads.
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 20 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DATA AREAS
Define Storage (DC) Directive General format is : Name Symbol or blank Opcode DC Operand One or more sub fields separated by comma Required
Duplicator
Type
Modifier
Constant Optional
Figure : 6- 20. Data Areas NOTES: DS directive is used to reserve the area of memory for future data. This directive causes a designated amount of memory space to be reserved in the program but dont place any data into the reserved area. EX for sub field component: Date DS 2 C LB Type Duplicator Modifier
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 21 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Length Any valid Either no constant Byte boundary Determine via modifier Type code or any valid Length modifier is used constant in the operand B,C,P,X,Z Any valid constant Byte boundary Determine by No constants Byte boundary Constants 1 H OR Y Either no constants half word boundary 2 OR Any valid constants
Length modifier
E,F,A,Q ,S Either no constant full word boundary 4 D OR L 8 OR Any valid constants Either no constant double word boundary OR Any valid constants
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 22 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BOUNDARY ALIGNMENT
DS 0H DS 0F DS 0D Half word boundary Full word boundary Double word boundary
Figure : 6-22. Boundary alignment NOTES: The most straight forward way to force alignment to the desired boundary for any constant or data area is to immediately precede the DC or DS directive that defines it with one of these three statements. DS DS DS EX: DC DS DC X80000000 0F X 80000000 0H 0F 0D
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 23 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DS
0D
001000 001000 80 001004 00000001 001008 0010028 0010028 F1F2F3 00102C 0002 001030 001078 C5D5C4 00107B FF
DS DC DC DS DC DS DC
FORCE ALIGNMENT TO FULL WORD 1-BYTE CONSTANT 4-BYTE CONSTANT, ON FULL-WD BDY CL25 25-BYTE RESERVED FORCED ALIGNMENT TO DBL-WD BDY FF1F2F3 3-BYTE CONSTANT 2-BYTE CONSTANT,ON HALF WORD BDY 18 FULL WORD RESERVED C END 3-BYTE CONSTANT,ON BYTE BDY 1-BYTE CONSTANT,ON BYTE BDY
Copyright MCPL. Unit 6.Constants and Data Areas Page 6 - 24 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 7. Byte and String Manipulation 7-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Byte-manipulation instructions have three general characteristics. 1 All byte-manipulation instructions operate on two strings. One of the strings in memory; the other may be in memory or in a register, depending on the instruction itself. 2 All byte-manipulation instructions require that the number of bytes being operate on the length of the strings be specified either explicitly or implicitly. 3 All the byte manipulation instructions described in this chapter treat bytes as 8bit nonalgebraic quantities: the high-order bit is not considered to be a sign bit but is treated in the same way as the other bits.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CHARACTER CONSTANTS
C-Type Constants C-Type DC Directive Length Modifier
Figure: 7-2 Character constant NOTES: To define data constant as a sequence of characters, we use the C data-type code. This code may be used in DC directive in literals and in self-defining terms. One byte is always allotted for each specified character. The maximum number of characters that can be specified for a single DC or literal constant is 256. When the length modifier Ln specifies fewer bytes than are needed to contain the binary representation of the data constant given in a C-type DC directive, the assembler deletes characters from the right. This is called truncation on the right. When the length modifier Ln specifies more bytes than are needed to contain the binary representation of the data constant given in a C-type DC directive, the assembler adds blank characters on the right to fill the length that was specified. This is called padding with blanks.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COPYING BYTES
Copying bytes to and from Registers Copying bytes from one Area Memory to another
Figure : 7-3 Copying Bytes NOTES : There are two sets of byte copying instructions: 1 copy bytes from memory into a register or from a register into memory 2 copy bytes from one area of memory to another area .The former are called INSERT and STORE instructions, respectively, the latter are called MOVE instructions.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copies 1 byte from memory into the 8 right-most bits of a register, without altering the other bits in that register.
STC
STORE CHARACTER Copies 1 byte the 8 right-most bits of a register---- into Memory. INSERT CHARACTERS UNDER MASK Copies N bytes, n<4, from memory into a register. The Number of bytes copied and their relative positions in the Register are specified in the second operand of the instruction.
RX
ICM
RS
STCM
STORE CHARACTERS UNDER MASK RS Copies N bytes, n<4, from register into memory. The Number of bytes copied and their relative positions in the Register are specified in the second operand of the instruction.
Figure 7-4 Copying Bytes to and from Registers NOTES: Note that the ICM and STCM instructions are available on the IBM 370, but not on the IBM 360. The letter M in these instructions refers the fact that the second operand of the ICM and STCM constitutes a mask rather than a register address or a length.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
4-bit register
16
24
4-bit mask
Figure : 7-5 Copying Bytes to and from Registers NOTES: The mask is 4-bit field that has a dual purpose. First, the number of bytes that are inserted or stored is equal to the number of 1s in 4-bit mask. And second, the relative position of the bytes in the register is determined by the relative position of the 1s in the mask , the corresponding being from left to right,one for one.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MVC MVCIN
SS1 SS1
Figure : 7-6 Copying Bytes From one Area of memory to Another NOTES: Note that the MVCL and MVCIN instructions are available on the IBM 370 but not on the IBM 360. The MVCIN instruction is available as a special feature rather than as a standard instruction on most IBM 370 systems. MVCIN can copy from 1 to 256 bytes from one location to another. The sending locations address is specified in the second operand field, and the receiving locations address and length are specified in the first operand field. Copyright MCPL. Unit 7. Byte and String Manipulation 7-7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPARING BYTES
Logical quantity and Arithmetic quantity Comparing Bytes when One of the Strings is in a Register Comparing Bytes when Both strings are in memory location
Figure: 7-7 Comparing Bytes NOTES: In comparing any two bytes, the contents of each byte are treated as unsigned 8-bit numbers. An unsigned quantity such as a byte contents is called logical quantity, whereas signed quantities such as integers are arithmetic quantities.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CLR
RR
CLM
Figure : 7-8 Comparing Bytes when one of the string s is in a Register. NOTES: To emphasize this distinction, all byte comparison instructions begin with the letter CL, meaning compare logical. The CLM instruction is available on the IBM 370 but not on the IBM 360. The letter M in this instruction refers to the fact that the second operand is a mask.The CLM mask functions in a manner similar to that in the ICM and STCM instructions .
Copyright MCPL. Unit 7. Byte and String Manipulation 7-9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CLC
SS1
CLCL
RR
Figure : 7-9 Comparing Bytes both strings are in Memory locations. NOTES: The CLCL instructions are available on the IBM 370 but not the IBM360.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Meaning Branch if v1 equals v2 Branch if v1 is not equal to v2 Branch if v1 is less than v2 Branch if v1 is not less than v2 Branch if v1 is higher than v2 Branch if v1 is not higher than v2
Figure : 7-10 Determining The Result of a String Comparison NOTES: Whenever compare instruction is used, the results of the comparison may be determined by means of a condition branch instruction. The same conditional branch instructions used in determining the result of algebraic comparison are used in determining the result of string comparison. Each of this six instructions is written with only one operand field. That field designates the address of the instruction to which a branch is made if the condition being tested is true.If the condition is not true, then no branch is made,instead,execution of the program continues with the instruction that immediately follows the conditional branch instruction. Copyright MCPL. Unit 7. Byte and String Manipulation 7-11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure : 7-11 String Processing Examples NOTES: The key aspect of these instruction is that they allow a programmer to deal with strings of arbitrary length , provided their length is known at that time a program is written.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
1 MVI Temp, C PUT A BLANK INTO FIRST BYTE 2 * OF AREA NAMED TEMP 3 MVC TEMP+1(79), TEMP PROPAGATE BLANK INTO REMAINDER 4 * 79 POSITIONS OF TEMP AREA . . . 5 TEMP DS CL80 RESERVE 80 BYTES FOR TEMP . . .
Figure : 7-12 Fill an area With Blanks NOTES:
Either of the following two MVC instruction will copy 80 blanks into the area named TEMP: MVC MVC TEMP(80),BLANKS TEMP, BLANKS EXPLICIT LENGTH FIELD LENGTH FIELD IMPLIED
To fill an area of memory with blanks, two things must be known: (1) the address of the area and (2) the number of bytes in the area, i.e., the areas length. The address can be written either symbolically or in base-displacement form. The areas length, an unsigned integer, can be written symbolically or numerically, or can be omitted and implied by the length attribute of the area.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DESTRUCTIVE OVERLAP
Overlap Area
Sending area Receiving area Destructive overlap
Figure : 7-13 Destructive Overlap NOTES: The fig illustrates the concept of destructive overlap, created by an MVC when two conditions exist simultaneously: (1) the sending area designated by the second operand overlaps the receiving area designated by the first operand, and (2) the first byte of the receiving area is with in the sending area.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Temp area Arbitrary data Arbitrary data Arbitrary data . All blanks All blanks
Figure : 7-14 Destructive Overlap NOTES: The above figure represents the sequence of the execution of the two instructions. In the 1 represents the MVI blank into first byte. 2. Represents MVC propagates first byte in 79 distinct steps, successively replacing the sending area bytes, one at a time, before they are copied into the receiving area.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NONDESTRUCTIVE OVERLAP
Overlap Area
Figure :7-15 Non Destructive Overlap NOTES: The method of Propagation illustrated here can be useful, it can also be disastrous if the programmer is unaware of the destructive overlap potential of the sending and receiving fields. If the first byte of the receiving area is not within the sending area, destructive overlap cannot occur. If in this situation, the areas partially overlap, they are said to overlap nondestructively.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure : 7-16 Replace Exclamation Points with Periods NOTES: The BCT instruction in statement 10 Reduces the loop control counter by 1.If the reduction is non zero , the BCT branches to the statement named COMPARE to continue the search .If the counter reaches 0 no branch will make.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-17 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
This solution is similar to that of Example 2. The differences are that: (1) the search is terminated either when a comma or blank is found or when there are no more bytes to be examined, and (2) when the search is terminated, the number of bytes that precede the first comma or blank is calculated and stored in the location named POSIT. It always requires at least two types of statements to examine a string: the first is a comparison, the second is a conditional branch determining the results of the comparison.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-18 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure : 7-18 Compare 5-Byte String to c End NOTES: Both strings are in memory and are of length greater than four, the CLC instruction is used. If the string lengths were greater than 256, or if the strings were of unequal length, the CLCL instruction would have to be used instead of the CLC.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-19 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure : 7-19 Compare 5-Byte String With Strings in a Table NOTES: A table is a set of related items stored in a memory An item in a table is almost always called a Table entry The number of entries in a table depends on length of each entry and amount of space available for the table. There are three entries given in the statement 14 through 16. But, instead of using the number three in the program, Statement 17 lets the assembler calculate the number and assign it to the symbol ENTRIES. Statements 5,8, and 12 require comment. Statement 5 compares the 5-byte string located at the current table-entry address given in Register 4 with the 5-byte string located at the symbolic address STRING. Statement 8 increments the table-entry address in Register4 by five (the length of each table entry) so that the second iteration of the loop will examine the second entry, and the third iteration will examine the third entry. Copyright MCPL. Unit 7. Byte and String Manipulation 7-20 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SUBSTRING OPERATIONS
EXAMPLE:
T: S: S1: S2:
Figure : 7-20 Substring Operations NOTES: We frequently need to be able to determine if a given substring, say S, exists within some string T. among the operations we may wish to perform on S are those of deleting each occurrence of S from T; replacing S by another string S1; or of inserting a string S2, immediately following S in T. Three operations illustrated for above example as follows 1. Deleting S from T would a new string, TNEW: A TYPICAL STRING NAMED T 2. Replacing S in T by S would yield this new String. TNEW: A VERY TYPICAL STRING NAMED T 3. Inserting S2 immediately following S in T TNEW: A NOT SO UNUSUAL BUT RATHER TYPICAL STRING NAMED T Copyright MCPL. Unit 7. Byte and String Manipulation 7-21 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
STUDENT NOTEBOOK
R1 = ADDR OF S R2 = ADDR OF CURRENT POSITION IN T R9 = ADDR OF CUR. POSITION IN TNEW R10=COMPUTED LNG OF TNEW (INITIALLY 0) R3 = NUMBER OF COMPARISONS REMAINING TO BE MADE. INITIALLY, EQUAL TO N ( M 1) IF N < M THEN MAKE NO COMPARISONS
LH 4, M R4 = LENGTH OF S, MINUS 1 SH 4,=H1 +1 IS SUBTRACTED FOR EX INSTR * COMPARES TO SUBSTRING OF SAME LENGTH IN T LOOP EX 4,COMPARE COMPARISON OF M BYTES BE EQUAL BRANCH IF SUBSTRING S IS FOUND NOTEQUAL MVC 0(1,9),0(2) COPY ONE CHAR FROM T TO TNEW AH 10, =H1 INCR LNG OF TNEW BY +1 LA 9,1(9) ADJ CUR POSIT IN TNEW BY +1 LA 2,1(2) ADJ CUR POSIT IN T BY +1 BCT 3,LOOP REDUCE #REMAINING COMPARISONS BY +1 B MOVE IF NO MORE COMPAISONS, GO COPY REST OF T Figure : 7-22 Byte and String Manipulations
Copyright MCPL. Unit 7. Byte and String Manipulation 7-23 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
* COPY REMAINING CHARACTER (IF ANY) FROM T TO TNEW MOVE LA AH SR BNP AR SH EX 5,T COMPUTE # CHARACTERS REMAINING IN T, BY 5,N SUBTRACTING CUR. POSIT. IN T FROM ADDR 5,2 OF FIRST BYTE BEYOND T NOMORE NO MORE CHARS IF S OCCUPIED LAST M 10,S BYTES OF T. OTHERWISE, INCR LNG OF 5, =H1 TNEW, AND PREPARE TO MOVE REMAINING 5,MOVEX CHARS TO TNEW VIA EX INSTR 5TH DS DS DS DS DS DS 10,NN CL256 CL256 CL256 H H H STORE COMPUTED LENGTH OF TNEW SPACE FOR MAX LENGTH T STRING SPACE FOR MAX LENGTH S STRING SPACE FOR MAX LENGTH TNEW STRING SPACE FOR LENGTH OF T ( 0<LNG<256) SPACE FOR LENGTH OF S (0<LNG < = 256) SPACE FOR LENGTH OF TNEW
NOMORE T S TNEW N M NN
FOLLOWING ARE TARGET INSTRS FOR EX INSTRUCTIONS IN ABOVE PROCEDURE COMPARE CLC 0(0,1),0(2) R1=ADDR OF S: R2 = CUR POSIT INT MOVE MVC 0(0,9),0(2) R9 = CUR POSIT IN TNEW ; R2 = POSIT IN T Figure: 7-23 String Editing-Delete Procedure NOTES:
Copyright MCPL. Unit 7. Byte and String Manipulation 7-24 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 7-24 Execute Instruction NOTES: When executed at run time, it causes the CPU to execute another instruction, called target instruction, located at the address given in the second operand field of the EX instruction. One of the main uses of the EX instruction depends on its capability for effectively but not actually changing the second byte (bits 8-15) of the target instruction is executed. This capability makes it possible to vary the length-field contents of SS1 and SS2 instructions and to vary the mask-field contents RS and SI instructions.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-25 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 7-25 CLCL and MVCL Instructions NOTES: To compare CLCL and MVCL are so named both of these instructions, the number of bytes operated on is not restricted to be less than or equal to 256,as is the case of CLC and MVC. In CLCL and MVCL the number of bytes can be from 0 to 2 24 - 1 The CLCL and MVCL are designed as RR type instructions.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-26 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CLCL INSTRUCTION
OPCODE OPERAND CLCL R1, R2 Reg R1 1100 Address 0 8 Reg R2 31 0 8 Reg R1 + 1 Reg length 31
Address
length
Second string
31 0
31
Copyright MCPL. Unit 7. Byte and String Manipulation 7-27 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CLCL LOOP
Using CLCL within a loop
Figure: 7-27 CLCL LOOP NOTES: The contents of two pair of registers are altered during the execution of the instruction. If the result of the comparison is that the two strings are not equal , the length and address fields of each register pair identify the bytes that caused the unequal result. One consequence of the register alterations just described is that if the CLCL is to be used in a loop, the length fields must be reloaded before each execution of the CLCL, and, depending on the locations of the strings being compared, the address fields may also have to be reloaded into the registers
Copyright MCPL. Unit 7. Byte and String Manipulation 7-28 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MVCL
Opcode operand MVCL R1,R2 Reg1 Address Reg1+1 length
310
31
Reg 2 +1
length
31
Figure: 7-28 MVCL NOTES: The MVCL Instruction, like the CLCL instruction, utilizes two even-odd pairs of registers during its execution. The MVCL and the meaning of the contents of the register pairs are similar to CLCL. The number of bytes specified by the length field in Register R1+1 is copied into the Receiving field, beginning at the address designated in Register R1. The bytes are copied from the sending field, starting from the address designated in Register R2.if the sending field length is less than the receiving field length, the remaining bytes of the receiving field are filled with the padding character.If the receiving field length is specified as zero,no bytes are copied. Copyright MCPL. Unit 7. Byte and String Manipulation 7-29 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
The TR and TRT instructions are used to help reduce the size and running time of programs that perform the following types of recurring string operations: Replacing some, but not necessarily all, bytes in a string with other predetermined bytes and Searching a string from left to right for the first occurrence of any one of some predetermined set of bytes.
Figure : 7-29 TR and TRT Instructions NOTES: The TR instruction can be used in any situation where it is desirable to replace certain bytes in a string with other byes. The TRT instruction can be used in any situation where we want to find one of a number of different characters in a string.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-30 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
GENERAL DESCRIPTION
Argument String Function String Length of Argument String Length of Function String Opcode TR TRT Operand D1(L,B1), D2(B2) D1(L,B1), D2(B2) Argument Function String string
Figure : 7-30 General Description NOTES: Both the TR and TRT instructions operate on two strings. One string is called the argument string and the other is called the function string. The bytes in the argument string are generally not known to the programmer, for it is the bytes in the argument string that are replaced by the action of the TR and searched by the action of the TRT. The programmer knows the bytes of the function string; the desired result can be achieved by the TR or TRT instructions. In the TR and TRT instructions, the argument string and its length are designated by the first operand and the function string is designated by the second operand. The length of the function string, which is usually 256 bytes, is not specified in either instruction.
Copyright MCPL. Unit 7. Byte and String Manipulation 7-31 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Shifting Bits Altering Bits Testing Bits The Condition Code Bit Manipulation Examples
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BIT MANIPULATIONS
Bit Manipulations includes several types of instructions that operate on one or more consecutive Bits
1. Shifting a bit sequence to the right or left 2. Altering individual bits 3. Testing individual bits 4. Testing the condition code
Figure 8-1 Bit Manipulations NOTES: The concept of a byte or character string, a sequence of consecutive bits is called a Bit String. The Bit String is usually used to refer to a sequence of bits.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SHIFTING BITS
Figure 8-2. Shifting Bits NOTES: In Arithmetic Shifts, the sign bit of the register or register pair is treated differently from other bits, and the condition code will be set to reflect the nature of the result. In Logical Shifts, the sign bit is treated in the same manner as all other bits, and the condition code is not set.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-3. Arithmetic Shift Instructions. NOTES: The 32-bit quantity in the register designated by the first operand is arithmetically shifted right(or left) N bit positions. The 64-bit quantity in the even-odd register pair designated by the first operand is arithmetically shifted right (or left) N bit positions. When the contents of a register or register pair are shifted N bits to the right, the N rightmost bits are lost, and the sign bit (bit 0) that existed before the shift began is inserted into each of the N left-most vacated positions, i.e., into bit positions 1 through N. The sign bit itself remains unchanged. When the contents of a register or register pair are shifted N bits to the left, zeroes are inserted into the N right-most vacated positions, the N left-most bits (not including the sign bit) are lost, and condition code 3 the overview indicator is set if a bit value different from that of the sign bit was among those that were lost. The sign bit itself remains unchanged. Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ARITHMETIC SHIFTS
Eg 1 : SRA 9, 31 Reg 9 Before : 0001 0001 0001 0001 0001 0001 0001 0001 After : 0000 0000 0000 0000 0000 0000 0000 0000 Eg 2: SRA 8,5 Reg 8 Before : 1111 1111 1111 1111 1111 1010 1010 1000 After Eg 3: SLA 4,4 (10) : 1111 1111 1111 1111 1111 1110 1101 0101
Propagation of sign bits Reg 10: Displacement : 0000 0000 0000 0000 1000 0000 0000 00 1100 Reg 4
1000 0100
: 0000 0000 0111 0000 0110 0000 0000 0000 Reg 6 1A 1B 1C 1D 03 43 63 83 Reg 7 1E 1F 10 11 A3 C3 E2 02 1E 1F 10 11 F8 80 88 00
1A 1B 1C 1D 58 ED E8 F0
In an arithmetic shift the sign bit of a register or register pair is treated differently from the other, bits and the condition code has a value which denotes the status of the result. Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
In a logical shift the sign bit is treated as similar to any other bit and the condition code is not set.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LOGICAL SHIFTS
Logical Shifts are used in conjunction with other bit and byte-manipulation to separate or join sequences of bits. Opcode SRL SLL SRDL SLDL Meaning Shift Right Single Logical Shift Left Single Logical Shift Right Double Logical Shift Left Double Logical Type RS RS RS RS
Figure 8-5. Logical Shifts NOTES: When the contents of a register or register pair are shifted N bits to the right, the N rightmost bits are lost, and zeroes are inserted into the N left-most vacated positions. When the contents of a register or register pair are shifted N bits to the left, the N left most bits are lost, and zeroes are inserted into the N right-most vacated positions. Regardless of the nature of the result of a logical shift instruction, the condition code is not set.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LOGICAL SHIFTS
Opcode SRL, SRL, SLL, SRDL, SLDL SRL SLL 8, 5 8, 4(10) Type RS
Reg 8 Before : 1111 1111 1111 1111 1111 1111 1010 0100 After : 0000 0111 1111 1111 1111 1111 1111 1101 Reg 10 : Displacement : 0000 0000 0000 0000 1000 1000 0000 0000 0100
00 1100 Reg 8 Before : 0000 1001 0000 1000 0000 0111 0000 0110 After : 1000 0000 0111 000 0110 0000 0000 0000 SRDL 6, 3 Reg 6 Before : 1A 1B 1C 1D After : 03 43 63 83 Reg 6 Before : 1A 1B 1C 1D After : D8 E0 E8 F0 Reg 7 1E 1F 10 11 A3 C3 E2 02 Reg 7 1E 1F 10 11 F8 80 88 00
SLDL 6, 11
Figure 8-6. Logical Shifts. NOTES: When the contents of a register or register pair are shifted X bits to the right then X right most bits are lost and zeros are inserted into the X left - most positions. The sign bit is treated as any other bit. The condition code is not set.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ALTERING BITS
The Assembly Language Programs use the individual bits in a bit string to represent status information. This type of information can be used to control the flow of a program and to keep succinct record of events that occur during the execution of a program. Bit position: 0 1 2 3
OPEN
TYPE
I/O
EOF
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
USE OF BITS AS INDICATORS Each bit in this bit string has a value of 0 or 1. These values could imply the status of a file as follows. Bit OPEN bit I/O bit 0 Value 0 1 1 0 1 0 1 Meaning = file not opened = file opened = if opened, file is used for input only = if opened, file is used for output only = sequential file = indexed sequential file = file has not reached end-of-file = file has reached end-of-file
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BIT VARIATIONS
Bit position: 0 OPEN 1 2 3 4 5
I/O TYPE EOF The bits could have following meaning: BIT Meaning OPEN BIT I/O BITS 0 1 00 01 10 11 00 01 10 11 0 1
Value
TYPE BITS
EOF BIT
= file not opened = file opened = no meaning = opened for input only = opened for output only = opened for input and output = none of the standard types = sequential = indexed sequential = direct = not yet end-of- file = end-of-file
Figure 8-9. Bit operators. NOTES: In general, n consecutive bits will provide 2 n possible meanings. There are two instructions that test bits, the test under mask (TM) and test and set (TS) instructions.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-10. Boolean Operators. NOTES: The Boolean operations OR, AND, EXCLUSIVE-OR have three characteristics in common: 1. They operate on two bit strings, each of same length. 2. Only one of the bit strings, the target, is altered. The other bit string, the mask, selects the individual bits that are to be altered in the target bit string. Each bit in the mask that is a 1 selects the correspondingly positioned bit in the target, regardless of whether that target bit is a 0 or a 1. 3. The Mask bit string is matched, bit for bit, with the target bit string: each bit in the mask operates on the corresponding bit in the target. The sign bit is not given any special treatment.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Mask Bit 0
Target Bit 0
Figure 8-11. The Boolean OR Operation. NOTES: The Boolean OR operation sets the selected target bits to1, regardless of what the previous values of those bits were.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-12. The Boolean AND Operator. NOTES: The Boolean AND operation preserves the value of the selected target bits and resets the remaining bits to zero, regardless of what the previous values of those bits were.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
1 1
0 1
1 0
Figure 8-13. The Boolean EXCLUSIVE-OR Operation. NOTES: The Boolean EXCLUSIVE-OR operation reverses the value of the selected target bits : If a selected bit was 0, it is set to 1; if it was 1, it is reset to 0.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
TESTING BITS
Two instructions test individual bits to determine whether their values are 0 or 1. Both of these test the bits of a byte in memory. The Two instructions that test individual bits in a byte are 1. Test under Mask (TM) 2. Test and Set (TS)
Figure 8-14. Testing Bits. NOTES: TM is the more generally useful of the two. It tests up to 8 bits at once, without altering the bits that are tested. TS tests only one bit- The higher order or sign bit of a byte and then sets all the bits in the tested byte to 1.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
TS
S1
16
Figure 8-16. Test and Set NOTES: The result of the test made by the TS instruction can be determined by means of conditional branch instructions: BZ Branch if Zero Branches if the tested bit had a value of 0 BNZ Branch if Not Zero Branches if the tested bit had a value of 1
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CONDITION CODE
The condition code is a hardware indicator that records the nature of results of certain instructions. The indicator consists of only two bits, only four possible conditions can be coded. These are known as condition code settings. 00 = Condition Code 0 01 = Condition Code 1 10 = Condition code 2 11 = Condition Code 3
Figure 8-17. Condition Code NOTES: The setting of the condition code can be examined and its value determined by two instructions designed for this purpose . 1.Branch on Condition (BC) 2.Branch on Condition via Register (BCR)
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Right-most bit denotes condition code 3 third bit denotes condition code 2 second bit denotes condition code 1 left-most bit denotes condition code 0 Figure 8-19. Condition code value. NOTES:
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-19. BC & BCR Mask field. NOTES: The variations are created by different values of the mask field and offen called Extended Mnemonics . Extended mnemonics are used so that we need not remember the appropriate mask field. For example, the instruction BE FOUND Is identical to the instruction BC 8, FOUND
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Miscellaneous
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
INTEGER OPERATIONS
Instruction Add A,AR,AH Subtract S,SR,SH Add AL,ALR Subtract SL,SLR condition code 0 result is 0 result is 0, With no carry (AL,ALR)only condition code 1 condition code2 condition code 3 result is negative result is positive operation generated an overflow result is not 0, result is 0, with no carry with carry result is not 0, with carry
Compare C,CR,CH both operands first operand less first operand Are equal than second greater than --Second Load LCR result is 0 result is negative result is positive overflow generated LNR result is 0 result is negative -- --LPR result is 0 --result is positive overflow generated LTR result is 0 result is negative result is positive - - Shift SLA,SLDA, result is 0 Generated SRA,SRDA result is 0 result is negative result is positive overflow result is negative result is positive ---
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BYTE OPERATIONS
Instruction Insert ICM condition code 0 condition code 1 condition code2 condition code 3 ---
all inserted bits 0, 1 st inserted bit is 1 1st inserted bit is Or all mask bits 0 0 but not all are 0 1st operand greater than second
Compare CL, both operands are 1st operand less CLR,CLC,CLI equal than second
---
CLCL operands are 1st operand less 1st operand greater equal, or have than second than second --zero lines CLM bytes selected are 1st operand field 1st operand field equal or mask bits less than second greater than second - - are all zero Copy MVCL first operand 1st operand length 1st operand length destructive length equals less than second greater than second overlap(no second operands bytes copied) Translate TRT all argument bytes one or more argu- such stopped on tested all function ment bytes not last argument byte --bytes 0 tested Figure 8-22. Byte Operations. NOTES:
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BIT OPERATIONS
Instruction condition code 0 condition code 1 condition code2 result is not 0 result is not 0 result is not 0 ------condition code 3 ------all selected bits are ones
all selected bits 0 some set bits are or all mask bits 0 0 and some bits are 1 left most bit of tested byte is 0 left most bit of tested byte is 1
---
TS
---
---
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DECIMAL
Instruction condition code 0 condition code 1 condition code2 result is negative condition code 3
both operands first operand less first operand great ------------Are equal than second er than second result is zero result is negative result is positive overflow generated
Shift
SRP
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
FLOATING POINT
Instruction condition code 0 condition code 1 condition code2 result is negative result is positive condition code 3 --------
Add AE,AER, mantissa of AD,ADR,AU, result is 0 AUR,AW,AWR AXR Subtract SE,SER mantissa of SD,SDR,SU, result is 0 SUR,SWR,SXR
result is negative
result is positive
Load LCER,LCDR result mantissa result is negative is 0. LNER,LNDR result mantissa result is negative is 0. LNPR,LPDR result mantissa I-------------is 0. LTER,LTDR result mantissa result is negative Is0. Compare CE, both operands first operand less CER,CD,CDR are equal than second Figure 8-25. Bit Operations NOTES:
result is positive -------result is positive result is positive first operand greater than second
----------------------------------
-------
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MISCELLANEOUS
Instruction condition code 0 condition code 1 condition code2 condition code 3 ----------
Compare CS, compared oper- compared operands And swap CDS ands equl,second not equal,first is one is replaced replaced Set pgm Mask Store clock SPM
---------
(the condition code is set to the value of bits 2 and 3 of the designated register) clock in error state last edited field is positive clock in stopped state or not-operational ---------------
Editing ED, last edited field last edited field is EDMK is 0. negative
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NONPRIVILEGED INSTRUCTIONS THAT DO NOT SET CONDITION CODE. Branches Branch and link Branch on Condition Branch on Count Branch on Index Multiply Divide Load Store Copy Translate Shift Logical BAL BALR BC BCR BCT BCTR BXH BXLE M D L ST IC TR SRL SLL MR DR LM STM STC SRDL SLDL BAS BASR
Integer Operations
Decimal Multiply Operations Divide Copy Floating-point Multiply Operations Divide Halve Round Load Store
Miscellaneous Decimal-binary Operations Conv. CVB CVD Decimal-EBCDIC Conv. PACK UNPK Execute EX Load Address LA Monitor Call MC Supervisor Call SVC Figure 8-27. Nonprivileged instructions that do not set the condition code. NOTES: Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BIT MANIPULATION EXAMPLES Bit Manipulation Instruction 1. Shift Instructions 2. Boolean Instructions 3. TM Instructions 4. The Conditional Branch Instructions
Figure 8-28. Bit manipulation examples NOTES: The shift instructions is used as a succinct method of multiplying and dividing by powers Of two, enable a program to separate and link adjacent bit strings. The Boolean instructions enable a program to isolate bits, to set individual bits to 0 or 1,and to reverse the settings of bits. The TM instruction provides an easy method for testing the values of individual bits, facilitating the use of status indicators and switches. The BC & BCR operations underlie the conditional branch instructions without which decisions could not be made by programs.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
STATUS BYTE
The Instantaneous status of a file is to be recorded in a single status byte, as follows: Bit name Bit position within byte OPEN IO 0 1,2 Value of bits 0 1 00 01 10 11 00 01 10 11 0 1 1 OPEN IO 3 5 TYPE EOF meaning = file is closed = file is opened = = = = no meaning opened for input only opened for output only opened for input and output
TYPE
3,4
= none of the standard types = sequential = Index sequential = direct = not yet end-of-file = end-of-file 6
EOF
Figure 8-29. Status Byte. NOTES: The whole byte is used for the status information, even though there are two unused bits in the byte. This serves two purposes. 1. It leaves a little room for defining other status bits at a later time. 2. It facilitates use of the bit manipulation instructions that can only address of whole byte.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-30. Definitions for a file-status byte. NOTES: Examples of using status bytes: When the file is opened OI FILESTAT, OPEN SET OPEN BIT TO 1 If the file is opened as an indexed sequential file OI FILESTAT, TYPISAM SET ISAM BIT TO 1 If it is necessary to determine whether the file is opened for output or input TM FILESTAT, IOOUT BO OUTPUT TM FILESTAT, IOIN BO INPUT ................ OUTPUT EQU * . INPUT EQU * SEE IF OUTPUT BIT IS 1 BRANCH IF IT IS 1 SEE IF INPUT BIT IS 1 BRANCH IF IS 1 file is opened for output file is opened for input
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
USE OF A STATUS WORD several bytes in the manner described as a full word or several full words. To use the full words the following techniques are used Setting Testing Resetting Inverting
Figure 8-31. Use of a status word. NOTES: Sometimes 8 bits are not used to enough to represent the status of a situation, for that we use several bytes in the manner of as a full word or several full words. In each bit corresponds to a terminal, the bits are numbered from left to right 0,1,2,3,.,31, and these numbers correspond to the terminal numbers. Each bit records the state of one terminal: if bit N is 0, then terminal N is not in use; if the bit N is a 1, then terminal N is being used.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-32. Testing or Resetting Bit N NOTES: It is assumed that BIT N is the half word location that has the value of N, that status is the location of the status word, and that pattern is a location that contains a one bit and position 0 and 0 bits everywhere else. PATTERN DC X 8 0 0 0 0 0 0
Once bit N is in position 0, it is isolated by the AND instruction using the pattern word. At this point, bit N is in an known position. It can be easily tested, reset, set, or inverted.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
To invert bit N, from 0 to 1 or vice versa these statements are suffice: LH L SRL X ST 2, BITN 3, PATTERN 3, 0 ( 2 ) 3, STATUS 3, STATUS R2= VALUE OF N R3= 1 IN POSITION # 0 MOVE 1 TO POSITION # N REVERSE BIT # N, PRESERVE OTEHRS PUT RESULT BACK INTO STATUS WORD
Figure 8-33. setting or inverting Bit N NOTES: Trace these situations for two different cases: (1) in which the Nth bit is originally 0 (2) in which the Nth bit is originally 1
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
EBCDIC
F0
F1
F2
F3
F4
F5
F6
F7
EBCDIC
F8
F9
C1
C2
C3 C4
C5
C6
Figure 8-35. conversion of hex digits to EBCDIC NOTES: In this example, the goal is to convert a sequence of eight arbitrary hex digits into their EBCDIC codes. Two things should be noticed in this solution: 1. The use of the double logical left shift in the statement 13 in the previous slide to isolate a hex digit in a register and simultaneously position the next hex digit for its eventual isolation 2. The use of the LA instruction in Statement 14 to compute the address of the correct EBCDIC byte, based on the numeric value of the hex digit.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 8-36. Translate from decimal to binary NOTES: 1.The so-called zone bits 1111 of the EBCDIC scheme must be removed for each digit. 2.The remaining bits of each digit, i.e., the bits that represent each digit in binary form, must be multiplied by the appropriate power of 10. 3.each of the product in step 2 must be added together to form the binary integer result.
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
TRANSLATING A NON-NEGATIVE INTEGER FROM EBCDIC TO BINARY 1 * THIS SET OF STATEMENTS TRANSLATES F NONNEGATIVE INTEGER 2 * FROM ITS EBCDIC REPRESENTATION TO ITS FULL-WORD BINARY 3 * REPRESENTATION 4 * 5 * THE EBCDIC REPRESENTATION IS ASSUMED TO BE EIGHT BYTES LONG, 6 * RIGHT JUSTIFIED, BEGINNING AT SYMBOLIC ADDRESS INT10. IT MAY 7 * HAVE LEADING ZEROES OR LEADING BLANKS 8 * 9 * THE RESULTING BINARY REPRESENTATION WILL BE STORED AT INT2 10* 11* INITIALIZATION 12 LA 2,INT10X R2 = ADDR OF LOW-ORDER BYTE 13 LA 3,P10 R3 = ADDR OF TABLE OF 10 * * N 14 LH 4, =H 8 R4 = MAX # DIGHTS TO BE TRANSLATED 15 LH 5, =H 0 R5 =ACCUMULATED RESULT (INITIALLY ZERO) 16 * 17 NEXT CLI 0(2), XF0 IF CURRENT BYTE VALUE NOT BETWEEN 18 BL DONE 0 AND 9 ( IN EBCDIC) THEN A LEADING 19 CLI 0(2), XF9 BLANK HAS BEEN REACHED 20 BH DONE 21 * MULTIPLY CURRENT DIGIT BY 10 * * N : 22 IC 7, 0 (2) PUT EBCDIC DIGIT INTO ODD-NUMBERED 23 N 7,PATTERN REGISTER, AND REMOVE ITS ZONE BITS. 24 M 6, 0 (3) THEN MPY BY CURRENT POWER OF 10, AND 25 AR 5, 7 ADD PRODUCT TO RESULT IN REG 5. 26 * 27 SH 2, =H+1 FOR LOOP CONTROL, ADJUST BYTE ADDRESS 28 AH 3, =H+4 TO NEXT DIGIT, AND TABLE ADDR TO NEXT 29 BCT 4, NEXT 10 * * N; THEN REPEAT UP TO EIGHT TIMES. 30 * 31 DONE ST 5, INT2 SAVE RESULTING BINARY INTEGER . . 32 INT2 DS F BINARY INTEGER RESULT (FULL WORD) 33 INT10 DS CLB EIGHT EBCDIC DIGITS, RIGHT- JUSTIFIED 34 INT10X EQU * - 1 ADDR OF LEAST. SIGNIFICANT EBCDIC DIGIT 35 PATTERN DC X0000000F MASK PRESERVES RIGHT-MOST FOUR BITS 36 * 37 P10 DC F1,10,100,1000 TABLE OF POWERS OF 10, I.E. Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
38
DC
F1E4,1E5,1E6,1E7
10 * * N FOR N = 0, 1, 2, . . . . , 7
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 8. Bit Manipulations 8-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
UNIT 9 : MACROS
OBJECTIVES : A sample macro Defining macros Use of control directives
Copyright MCPL. Unit 9. Macros Page 9- 1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Macro Definition
The set of statements that a macro represents must be defined before the macro can be used in a source module.some macros,such as GET and PUT I/O macros,are defined by system programmers and may be used by any assembly language programmers. A Macro is an opcode that represents a set of one or more assembly language instructions, directives, or other macros. It is a kind of high-level extension of assembly language.
Copyright MCPL. Unit 9. Macros Page 9- 2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure : 9-2 Macro-prototype statement NOTES: The second statement of the definition must describe the name, opcode and operand fields of the macro. This statement is termed as prototype statement or at times the model statement. Each positional parameter is represented by a variable symbol and each keyword parameter is represented by a variable symbol followed immediately by an equal sign.
Copyright MCPL. Unit 9. Macros Page 9- 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Name Field
Opcode
Operand
Blank
MACRO
Blank
Figure : 9-3 Macro - header statement NOTES: The first statement of the macro definition must be a MACRO directive, termed as Header-Statement. The definition of a macro can be included in the source module in which it is invoked, or placed in a separate file that's accessible to the assembler while it is assembling that source module.
Copyright MCPL. Unit 9. Macros Page 9- 4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
A SAMPLE MACRO
Example: A macro named ADD with the following property opcode operand ADD X,Y
Whenever the statement is written in a source module,the effect is equivalent to these three statements: L 5,X A 5,Y ST 5,X We can also write it as ADD ALPHA , BETA
NOTES :
The add macro such that we write any two valid symbols in place of ALPHA and BETA. It always causes Register 5 to be used,so that the previous number in that register is replaced by the result of the ADD macro. There must be exactly two symbols in the operand and,they must designate full-word integers. The number whose address is represented by the second symbol is added to the number whose address is represented by the first symbol;the sum is stored at the address represented by the first symbol.
Copyright MCPL. Unit 9. Macros Page 9- 5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
A MACRO'S DEFINITION
A MACRO'S DEFINITION
MACRO A B C
Header Prototype
Body
M E N D
Trailer
Figure 9-5 A Macro's definition NOTES: A = An optional variable symbol designating the namefield. B = The macro name or opcode C = Specifications of the operand X = An optional sequence symbol identifying the MEND statement.
Copyright MCPL. Unit 9. Macros Page 9- 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
EXAMPLE 1
EXAMPLE 1
MACRO &L &L ADD L A ST MEND &A, &B 5, &A 5, &B 5, &A
Figure 9-6 example 1 NOTES: The MACRO ADD processes two variables 'A' & 'B'. 'A' is loaded into the register 5. 'B' is added to the contents of Register 5. The third instruction stores the contents of register 5 to A.
Copyright MCPL. Unit 9. Macros Page 9- 7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
USE OF CONTROL DIRECTIVES The statements in the body of a macros definition can include any of the control directives. GBLx , SETx , AIF , AGO , ANOP RETURN Macro: The meaning of the RETURN macro is Return to the calling program after restoring all registers except the registers (if any) designated in the operand. The exceptions can only be Register 0,Register 15,or both Register 0 and Register 15.Thus there are four essential different ways to invoke the RETURN macro: RETRN RETRN 0 , 15 RETRN 15 RETRN 0 restores all registers restores all but R15 and R0 restores all but R15 restores all but R0
NOTES: Each of the invoking statements will cause the assembler to generate the corresponding
expansion for the return sequence.
Copyright MCPL. Unit 9. Macros Page 9- 8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
This determines whether the first operand field is present.If not, assembler skips to statement identified by the sequence symbol. AIF ((&r1 NE 0) AND (&R1 NE 15)).RERR When the first operand field is present, this determines whether its value is acceptable. AIF (&R2 EQ ).R3 When the first operand is present and its value is either 0 or 15,this determines whether the second operand is present. If it is not,the assembler skips to statement identified by the sequence symbol
AGO
.R2
Copyright MCPL. Unit 9. Macros Page 9- 9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MEXIT Directive The MEXIT directive instructs the assembler to stop its assemblytime processing of the RETRN macro. This directive is equivalent to an unconditional skip(AGO) to the MEND directive. Syntax: Name field Sequence symbol or Blank MNOTE Directive The MNOTE directive specifies a message that is printed on the listing and a severity code. Syntax: Name field Sequence symbol or Blank Opcode MNOTE Operand n, Opcode MEXIT Operand Blank
Severity code
Copyright MCPL. Unit 9. Macros Page 9- 10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Data Set
CLOSE macro
Figure 9-10 Vsam processing - Assembler NOTES: The ACB macro identifies the data set, type of processing and basic options. OPEN/CLOSE connect/disconnect application programs and the data set defined in the ACB. RPL macros define a request and specify the processing options for the request (e.g. DIR or SEQ access; LOC or MVE mode). A RPL identifies the data set to which the request is directed by naming the ACB macro that defines the data set. Request macros initiate a request and point to the RPL that defines the request.
Copyright MCPL. Unit 9. Macros Page 9- 11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ACB RPL
Figure 9-11 Creating acbs and rpls NOTES: GENCB generates a control block when the program is executed rather than when the program is assembled. The use of GENCB means that programs would not require reassembly with a new version of VSAM. GENCB allows you to generate multiple ACBs or RPLs. The instructions path length is longer with GENCB than with an explicit ACB or RPL macro.
Copyright MCPL. Unit 9. Macros Page 9- 12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
FILEA
ACB .MACRF = (processing option list). ADR I CNV I KEY DIR I SEQ I SKP IN I OUT NIS I SIS Record or CI access Access mode Input or Output Insert strategy
Figure 9-12 ACB MACRF parameter NOTES: NIS / SIS NIS (Normal insert strategy) is the default insert strategy. Splits occur in the middle of control intervals. SIS (Sequential insert strategy) is helpful for mass sequential insertions. Splits occur at the point of record insertion.
Copyright MCPL. Unit 9. Macros Page 9- 13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Record or CI access Access mode Forward or Backward LOCATE or MOVE mode Retrieval for UPDATE NOUPDATE
STUDENT NOTEBOOK
KEYED - SEQUENTIAL RETRIEVAL (FORWARD) INPUT RETRVE RPL ACB MACRF=(KEY, SEQ, IN) ACB=INPUT AREA=IN, AREALEN=100, OPTCD =(KEY, SEQ, SYN,NUP,MVE )
15, 15 ERROR
LOOP CL100
Figure 9-14 Assembler Error Handling NOTES: When an OPEN / CLOSE or request macro completes, VSAM always places a return code in register 15 indicating success or failure. The application program must check the return code. The corresponding VSAM reason code can be accessed using the SHOWCB macro.
The MVS/DFP Macro Instruction reference contains a list of reason codes that an error handling routine might interrogate.
Copyright MCPL. Unit 9. Macros Page 9- 15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
Copyright MCPL. Unit 10. Sequential Organization 10- 1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
Figure 10-1 Sequential organization NOTES: The processing of Sequential data sets always involves at least in three distinct phases. Initialization Phase: each data set opened and perhaps the first record is read. Main processing phase: each record is processed according to whatever criteria are appropriate to the problem. End-ofdata phase: the last output record remaining in main memory has to written and the data sets must be closed.
Copyright MCPL. Unit 10. Sequential Organization 10- 2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
The values coded for block size for IBM 3330 disk system for SYSIN and SYSOUT For SYSIN: RECFM=FB, LRECL=80,BLKSIZE= 4080 (51 records per block) RECFM=VB, LRECL=84,BLKSIZE= 4036 (48 records per block) For SYSOUT: RECFM=FB, LRECL=132,BLKSIZE= 4092 (31 records per block) RECFM=VB, LRECL=136,BLKSIZE= 4084 (30 records per block)
Figure 10-2. SYSIN and SYSOUT in OS Systems. NOTES: The SYSIN data set is a sequential data set created by the operating system. A special Form of the DD statement, either DD * or DD DATA, identifies the SYSIN data. Like SYSIN, the SYSOUT data set is a sequential data set created by the operating System. It is identified on a DD statement by the parameter SYSOUT =. Neither SPACE = nor DISP = can be specified for SYSOUT. To designate the block size for SYSIN and SYSOUT, choosing a value consistent with the device characteristics. Some computer installations use default values of block sizes for both these data sets. You should determine what block sizes should be specified at your computer installation. Unless stated otherwise, the above values will be coded.
Copyright MCPL. Unit 10. Sequential Organization 10- 3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
Figure 10-3. SYSIPT and SYSLST in DOS System NOTES: The above code specifies that SYSIPT data records will be read from an IBM 2540 card reader, with a single I / O buffer named INBUF, and that the name of the users end-offile routine is EOJ. Move mode is used due to the WORKA = YES parameter.
Copyright MCPL. Unit 10. Sequential Organization 10- 4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
NOTES :
Copyright MCPL. Unit 10. Sequential Organization 10- 5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
NOTES :
To process fields with in a logical record in locate mode, a DSECT defining the logical record fields must be established at assembly time. A dummy base register that points to the beginning of the DSECT area must also be established by means of a USING directive at assembly time, and the logical record address received from the GET Macro should be loaded in to the dummy base register at run time.
Copyright MCPL. Unit 10. Sequential Organization 10- 6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
PROCESSING VARIABLE LENGTH RECORDS Using the RDW Move Mode Locate Mode
Copyright MCPL. Unit 10. Sequential Organization 10- 7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
MOVE MODE
To process variable-length records in move mode can be code like this: COPYLOOP GET TRANSIN, CARD OBTAIN A LOGICAL RECORD LH 10,CARD LOAD RECORD LENGTH FROM RDW SH 10, =H 1 SUBT +1 FOR EXECUTE INSTR EX 10, VMVC MOVE RECORD FROM INPUT TO OUTPUT PUT TRANSOU, LINE AREAS, AND PUT IT INTO OUTPUT B COPYLOOP BUFFER. THEN GETNEXT RECORD. MVC LINE ( 0 ), CARD MVC FOR VAR-LNG MOVE. . . DCB . . . , RECFM=VB, LRECL=84, BLKSIZE =4096 DCB . . . ,RECFM=VB, LRECL= 136, BLKSIZE=4084 DFTCD . . ., RECFORM= VARUNB, BLKSIZE =84 DFTPR . . . , RECFORM=VARUNB, BLKSIZE = 136 DS CL94 DS CL136 DS 0H DS CL84 DS 0H DC CL136
Copyright MCPL. Unit 10. Sequential Organization 10- 8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
LOCATE MODE
COPYLOOP GET TRANSIN OBTAIN ADDRESS OF LOGICAL RECORD LR 9, GREG USE REG 9 TO SAVE INPUT RECDD ADDR MVC VRECL,0(9) GET LENGTH FROM RDW IN I /O BUFFER LH 10, VRECL LOAD RECD LNG FROM HALF-WORD AREA SH 10, =H 1 SUBT + 1 FRO EXECUTE INSTR EX 10, VMVC MOVE RECORD FROM INPUT TO OUTPUT PUT TRANSOU AREAS, AND OBTAIN ADDRESS OF NEXT LR 8, PREG OUTPUT RECORD. SAVE THIS IN REG 8 B COPYLOOP AND THEN GET NEXT INPUT RECD ADDR. VMVC MVC 0 ( 0, 8), 0 (9) MVC FOR VAR-LNG MOVE. VRECL DS H HALF WORD FOR RECORD LENGTH
Figure 10-6. Locate mode NOTES: In locate mode, the process of obtaining the record length should be modified. The Record length must be obtained from the record descriptor word (RDW) of the logical Record, i.e., from the first 2 bytes of the logical record area. The general case of blocked records (RECFM =VB or RECFORM = VAR BLK ) even though The DOS SYSIPT and SYSLST files do not permit blocked records. The same method can be used for any file(DOS or OS ) in which blocked records are permitted. The method Consists of moving the first 2 bytes of the RDW to a temporary area that is aligned on a half-word boundary, so that the LH (Load Half Word) instruction can be used whether we have An IBM 360 or IBM 370.
Copyright MCPL. Unit 10. Sequential Organization 10- 9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
PRINTER OUTPUT
Printer output : Page and Line spacing ; Date and Time macros Carriage control Title lines
Figure 10-7. Printer output NOTES: The first character of each logical record written to the system out put data set can be used to control printer line-spacing. The most common space-control functions are to single space, double space, triple space, suppress spacing and skip to new page. Control character is simply one of the 256 EBCDIC characters. There are two different sets of control characters, ANSI and IBM machine code characters. In OS , the choice of control character set is designated in the RECFM=parameter of the DCB macro. The ANSI set is designated by letter A, the IBM set by letter M: RECFM=FBA or VBA, or RECFM=FBM or VBM.
Copyright MCPL. Unit 10. Sequential Organization 10-10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
TITLE
The logical record area for the title could be defined as TITLE DS CL133 SPACE FOR TITLE LINE ORG TITLE BEGIN REDEFINITION FOR FIELDS DC XF1 ANSI CTL CHAR FOR TOP OF NEW PAGE DC CL14 BLANKS TO CENTER THE TITLE *FOLLOWING IS SOME APPROPRIATE TITLE,WITH TRIALING BLANKS DC CL90 LISTING OF SYSIN DATA MONTH DS CL2 SPACE FOR TWO-DIGIT MONTH DC C/ DAY DS CL2 TWO-DIGIT DAY OF MONTH DC C/ YEAR DS CL2 TWO-DIGIT YEAR DC CL11 SPACING FOR READABILITY DC CPAGE PAGE DC CL4 UPTO FOUR-DIGIT PAGE NO. ORG
Figure 10-8. Title NOTES: The title line must be printed each time the line-number counter reaches the limit established for number of lines per page. A logical record area must be defined to include the title space for the date and page number, and the top of page control character. A page-number counter must be maintained and converted to EBCDIC format each time a new page is to be started.
Copyright MCPL. Unit 10. Sequential Organization 10-11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
The COMRG and GETIME Macros Date and Time in DOS Opcode GETIME COMRG Operand
NOTES:
To obtain the date and time in DOS two separate macros are needed, GETIME and COMRG GETIME macro returns the time of day in register 1 as a signed packed decimal number. The COMRG macro returns the address of the date rather than the date itself. The address is returned in register 1, and the field that points to is known as communication region , of which the first 8-bytes contain calendar date in EBCDIC format , stored as mm/dd/yy.
Copyright MCPL. Unit 10. Sequential Organization 10-12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
Cols 62-70:std-id
1 4
8 12 16
21
60
62
71 80
NOTES:
The information to be maintained for each dorm room is the dorm identity and room number, and the names of the students who are assigned to that room. Since the data set will contain the information that we want to know and maintain about dorm room capacity is known as master file. The data set used to create or update the master file is known as transaction file. To process the master file as a sequential data set, we require that its logical records be in some useful sequence and that the logical records of the transaction file be in the same sequence. The dorm field in each record is thus referred to as the major field for sequencing and the room number field as the minor field. Each dormitory is identified by a one-to four character abbreviation, all of which be letters. Each dormitory room number consists of one to four letters or digits.
Copyright MCPL. Unit 10. Sequential Organization 10-13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDEN
Copyright MCPL. Unit 10. Sequential Organization 10-14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 1 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Queued Indexed Sequential Access Method (QISAM) Basic Indexed Sequential Access Method (BISAM) Indexed Sequential Access Method (ISAM)
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 2 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 3 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Used to create an Indexed Sequential Data Set in OS. Used to update records in place via PUTX in UPDAT Mode. Used to add the records to end of the data set via PUT in EXTEND Mode.
Figure 11-3. Queued indexed sequential access method (QUISAM) NOTES: QISAM is access method used to create the indexed sequential data sets, update the records, insert the records and delete the Records from sequential data set. The processing steps used with QISAM are similar to QSAM but Some significant differences between them.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 4 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
QISAM records can be deleted when updating in place. This is accomplished by using the first byte of each logical record as a delete flag.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 5 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
The DSORG parameter must always be coded as DSORG = IS for QISAM. Move mode or locate mode buffering can be used INPUT Mode the MACRF Parameter
Figure 11-5. Dsorg and macrf parameters NOTES: The RECFM, LRECL, and BLKSIZE parameters should be coded only when creating the data set, not when updating or retrieving from it. Move mode or locate mode buffering can be used , but the other buffering options available with QSAM processing data mode, substitute mode , and exchange buffering are not permitted with QISAM When retrieving record in INPUT mode, we must specify in the MACRF Parameter whether or not the SETL macro will be used by coding MACRF=(GM,SK) or (GL,SK)
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 6 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Used to update or retrieve the records but not to create an Indexed Sequential Dataset. Deleted records Synchronization Open Macro DCB Parameters
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 7 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Create an Indexed Sequential File. Extend an Indexed Sequential File. Update a file in Sequential Mode. Update a file in Random Mode.
Figure 11-7. Indexed sequential access method NOTES: We must use WRITE macro with IOAREAl = buffer area and specify IOROUT = LOAD in the DTFIS macro. Follow the OPEN macro with a SETFL(Set File Load Mode) macro and precede the CLOSE macro with an ENDFL (End SETFL) macro. Record must be written in ascending key sequence. To create a file: //DLBL dtfname ,filename,date,ISC,..
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 8 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
INDEXED SEQUENTIAL ACCESS METHOD Create an Indexed Sequential File. Extend an Indexed Sequential File. Update a file in Sequential Mode. Update a file in Random Mode.
Figure 11-8. Indexed sequential access method NOTES: To add records in ascending key sequence beyond the previous last record of the file, use the procedure and parameters as when creating the file. Difference between creating and extending is indicated in a users program it specified in the //DLBL JCL statement. To create a file: To extend a file: //DLBL dtfname ,filename,date,ISC,.. //DLBL dtfname ,filename,date,ISE,..
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11- 9 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
INDEXED SEQUENTIAL ACCESS METHOD Create an Indexed Sequential File. Extend an Indexed Sequential File. Update a file in Sequential Mode. Update a file in Random Mode.
Figure 11-9.Indexed Sequential Access Method. NOTES: In sequential Mode, we can choose between updating in place and general updating procedures.
Updating in place is restricted to changing data field contents(but not the key field), and is specified via IOROUT=ADDRTR and TYPEFLE = SEQNTL in the DTFIS macro.
It uses GET and PUT macro to retrieve a record and to write a record respectively. In random mode, generalized updating is permitted by specifying IOROUT = ADDRTR and TYPEFLE = RANDOM. New records can be inserted in their proper key-sequenced position without creating a new file. There is no provision for deleting records in random mode
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-10 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
SPACE ALLOCATION
Figure 11-10. Space allocation NOTES: Secondary memory space for an indexed sequential data set is generally allocated in three distinct areas: the prime data area, the independent overflow area and the cylinder index area. In OS systems , the space allocation depend on the SPACE= parameter of the DD statement is coded. In DOS systems , the space allocation is done by //EXTENT statements.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-11 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
X Figure 11-11. Space allocation for ISDS in OS systems NOTES: Fig1: Prime area = P cylinders with index at its end ; partially used index cylinders used for independent overflow. Fig2: Prime area = P cylinders with X cylinders as embedded index; partially used index cylinders are independent overflow areas.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-12 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
W p w
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-13 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
P //ddname DD DSNAME=dsname(INDEX), // DISP=(NEW,KEEP) , // SPACE=(CYL,(X), ,CONTIG) // DCB=DSORG=IS, // DD DSNAME=dsname(PRIME), // DISP=(NEW,KEEP), // SPACE=(CYL,(P), ,CONTIG), W X // DCB=*.ddname,.. // DD DSNAME=dsname(OVFLOW),DISP=(NEW,KEEP), // SPACE = (CYL,(W), ,CONTIG),DCB=*.ddname. Figure 11-12 Space allocation for isds in os systems NOTES: Fig1: prime area = p cylinders: index area = x cylinders, with partially used Index cylinders used as independent overflow area. Fig2: prime area = p cylinders: index area = x cylinders : independent overflow area = w cylinders.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-14 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Relative track number where space allocation begins. Number of consecutive tracks in the space allocation.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-15 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
480
120
180
380
405
425
FF 480
Overflow track Figure 11-14. Adding records to an indexed sequential data set NOTES: Records existing before addition of new records assuming one block/track with 5 records/block and record 480 flagged for deletion
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-16 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
SPACE REQUIREMENTS
For the IBM 3330 system the track capacity formula is 13165 191 + KL + DL
Number of blocks per track = Index space requirements. Prime space requirements.
Figure 11-15. Space requirements NOTES: KL - Key Length. DL - Data Block Length. L - Logical record length. B - Block Size. R - Estimated Number Records. N - Number prime data Blocks required = (L*R)/B. M - Blocks per Tracks. P - Prime data tracks per cylinder.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-17 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Figure 11-16. Creating an indexed sequential data set NOTES: To create an Indexed Sequential Data Set : The length and position of the key field must be the same in all logical records of the data set. Some DCB parameters and DTFIS parameters are required.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-18 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Figure 11-17 Principal dcb parameters NOTES: BLKSIZE,CYLOFL,KEYLEN,LRECL,NTM,OPTCD,RECFM And RKP can only be specified when creating an indexed sequential data set. They cannot be specified when updating or retrieving from the data set.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-19 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-20 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Byte 0 - 1: byte deletes flag Bytes 1 - 4: 4-byte dorm abbreviation} Bytes 5 - 8: 4 byte room number} record key field
Id Student name (9) (40 bytes) Space used whether needed or not
Id (9)
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-21 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Id Student name (9) (40 bytes) Space not used unless needed
Id (9)
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-22 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Figure 11-21. Updating in sequential mode NOTES: Inserting new is not usually performed sequentially because new records cannot be inserted into an existing data set using sequential mode which requires overflow area.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-23 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Open the data set in EXTEND mode. DISP=(MOD,KEEP) in DD statement. Specify the MACRF parameter in DD statement and use PUTX macro.
UPDATING
DELETING
OPTCD=L and Move XFF in to the delete-flag and rewrite the record.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-24 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
UPDATING
DELETING
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-25 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Include the BUFNO=parameter in DCB macro. For read a record READ macro is READ KU.
For rewrite a record WRITE macro is WRITE K. For new record WRITE macro is WRITE KN.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-26 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Figure 11-25. DOS random mode processing NOTES: The buffer used for adding new records is indicated by the IOAREAL=parameter. IOAREAR=parameter indicates buffer used for retrieving and updating existing records. WORKR=parameter indicates logical record work area.
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-27 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
MAIN PROCESSING Move the key of the current transaction record to the area that is designated by the key address parameter in an OS read or write macro and by the KEYARG=parameter in DOSDTF macro. END-OF-DATA INVALID KEY
Figure 11-26 Updating in random mode NOTES:
Copyright MCPL. Unit 11. Indexed Sequential Organization Page 11-28 Course Material may not be reproduced in whole or in part Without the prior permission of MCPL.
STUDENT NOTEBOOK
Access Method Services Basic I/O macros Loading a VSAM Data set Updating an Entry-Sequenced Data Set Updating a Key-sequenced Data Set Alternate Indexes
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 12 -1 VSAM (virtual storage access method) NOTES: The Virtual Storage Access Method has been designed for several purposes;It is intended as a replacement for OS and DOS Indexed Sequential Access Methods (QISAM,BISAM;ISAM). It may also be used instead of the OS and DOS Sequential Access Methods (QSAM, BSAM;ISAM).It can used in DataBase Management Applications such as IBMs Information Management System (IMS). The Access Method Services Utility Program (AMS) provides means of creating VSAM Data Sets, and the VSAM I/O provides a variety of processing option.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
VSAM DATASETS
VSAM provides support for three types of Datasets. Entry-Sequenced Data Sets (ESDS) Key-Sequenced Data Sets (KSDS)
NOTES:
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
RECORD1
RECORD2
RECORD3
UNUSED SPACE
R D F
Figure 12-3 ESDS NOTES: ESDS records are stored in a data set in the sequence in which they are presented to the operating system. In this sense the sequencing of ESDS records is analogous to that of sequential data-set records ESDS has only a data component it contains fixed length or variable length records. New records are only added at the end of the dataset, existing records can never be deleted, but they can be updated. Access Methods: 1. Sequential Access 2. Direct Access by means of relative byte address (RBA)
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 12-4 RRDS NOTES: RRDS consists of a number of preformatted fixed-length slots. each slot has a unique relative record number, and the slots are sequenced by ascending relative record number. Each record occupies a slot, and is stored and retrieved by relative record number (RRN). Access Methods: 1. Sequential Processing 2. Skip-Sequential Processing 3. Direct Processing by means of relative record number (RRN)
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SS 1
SS 2
SS 3
CA3
CI 1 CI 2
SS 4
CA4
CI 1 CI 2
SS
SS 6
CA6
CI 1 CI 2
CA2
CI 1 CI 2
CA5
CI 1 CI 2
Figure 12-5 KSDS NOTES: KSDS has a data and an index component, it contains fixed length and variable length records. KSDS records are stored in a data set in ascending key sequence. The key field that controls sequencing is known as the primary Key field. In this sense the primary key and sequencing of KSDS data records are analogous to those of indexed sequential data set records. Access Methods: 1. Sequential Access 2. Direct Access by means of key 3. Skip sequential access
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LR
(M<=19) Tracks LR LR LR
Figure 12-6 VSAM building blocks NOTES: LR = Logical Record A logical record is a unit of information used to store data in a VSAM data set. CI = Control Interval VSAM uses CI s to contain records. Whenever record is retrieved from DASD, the entire CI containing the record is read into VSAM I/O buffer in virtual storage. CA = Control Area The CIS in a VSAM data set are grouped together into fixed-length contiguous areas of direct storage called CAS.A VSAM data set is composed of one or more CAs.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
1 L1
2 L2
3 L3
n Ln UNUSED SPACE
RDFn
Rdf2 Rdf1
CONTROL INFORMATION
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
2 L
2 U
TOTAL LENGTH OF RECORDS SPACE 1 THRU n 1 X00 RDFk = RECORD DEFINITION FIELD FOR RECORD K Figure 12-8 RBA and CIs continue.. NOTES :
LENGTH OF UNUSED 2 Lk
LENGTH OF RECORD K
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
X08
L2
L1 1
L2 2 3
L3
L2
Ln n
RDFn RDF
2RDFS
Figure 12-9 RBA and CIs continue.. NOTES: VSAM always uses the RBA to determine a records location in a dataset. But except in certain advanced applications of VSAM, RBAs are not normally needed by user programs to access records.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DELETE Deletes one or more VSAM objects and their catalog entries LISTCAT List information contained in a VSAM catalog PRINT Prints the contents of a VSAM data set or of a sequential or Indexed-sequential data set REPRO Copies a VSAM or sequential or indexed sequential data set Into another catalog VERIFY Verifies and corrects certain information about a data set in a catalog
Figure 12-10 AMS command summary. NOTES: AMS is the VSAM Utility program, executable under the name IDCAMS in both OS and DOS systems. The most important of its functions are : It defines VSAM catalogs and data sets and allocates space for them. It loads VSAM data sets from the input data stream and from other NON-VSAM data sets. It prints the contents of VSAM catalogs and data sets
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
BLDINDEX Initially loads a newly defined alternate index CHKLIST List tape data set that were open at the time a checkpoint was taken (OS only) CNVTCAT Converts OS catalog entries into VSAM VSAM catalog entries (OS only) EXPORT Unloads a VSAM base cluster or alternate index , together with its catalog entry, onto a movable storage volume; alternatively, copies a user catalog onto a movable volume and then disconnects that catalog from the systems master catalog
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -12 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
RESETCAT
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -13 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -14 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CDC
EFG
KLA
USA
XYZ
C O
N T R O L I N T E R V A L
BDE
BRO
CDC
CRA DA B
AA A
AB C
BDE BRO
E F G C R A D A B
EFG
W X Y
X A B
XY Z
WX Y XA B
CDC
XY Z
CONTROL AREA Figure 12 13 Data component and Index component. NOTES: Like the logical records in a control intervals the entries in a index record are stored in ascending prime key sequence. The imbedded index sequence set (the lowest level index) contains the highest key and a pointer for each control interval that contains data in the control area that the sequence set pertains to. Each higher-level index contains the highest key and the pointer for each of the immediately lower-level indexes that pertain to.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -15 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Executable Control Block Macros GENCB MODCB SHOWCB TESTCB Generates the same information that an ACB, EXLST, or RPL macro does so at run time rather than assembly time Modifies the contents of any of the control blocks that were generated by ACB,EXLST,RPL, or GENCB Obtains the contents of one or more fields of any control block Tests the contents of any one of the fields in a control block
Figure 12-14 VSAM Macro summary NOTES: As in sequential and indexed sequential assembly language I/O programming, VSAM I/O programming is accomplished via macros. Types of Macros: 1. Request Macros 2. Control Block Macros Control Block Macros are used to create, modify, obtain or test selected fields of the control blocks. The control blocks themselves are similar in purpose to the DTFxx areas in DOS and the DCP areas in OS systems. The provided information is used at run time by the operating system. The information generated by the ACB, RPL and EXLST macros in both DOS and OS systems.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 12-15 VSAM Macro summary continue. NOTES: Request Macros are designed to be executed at run time. They initiate actions such as opening a dataset and retrieving and updating records.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -17 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
PUTIX
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -18 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -19 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
acbname
ACB
rplname
RPL
.ACB = acbname,
existname
EXLST OPEN
(acbname)
RPL = rplname
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -20 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
MAREA = addressnames an area to receive OPEN/C error messages MLEN = length Specifies length of the MAREA area
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -21 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 12-20 ACB Macro summary continue. NOTES: The ACB Macro must be referred to when opening and closing a VSAM data set. The Basic option specified in an ACB are these : The identity of an OS DD statement or DOS DLBL statement that in turn identifies the VSAM data set to be processed and their anticipated logical record accessing modes. The other options may be specified in an ACB are the buffer space requirements for reading and writing CONTROL INTERVALS and the address of the EXLST Macro that pertains to this ACB. If needed password also can be specified.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -22 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NRS | RST
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -23 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 12-22 ACB Macro summary continue NOTES: Permission to process a VSAM data set must be requested at run time by an OPEN macro. The macro must in turn specify the address of an ACB macro by describes the anticipated processing requirement. All the accessing mode that are going to used while the data set is being processed must be specified in the ACB macro.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -24 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
KEYLEN = k RECLEN = r OPTCD = (optcd-options) Figure 12-23 Rpl macro parameters NOTES:
The RPL Macro must be referred to each time any macro other than the OPEN or CLOSE (or GENCP) is executed at run time. The basic options specified in an RPL are these: the name of the ACB that the RPL is associated with; the address and length of the I/O record work area; the record accessing mode to be used for a particular request; the address of the search argument for direct accessing and for record positioning; and whether or not the request is for updating a record.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -25 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -26 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OPTCD-OPTIONS
KEY | ADR | CNV SEQ | DIR | SKP MVE | LOC NUP | UPD | NSP KEQ | KGE Keyed, addressed, or control-interval access Sequential, direct, or skip-sequential access Move mode or locate mode Is not for update, is for update, or note sequential position With keyed access, find the first record with a key that is either equal to, or greater than or equal to, the search key Specifies whether the search key is a full key or a generic key Record accessing is either in the forward or the backward direction; if BWD, then KEQ and FKS are assumed
Figure 12-25 OPTCD - OPTIONS NOTES: Defaults for all optcd-options are specified above as the first choice each group of two are three options.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -27 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OPTCD-OPTIONS (CONT)
ARD | LRD ARD: record accessing is as specified in other parameters; LRD: locate or retrieve the last record in the data set (BWD) Synchronous or asynchronous accessing Specifies whether or not to give control to the users UPAD error-exit routine to synchronize processing of shared resources
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -28 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
abbreviated DEF MCAT DEF UCAT DEF SPC DEF CL DEF NVSAM DEF AIX DEF PATH
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -29 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DEFINE CLUSTER
General Format DEFINE CLUSTER(cluster options) DATA (data options) INDEX (index options) CATALOG (catalog options)
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -30 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CLUSTER OPTIONS
NAME (entry name) VOLUME (volser) CYL (p s) |TRK (p s)|REC (p s) Specifies the name of the cluster Identifies the volume where the Cluster will reside Specifies the amount of space to be Allocated; p is the primary allocation, the secondary Identifies the DD or DLBL statement linked to the cluster NONINDEXED means its an ESDS; INDEXED means its a KSDS Specifies whether or not it is a Reusable data set Specifies whether the data set shares a Suballocatable data space or is allotted (KSDS only) specifies whether or not to Imbed the index sequence Set
FILE (dname) NONINDEXED | INDEXED NOREUSE | REUSE SUBALLOCATION|UNIQUE NOIMBED|IMBED Figure 12-29 Cluster options NOTES:
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -31 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -32 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CATALOGNAME / PASSWORD Identifies the name of the catalog in which the cluster is to be defined and specifies the password (if any) required to update the catalog; the slash / between catalogname and password must be included if a password is specified
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -33 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
/*
Figure 12-32 Repro command NOTES: The AMS REPRO command can be used to load a new VSAM data set with records obtained from a non-VSAM dataset. The VSAM dataset that is loaded by REPRO must have been previously defined by the DEFINE command. The sequential is the input to the REPRO command and the output is a KSDS cluster.
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -34 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -35 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -36 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -37 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 12-36 JCL control for alternate index. NOTES: An Alternate Index enables records in an ESDS or KSDS base cluster to be identified and accessed by key. The key is known as Alternate key, to distinguish it from the prime key of KSDS cluster
Copyright MCPL. Unit12. VSAM (Virtual Storage Access Method) 12 -38 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Cross-references
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Figure: 13-1 Assembler input and output NOTES: The machine language representation of source module is produced by the assembler and stored in an object module. Assembler produces a listing that correlates the source and object module contents and provides certain diagnostic information.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Figure 13-2. Two pass assembler NOTES: The entire source module is processed twice in succession, statement by statement. PASS 1 is a mechanism that assigns values to symbols and address to literals. PASS 2 is a mechanism that creates the object module, the listing and related information. For a two pass assembler, a symbol must be defined prior to its occurrence in an EQUs operand. The assembly processes depend on the information represented in tables. Some of these tables generated as part of the assembler source module, some at assembly time. The two pass assembler mechanism depicted in diagram and the tables will discussed in later sections.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Opcode table PASS 1 Source Module P R O C E S S I N G Directive table ESD Symbol table TXT Literal table Base register table 2 P R O C E S S I N G Listing PASS Object module
RLD
Intermediate file
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Figure 13-4. Fundamentals of the assembly process NOTES: The assembler to carry out the process from the source module to object module it needs descriptions of instructions and directives, determine and remember the value of symbols, identities and addresses of literals and base register and base address. Table is a collection of data arranged in some order so that the data items are relatively easy to locate and process. the simplest form of the table is single dimensional integer array in which each integer is an entry of the table. Table entries contain more than one data item; among the items is a key that identifies the entry.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Assembler is complex program written in assembley language that requires number of statements, instruction codes, instruction formats and base registers to handle the users source module. In IBM 360 and 370, there are 150 instruction codes, 50 directives, 7 instruction formats and 15 data type codes. But frequently used are mentioned above.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
OPCODE TABLE
0 0 0 0 0
0 1 1 0 6
1 Byte
Flags binary 000000 001000 001000 001000 001000 000000 000000 000000 010000
XR ZAP
17 F8
0 0
0 6
01 11
000000 010000
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
4=S 5 = SS1
Extended mnemonic Store clock Extended precision floating point Floating point Packed decimal Unused bit Figure : 13-7 Opcode table cont.. NOTES: Opcode table describes the instructions will be defined for Assembley process. Each Entry in the table consists 8-bytes that are divided into 5 items or Fields. Mnemonic instruction code: 5-bytes key field. Entries are in ascending sequence by the value of this field. Machine language opcode: 1-byte information of instructions type and length. Mask field: defines conditional branch instructions. Other information in a table represented by the 1-bit flag fields.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
DIRECTIVE TABLE
5 Bytes Mnemonic Directive CACTR CAGO CAIF CANOP CCNOP CCOM CCOPY CCSECT 1100 CTITLE CUSING CWXTRN CDC
3 Bytes Address of processing routine AL3(DIRACTR) AL3(DIRAGO) AL3(DIRAIF) AL3(DIRANOP) AL3(DIRCNOP) AL3(DIRCOM) AL3(DIRCOPY) AL3(DIRCSECT) AL3(DIRCXD) C AL3(DIRTITLE) ) AL3(DIRDC AL3(DIRUSING) C AL3(DIRWXTRN) X D
Figure: 13-8 Directive table format NOTES: Directive table is used to process the directives and to determine the given character string represents a valid directive or not. It contains the address of the routine within the assembler that process each directive. Each directive has its own processing routine.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
SYMBOL TABLE
8 bytes Symbol
Value
4 bytes
| 2 bytes
| 2 bytes
| 1 byte | 1byte
Length attribute Statement number Control section number Relocatable / absolute indicator
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 10 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
LITERAL TABLE
2 String length
Figure: 13-10 Literal table format NOTES: A Literal is entered in to the Literal table, when it is obtained from an instructions operand field in PASS1. Addresses are assigned to any literals in the table when an END or LSTORG directive is processed. In IBM 360 and 370 systems, the first address assigned to a literal is always on a Doubleword boundary.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 11 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
1 Byte
| 1 Byte
USING DROP
Figure: 13-11 Base register table NOTES: The entries in the table reflect the information from the USING and DROP directives. To allow for the designation of symbolic base registers and symbolic base addresses and entries are not made in this table until PASS2. USING directive causes an entry to be made in the table for each base register designated in its operand. DROP directive causes entries to be deleted. To compute a base displacement address corresponding to a relocatable symbolic address, the assembler chooses the base register whose base address is in the same control section as the symbolic address.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 12 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
INTERMEDIATE FILE
1 3 T y pe MLC
| Source statement
variable length
Figure: 13-12 Intermediate table format NOTES: Each entry in the intermediate file is created in PASS1, PASS2. The sequence of the entries is the same as that of the statements in the source module. Each entry contains a copy of a source module statement plus some additional information determined in PASS1. It includes the MLC at the time the statement was processed.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 13 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 14 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 15 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 16 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
TABLE SEARCHING
Table search is mainly divided into two types: Linear search Binary search
Figure 13-16. Table searching NOTES: Table search is a processing technique to find the table entry. This search consists of two types linear search and binary search.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 17 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
LINEAR SEARCH
LINEAR_SEARCH: J := 1; REPEAT WHILE J <= Number of entries in table IF search-key = key of Jth entry of table THEN {key found in Jth entry} EXIT LINEAR_SEARCH; END IF; Increase J by 1; END WHILE; {key not found} EXIT LINEAR_SEARCH.
Figure 13-17. Linear search NOTES: Linear search is start searching from the first one until the desired entry is found. Linear search is simple to implement but it is time-consuming when there are large number of entries in the table. Linear search requires half the time of the entries that is if there are N entries then average time is A(N/2).
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 18 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
BINARY SEARCH
BINARY_SEARCH: {set initial group to entire table} LOWPT := 1; {first entry} HIPT := M; {number of entries in table} REPEAT WHILE LOWPT < HIPT MIDPT := integer portion of (LOWPT + HIPT)/2; {index of current middle} IF search_key = key of entry of table at position MIDPT THEN {key found in MIDPT entry} EXIT BINARY_SEARCH: ELSE IF search_key < key of entry of table at position MIDPT THEN HIPT := MIDPT 1; {use lower half of current group} ELSE LOWPT := MIDPT + 1; {use upper half of current group) END IF; END IF; END WHILE; IF LOWPT = HIPT THEN {one entry remains to be checked} IF search_key = key of remaining entry of table THEN {key found in MIDPT =/- entry} EXIT BINARY_SEARCH; END IF; END IF; {key not found} EXIT BINARY_SEARCH. Figure 13-18. Binary search NOTES:
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 19 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 20 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
A(N/2) B(LOG2)/N
Figure: 13-19 Binary Vs Linear NOTES: For linear search, there are N entries, the average search time will be more A (N/2) Where A is a function of the speed of the computer and of the number and type of instructions used in each iteration of the search procedure. The average search time using the Binary search technique B (log2/N)
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 21 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
SORTING TABLES
Internal sorting External sorting Straight insertion sort Other sort techniques Criteria for best sort
Figure 13-20 Sorting tables NOTES: Sorting involves rearrangement of entries into some prescribed order in the table. The sorting is based on the some property of the each entry. Property is a value of one or more fields of an entry. All the entries that are to be sorted can fit in main memory through the processing called Internal sorting. The number of entries is so large that only a portion can be in main memory at on time, the rest being in secondary memory, the process is known as external sorting There is no known best way to sort an arbitrary set of data in an arbitrary chosen system. The best situation would be one that used least amount of time and least amount of memory space. This is depending on the system, on the instructions used in the algorithm, how many entries are to be sorted and how badly out of sequence.
Copyright MCPL. Unit 13. Assembly Concepts Page 13 - 22 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
INSERTION_SORT REPEAT FOR j = 2 to n k = key from record j r = copy of record j i=j1 { i will be the position of the left of the inserted jth record } REPEAT WHILE ( I > 0) AND ( k < key from record j) Move record i to record i+1 Subtract 1 from i END WHILE Move r to record i + 1 END FOR EXIT-INSERTION_SORT
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 23 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Figure 13-21 Other sort techniques NOTES: Merge technique, which combine two or more already sequenced subset of entries to produce a new sequenced subset and continue in this way until all the sequenced subsets have been merged into one, which is the final sorted table. Distribution technique, in which a portion of each is examined and the entries separated into subsets, one for each different value of key portion being examined. A different portion of key is then used and the process repeated, maintain the order of the entries that was established by the previous distribution. Continue this process until the final portion of the key has been examined. The final subset produced consists of all the entries in sequence.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 24 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
CROSS REFERENCES
SPACE CONSIDARATIONS: How many tables are there and how much space should be reserved for each table. LIST and PRINTERS CROSS REFERENCE LIST STRUCTURE
Figure 13-22 Cross references NOTES: Cross referenced information for a source module: the statement numbers of all statements in which the symbol appears in an operand field, in order that they can be printed at the end of PASS2. To get this information would be to have one cross reference table for each symbol. But it poses space consideration problems because we dont know how many symbols there will be in a given source module until that module is processed. To resolve these problems with a scheme called list. LIST is set of entries that may be scattered in memory, instead of being consecutive as in a table. Each list entry contains at least one field that is used in locating another entry of the list. The content of that field is called Pointer. POINTER can be an address or any other number that can be used in calculating an address.
Copyright MCPL. Unit 13. Assembly Concepts Page 13 - 25 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
# 1 5 2 6 3 8 4 11 5 12 6 15
2 5 6 0 4 0
Figure: 13-23 Cross-reference tables. NOTES: The entries would be place in cross reference table in pass2 of the assembler when the corresponding intermediate file is processed. The list structure has these properties. Each entry consists of two fields of 2 bytes each. Statement number field: identifies the statement in which the cross reference occurs. Pointer field: identifies the next entry in the structure that contains the cross reference for the same symbol.
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 26 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Student Notebook
Copyright MCPL.
Unit 13. Assembly Concepts Page 13 - 27 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
Figure 14-1. Internal subroutines NOTES: Subroutine is a set of statements that may be used at one are more points in a computer program to perform some task of that request of that program. An internal subroutine is one whose statements are contained within the requesting program at assembly time. An external subroutine is one whose statements are assembled separately from the requesting program. Alternative names for the concept of a subroutine are subprogram and procedure.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
TERMINOLOGY
Calling and called programs. Program P. Instructions and Data of Program P Called Program P calls Q Q returns to Ps re-entry point Program Q. Instructions and Data of Program Q. Calling Program
Q returns to P to P
Figure 14.2 Terminology NOTES: When a program requests that a subroutine perform its task, it is said to call that subroutine. The program making the request is known as the caller. The subroutine requested to perform the task known as the called program. The address of the first instruction executed by a subroutine when it is called is the subroutines entry point. The address of the instruction to which a subroutine branches is called is the subroutines entry point. A closed subroutine is one written in such a way that a single copy of it is all that is required, no matter how many places it is used in a program.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
LINKAGE Calling a Subroutine Returning from a Subroutine RR type Branches BALs Rentry Register
NOTES:
A closed subroutine can be called from any number of different places within in program, the caller has to be able to specify reentry point to which the subroutine will return. In IBM 360 and 370 systems, there are two instructions that do this: an RR-type Branch and Link via register(BALR), and an RX-type Branch and Link (BAL) instruction. The RRtype BALR instruction will be needed when calling external subroutines. To use BAL, the subroutines central point is specified symbolically in second operand: BAL R1, Symbol BR instruction branches to the address contained in the register specified in its operand. By using this instruction, a subroutine is able to branch to whatever re-entry point had been loaded into that register by the caller. Symbolically given below. BR R1 The subroutine can return to the re-entry point via a BR or other RR-type branch instruction provided both the BAL and the RR-type branch use the same register for the re-entry point address.1
Copyright MCPL. Unit 14. Internal Subroutines Page 14-4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
ADDRESS CONSTANTS
Address is Basic to the use of Subroutines
1. If Z is defined in the name field of an instruction then LZ= 2,4 or 6. (2, 4, or 6 bytes) 2. If Z is defined in the name field of a DC or DS directive containing a Length modifier Ln, then LZ= n. 3. If Z is defined in the name field of a DC or DS directive not containing a length modifier then LZ is the length of the constant: LZ = 2 for H-type constants LZ = 4 for F-type constants etc.,
Figure 14.4 Address Constants NOTES: An A-type constant whose value is the value of LZ is specified simply as A (LZ).Address contains can contain more than one field separated by commas: for example A (X, Y, Z) is a same as three consecutive full word address constants, the first being A (X), the Second A (Y) and the third A (Z). An address constant is a constant whose value is the value of an expression that can contain one or more name-field symbols. In address constants, you use a left and right parenthesis rather than apostrophes to enclose the expression. A (X) instead of A X The length attribute of a symbol is the number of bytes that the assembler assign to the memory area associated with the symbol. Such as an instruction or a DC or DS directive.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
NOTES:
The actual parameters are the ones that are specified by the caller when it calls a subroutine. The formal parameters are the ones that are referred to from within the subroutine so that the assembler can generate the instructions needed to access the actual parameters. We need some way for the subroutine to know what its actual parameters are each time it is called. Two methods are given below. 1. The subroutine can specify symbolic address for its input data as well as for its output results. 2. The caller can specify either the address or the value of the parameters when it calls the subroutine, so that the subroutine doesnt need to specify symbolic address.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
NOTES:
Internal subroutine with assembly-time and run-time parameters. Called via BAL 14, SKIP PARAMETERS: STRING = ADDR OF STRING
R3 = ADDR OF RESULT 3, STRING 0(3), C 14 3, 1(3) SKIPL R3 = ADDR OF STRING LOOK FOR BLANKS RETURN WHEN NON-BLANK FOUND ELSEE, ADVANCE TO NEXT CHAR
Copyright MCPL. Unit 14. Internal Subroutines Page 14-7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
MODULARIZATION
TOP-DOWN DESIGN LEVEL 0: LEVEL 1: LEVEL 2: LEVEL 3: LEVEL 4: LEVEL 5:
Figure 14.7 Modularization LEVEL 0: The top most levels solution is relatively easy: it just calls lower level routines To carry out the details. LEVEL 1: The initialization task in this problem need only consists of opening two Files: in put data file and out put result file. LEVEL 2: At this level, the task is convert a single hex in put integer, which is given in EBCDIC format, the task is accomplished in two steps: 1.Convert EBCDIC hex to internal binary format 2.Convert internal binary to EBCDIC decimal format. LEVEL 3 Our CVX and CVE subroutines are at LEVEL3 & the subroutines called by & ThemSKPBLK, HEXCHK, HEXCONare at LEVEL 4 LEVEL 4 LEVEL 5: We can put the I / O data areas, DCBs (or DTFs), and constants at LEVEL 5 Which are the lowest levels in our organization.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
range of Reg 12
. .
18F
SAVE
. DS END
NOTES:
The Using directive, Opcode USING operand B0, R0, R1, R2. Rn
Where B0 = symbol whose value is assumed by the assembler to be the base address in Register. Rx = address of any one of the general register.
Copyright MCPL. Unit 14. Internal Subroutines Page 14-9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -1 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Figure: 15-1 Terminology and Linkage Requirements NOTES: When a Program requests that a subroutine perform a task, it is said to call that Subroutine. The program making the request is known as the calling program, whereas the subroutine requested to perform the task is known as the called program. The address of the first instruction executed by a subroutine when it is called is known as the subroutines entry point. Correspondingly, the address of the instruction to which a subroutine branches when it returns to a calling program is known as the calling programs reentry point. The Linkage requirements are:1) Passing the values of the parameters, 2) Passing the address of the reentry point and 3) Branching to the entry point. The mechanism by which these requirements are met is known as the calling sequence.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -2 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Assembly-Time versus Run-Time Address Internal versus External Addresses Program Ps Instructions And data 0 4 8 C
0 8 C
10 14 18 20
10 14
1C
Np
Nq
Figure: 15-2 Memory Addresses assigned by the assembler. NOTES: Two programs may be assigned the same memory addresses at assembly time, there will be no conflict when they are run because their respective addresses can be mapped into different real memory address. The addresses assigned to a program at assembly time are internal to that program. The addresses that are internal to one program are external to all other programs.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -3 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Program
Program Q
Np+Nq+4 Figure: 15-3 Memory addresses in a load module. NOTES: The Linkage editor program has an intermediary roll between assembler and the loader. It produces what is known as a load module. An External address Constant symbolically specifies an address that is in some other program than the one in which it is specified. Register 13 and Save area: The contents of Register 13 must be saved and since they will be needed when restoring the other register contents, they had better be saved in an area from which they can be recovered prior to returning to the calling program.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -4 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
LINKAGE CONVENTIONS
P CSECT STM 14,12,12(13) BALR 12,0 USING *, 12 ST 13,SAVE+4 LA 13,SAVE . . . LA 1,=A(X,Y,) L 15, = V(Q) BALR 14,15 . PEXIT L 13,SAVE+4 LM 14,12,12(13)
CSECT STM 14,12,12(13) BALR 12,0 USING *, 12 ST 13,SAVE+4 LA 13,SAVE . . . LA 1, =A(X,Y,) L 15, = V (Q) . .
Figure: 15-4 Standard linkage convention. NOTES: Every Program, be it a called or calling program, begins and ends its execution in the same manner. The value of the parameters and the address of the result areas are passed indirectly through register one.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -5 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -6 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Figue: 15-6 Passing values of parameters. NOTES: The Linkage conventions method of passing parameters to an external subroutine is different from that of internal subroutines. What is passed to an external subroutine is the address of the table., not the values of the parameters, not the addresses of the parameters, but the address of the table that contains the addresses of the parameters. One of the first instructions that the subroutine will execute after it has stored the register contents and the callers SAVE area address is one that will obtain one or more parameter addresses from the table. For example, to copy the first parameter address into Register 2, this instruction is sufficient: L 2,0(1) To copy the first two parameter addresses into register 2 and 3, respectively, these two instructions can be used: L 2,0(1) L 3,4(1) Or this single instruction can be used: LM 2,3,0(1)
Copyright MCPL
Unit 15. External Subroutines. Page 15 -7 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
RESTORING REGISTERS WHEN RETURNING FROM A SUBROUTINE. To restore all registers: L 13, SAVE + 4 LM 14, 12, 12(13) BR 14 to restore all but register 15: L 13, SAVE + 4 L 14,12(13) LM 0, 12, 20(30) BR 14
Figure.15-7 Restoring registers when returning from a subroutine. NOTES: The act of restoring the calling programs Register 0 and/or Register 15 contents would void the result and/or code that had been placed in those registers by the subroutine. Consequently, there are four cases to be considered when returning from a subroutine (mentioned above).
Copyright MCPL
Unit 15. External Subroutines. Page 15 -8 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Figure:- 15-8 NOTES: 1) A subroutine written in by one person can be called by a program written by someone else. If the subroutines method of return is clear to both persons, neither has to investigate the details of the others program. 2) The passing of parameters is done in a single consistent manner, whether the data and results are integers, characters, or of any other type or length. 3) If all compilers generate the same standard code for the equivalent of the subroutine call and return operations, then programs written in Fortran, Cobol, and other high level languages can be interfaced to one another and to assembly language programs. 4) Benefits 1-3 are increased in importance when a person wishes to transfer a program from one computer installation to another, if the same conventional methods are used at both sites.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -9 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
SUB1 VABS
Figure: 15-9 Illustration of ENTRY and EXTRN directives. NOTES: Techniques for allowing symbolic references between separately assembled modules: 1) External addresses: ENTRY and EXTRN, 2) common addresses: COM, and 3) dummy addresses. External Addresses: ENTRY and EXTRN The EXTRN directive essentially declares that symbol or symbols in its operand field represent external addresses. When EXTRN is used to identify an external symbol, the symbol is referenced with an A-type constant: when EXTRN is not used, the symbol is referenced with a V-type constant.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -10 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
Identical statements Figure: 15-10 Illustration of COM. NOTES: An area of memory common to all the programs can be defined. Parameters, data, and results can be stored into and loaded from this area by any of the programs, as though the area were internal each program. By using this technique, one can avoid passing parameters and using V-type or EXTRN / A-type constants.
Copyright MCPL
Unit 15. External Subroutines. Page 15 -11 Courses may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OBJECTIVES :
A Question of Accuracy Conversion from one Base to another Representation of Mixed Numbers Overflow, Underflow and Significance Errors
Copyright MCPL. Unit16. Non integer Arithmetic Introductory concepts Page 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
A QUESTION OF ACCURACY Fractional representation of a mixed decimal number can be represented as a sequence of decimal digits, dj, preceded by a decimal point. 0.d1d2d3 Loss of Accuracy
NOTES : Example : When ever we write 0.3333.we understand that we can write as many
threes as we place in order to better approximate the rational fraction 1/3 .A fixed upper limit on the number of digits that can be accommodated is imposed by the hardware and software .If the limit is six , then our best approximation would be 0.333333.
If during the computation we were to attempt to compute the quantity (A-B)*C , where C = 30 and A B = 1/10,000,000 the correct result of 0.000003 would be incorrectly represented as 0.000000 , since to six places the value of A - B is 0.000000. If the same (A-B)*C were multiplied by another factor, D, the result would be zero no matter what the value of D is.
Copyright MCPL. Unit16. Non integer Arithmetic Introductory concepts Page 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 16-2 Conversion from one base to another NOTES : In base 10 , the value of decimal fraction represented as 0.d1d2.dm may be computed as d1x 10 - 1 + d2 x 10- 2 + +dm x 10- 3 In base P , the value of the fraction consisting of the base digits Pj, 0.P1P2..Pk can be computed as P1 x P- 1 + P2 x P- 2 + +Pk x P- k To convert from the representation of a fraction in one base , P, to another base , Q, the required calculations depend on whether they are done in the base P system(the old base) or in the base Q system.
Copyright MCPL. Unit16. Non integer Arithmetic Introductory concepts Page 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Decimal representation
NOTES :
One way to represent mixed numbers in 32 bit word is to let a certain number of low order bits be used for the fractional portion and the remaining high order bits for the sign and integer portion . The implied position of the binary point would have to be explicitly adjusted arithmetic shift instructions to retain the accuracy in multiplication or division . via
Decimal representation is done with a method of representation known as packed decimal format. In this format , integers and mixed numbers are represented as decimal integers .Each decimal is represented by 4 bits is known as binary coded decimal(BCD) A mixed number , F, is represented as the integer N = F X 10 n .
Copyright MCPL. Unit16. Non integer Arithmetic Introductory concepts Page 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
K bits ( K= p + n + 1) p P bits Sign bit Exponent bits n nnnnn n bits Fraction bits nnnn
NOTES :
The most common method of representing mixed numbers in computers is known as the floating-point method. In this method, numbers are represented and processed as a fraction times a scale factor. The base of the scale factor is usually a power of two, say 2m,rather than ten. Generally preferred form of fraction is with its leading bit nonzero. This is known as the normalized form of the fraction. Exponent part can be represented in 3 ways. One way is to use the exponent bit as its sign bit and to represent the exponent in sign-magnitude form. Another way is to represent the exponent in p-bit twos complement form. A third way is to represent an exponent m by an unsigned binary integer, q + m. This is known as excess-q notation.
Copyright MCPL. Unit16. Non integer Arithmetic Introductory concepts Page 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
NOTES :
As in integer arithmetic, arithmetic with mixed numbers may produce a result that cannot be represented in the number of bits allowed. If the magnitude of the number is too large for the range permitted, the condition is called overflow. If the magnitude of the number is too small for the range, the condition is called underflow. In Floating point addition and subtraction, if the resulting fraction is 0 but the exponent isnt ,all significant bits have been lost and the condition is termed a significance error .
Copyright MCPL. Unit16. Non integer Arithmetic Introductory concepts Page 16 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 17-1 Packed decimal operations NOTES: The IBM 360 and 370 systems provide a capability for Decimal integer arithmetic based on the representation of the numbers called Packed-Decimal Format. Constants can be defined for this format by the DC directive and by the Literals. Advantages of Packed-Decimal Format: To reduce the amount of memory space that would be required in EBCDIC format to store simple integers. To provide a method of processing decimal fractions without the loss of accuracy that could occur if they were processed as binary numbers. Avoid the Inherent errors.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DATA FORMATS
Decimal digit 0 1 2 3 4 5 6 7 8 9 Packed-Decimal representation 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Range: Maximum Packed-Decimal number requires 16 bytes. This gives a range (- 10 ^31) +1 to (+ 10 ^31) 1 Sign: Sign of Packed-Decimal number always represented by Right most 4-bits. Figure 18-2: Data formats NOTES: Packed-Decimal number is always represented in an integral number of bytes. The Number of bytes required depends on the number of digits. Number of bytes = (N+1)/ 2 if N is odd = (N+2)/2 if N is even Where N is number of digits.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
INSTRUCTION FORMATS
SS1- type Instruction: D1(L, B1), D2(B2) With 1 <= L <= 256 SS2-Type Instruction: D1 (L, B1), D2(L2, B2) With 1 <= L 1 <= 16 With 1 <= L2 <= 16 Length field
Figure 17-3 Instruction formats NOTES: SS1 type instruction has two operand fields each specifies the memory address of the data being operated on, and the length of each data item is specified in the first operand. SS2 type instruction has two operand fields that specify the address of data items, but the length of each item is specified separately in each operand. Length field must be specified in a DC or DS directive
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ARITHMETIC OPERATIONS
Packed Decimal Arithmetic operations : Zero and Add Packed (ZAP) Add Packed (AP) Subtract Packed (SP) Multiply Packed (MP) Divide Packed (DP)
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
*L1 L2 = 4 = number of bytes of leading zeroes Overflow: ZAP B(2) , A(4) A Before execution : 0023456C After execution : 0023456C B any 2 bytes 456C
*L1 < L2 and loss of significant digits causes decimal overflow. Figure 17-6 ZAP NOTES: Zero and Add Packed copy a packed decimal number from one memory location to another, after filling the destination area with zeroes. When L1 > L2 , the result in the destination area will contain at least L1 L2 bytes of leading zeroes. If L1 < L2 , and if there is not enough room in the destination area to accommodate all the significant digits of the number in the source field , a decimal overflow occurs.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Y2 00001C 00001C
Figure 17-6 AP NOTES: This instruction is executed; the number whose address and length are specified by the second operand is algebraically added to the number whose address and length are specified by the first operand. The sum replaces the number specified by the first operand, and the condition code is set to 0 , 1 or 2 when the sum is 0 , negative or positive respectively.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Y2 00001C 00001C
Figure 17-7 SP NOTES: This instruction is executed; the number whose address and length are specified by the second operand is algebraically subtracted from the number whose address and length are specified by the first operand. The result replaces the number specified by the first operand, and the condition code is set to 0 , 1 or 2 when the result is 0 , negative or positive respectively.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
W2 999D 999D
Figure 17-8 MP NOTES: This instruction is executed; the number whose address and length are specified by the first operand is multiplied by the number whose address and length are specified by the second operand. The result, its sign determined by the rules of algebra, replaces the multiplicand in memory but the condition code is not set.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure 17-9 DP NOTES: This instruction is executed; the number whose address and length are specified by the first operand is divided by the number whose address and length are specified by the second operand. The result consists of two components: integer quotient, of length L1 L2 bytes And the integer remainder, of length L2 bytes.
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-10 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
COMPARISONS
CP D1(L1 , B1 ) , D2( L2 ,B2)
Address and length of 1st operand (V1) Address and length of 2nd operand (V2) Examples : V1 V2 CP V1(2) , V2(3) Ressult:V1>V2 012C V1 CP V1(3) , V2(2) Ressult:V1 = V2 00345C V1 CP V1(4) , V2(1) Ressult:V1 < V2 1234567D 00345D V2 345C V2 0C
Figure: 17-10 Comparisons NOTES: Two Packed-Decimal numbers can be algebraically compared without changing either number, it accomplished by means of Compare Packed (CP) instruction, a SS2 type instruction. The condition code sets as follows: If condition is V1 = V2, condition code = 0 If condition is V1 < V2, condition code = 1 If condition is V1 > V2, condition code = 2
Copyright MCPL. Unit 17.Packed-Decimal operations Page 17-11 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Introduction Assembly Language Representation Floating-point Instructions Load and Store Operation Arithmetic Operations Error Handler Conversion TO and From Floating-Point Comparing and Testing Floating-Point
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
FLOATING-POINT OPERATIONS
The concept, format and use of numbers written in floating-point notation are similar to that of numbers written in so-called scientific notation. But as will be seen floating-point operations provide an important simplification for the problem of decimal-point alignment; alignment is performed by the hardware during the execution of floating-point instruction.
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Three types of floating-point constants in assembly language. E = short format (single-precision) D = long format (double-precision) L = extended format (quadruple-precision)
Figure: 18-2 Assembly language representation NOTES: Boundary Alignment Use of scale and exponent modifiers, Sn and En Scale modifier Sn is used only when we want to create an normalized floating-point number. Exponent modifier En can be used to express the constant in scientific notation.
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
FLOATING-POINT INSTRUCTIONS
All 51 instructions are either RX or RR-type instructions.
Figure: 18-3 Floating-point instructions NOTES: In Rx-type floating-point instructions, the first operand field must designate an appropriate floating-point register address. In RR-type floating-point instructions, both operands must designate appropriate floating-point register addresses.
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
LD
STE
STD
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ARITHEMATIC OPERATIONS
ADD SUBTRACT MULTIPLY DIVIDE HALVE ROUND
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ERROR CONDITION Four types of error situations can be detected : Exponent overflow Exponent underflow Significance exception Divide exception
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Two main types of conversions: Between floating-point and fixed-point integers. Between floating-point and ebcdic.
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Example2.
CDR 2 , 4
AF0000006FAB5760
Copyright MCPL. Unit 18.Floating-Point Operation Page 18-9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL Unit19 Cosmetic Directives PAGE 19Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
DEFINATION OF DIRECTIVES
COSMETIC DIRECTIVES USES OF COSMETIC DIRECTIVES
Figure 19 -1 definitions of directives NOTES: Directives that provide control over the appearance of source language statements on the listing and over certain aspects of the validity of source language statements will be referred to as cosmetic directives. Cosmetic directives can be used for the following purposes:
1. To begin a new page at any point on the listing (EJECT) 2. To put a title on each page of the listing (TITLE) 3. To create line spacing that visually separates adjacent bodies of statements on the listing (SPACE) 4. To suppress the printing of selected portions of the listing (PRINT) 5. To define additional mnemonic opcodes in terms of existing ones and to declare specific mnemonic opcodes to be invalid (OPSYN) 6. To require sequence checking of source language statements (ISEQ) 7. To define a nonstandard statement format (ICTL)
Copyright MCPL Unit19 Cosmetic Directives PAGE 19Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL. 2
STUDENT NOTEBOOK
NOTES:
An EJECT directive may appear anywhere in the source program and may be used any no.of times. It is not printed on the listing. Its purpose is to separate different portions of the listing from one another, there by enhancing the readability of the listing. A TITLE directive may appear anywhere and any no.of times in the source code, but it is not printed on the listing. The TITLE and EJECT directives should not be used in consecutive statements, since each one causes a skip to a new page. And two consecutive apostrophes or ampersands must be used to represent a single apostrophe or ampersand in a TITLE operand. A SPACE directive may appear anywhere and any no.of times in the source code, but it is not printed on the listing. The no.of blank line to be inserted is specified in the operand field either as a self-defining decimal term or as a blank. Copyright MCPL Unit19 Cosmetic Directives PAGE 19Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL. 3
STUDENT NOTEBOOK
PRINT
PRINT Opcode PRINT PRINT OPTIONS Keywords ON or OFF GEN or NOGEN operand one or more key words, separated by Commas meanings whether or not any lines following the PRINT directive are printed on the listing whether or not the statements generated in a macro expansion are Printed. whether the object code of a constant is printed in its entirely, or whether only only the first 8-bytes of each constants Object codes are printed.
DATA or NODATA
Figure 19 -3 PRINT
NOTES: Assembly Language has two other directives, PUSH and POP.
To suspend the most recently established key words of a Print directive, the format of the PUSH directive is simply Opcode operand
To restore the key words of the most recently suspend PRINT directive, the format of the POP directive is
PUSH
POP
PRINT
4
Copyright MCPL Unit19 Cosmetic Directives PAGE 19Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
OPSYN, ISEQ
OPSYN: DEFINE A NEW MNEMONIC OPCODE Name field Opcode operand an existing opcode blank
ISEQ: SOURCE-STATEMENT SEQUENCE CHECKING The format for initiating sequence checking is Opcode operand ISEQ P,Q The format for terminating sequence checking is Opcode operand ISEQ blank
NOTES: OPSYN: The first format defines the opcode given in the name field to have all the
properties of the code given in the operand field. The second format removes the opcode given in the name field from the set of allowable opcodes.
ISEQ directive is used to cause the assembler to verify that the statements in a source module are in the sequence in which they were intended to be .The verification depends upon sequence numbers that the programmer has placed in the identification field of each source statement. The ISEQ directive is used in pairs; the first ISEQ of the pair initiates sequence checking, the one terminates it.
Copyright MCPL Unit19 Cosmetic Directives PAGE 19Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Figure: 19 5 ICTL
NOTES:
There are two essentially different statement formats allowable in the IBM 360 and 370 Assembly language: standard format and non-standard format. If you wish to use a non standard format, the first statement of s source module must be an ICTL directive. In standard format, these three positions are defined as b = beginning position = position 1 e = ending position = position 71 c = continuing position = position 16 The letters b, e and c represent decimal integers whose values obey the following constraints: 1 < = b <= 40, 2 <= c < = 40, 41< = e <= 80 and b < c < e, b + 5 < = e.
Copyright MCPL Unit19 Cosmetic Directives PAGE 19Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-1
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
CONTROL SECTIONS
Figure 20-1 Control Sections NOTES: An Assembly language source module consists of one or more relocatable subdivisions known as Control Sections: Executable and Reference Control sections. Executable control section can contain instructions, constants and data areas that initiated by CSECT or START directives. Reference control section contains neither instructions nor constants; it merely describes or reserves memory areas for use by executable control sections at run time that initiated by DSECT or COM directives. The Assembler maintains a separate memory location counter (MLC) for each control section in a source module. I.e. the address assigned to symbols defined in one control section are independent of the addresses assigned to symbols defined in any other control section. Therefore separate implied base register should be established for each of the control sections of a source module. Copyright MCPL. Unit20.Pseudo-Ops. Pages20-2
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
CSECT
Opcode CSECT
Operand Blank
Figure 20-2 CSECT NOTES: The Control Section (CSECT) pseudo-op is used to specify the beginning of an executable control section in a source module. It must also be used to indicate the point at which any previously initiated executable control section is to be resumed. The symbol appearing in the name field is the name of the control section. This is always considered to be a control section entry point. If the name field is blank, the control section is said to be unnamed or private. Unnamed sections cannot be referenced by other control sections.
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-3
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
START
Name Field
Opcode
Operand
STARTS
Figure 20-3 START NOTES: The START pseudo-op is used to denote the beginning of the 1 st executable control section in a source module. It is not as flexible as CSECT but it provides a clear-cut indication of where the 1 st executable section begins. The symbol in the name field is the symbolic name of the control section. Being initiated this is always considered to be a control section entry point. If the name field is blank, the control section is said to be unnamed or private. Unnamed sections cannot be referenced by other control sections The value of self-defining term in the operand designates the initial value for the memory location counter of the control section, by default is zero. START cannot be used to resume an executable control section.
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-4
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
ORG
Opcode ORG
Figure 20-4 ORG NOTES: The Origin (ORG) pseudo-op instructs the assembler to change the value of the memory location counter of the control section in which the ORG occurs. If the operand field contains relocatable expression, the memory location counter set to the value of that expression. If the operand field is blank, the counter is said to be smallest address that has not been previously assigned to any constants, data area or instruction in the control section. The value of relocatable expression can be equal to , greater than or less than the location counter value that it replaces. If it is equal to that value there is essentially no effect other than to assign the value to the name field symbol. The main use of ORG is to set the location counter back to a previous value in order to redefine an area of the memory.
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-5
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
LTORG
Opcode LTORG
Operand Blank
Figure 20-5 LTORG NOTES: The LTORG pseudo-op causes the assembler to assemble all the literal constants it has accumulated. I.e. assigned a memory location in the control section for the literal constant which is in the literal pool and then it removed from the pool. The first literal assembled each time a LTORG is processed is assembled on a double word boundary. If there are more than one executable control sections in a source module, there should be a LTORG directive at the end of each of the sections. If the statements from different control sections are intermingled in the source module.
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-6
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
END
Opcode END
Figure 20-6 END NOTES: The END directive indicates to the assembler that there are no more statements to be processed in the source module. The operand is used to designate the first instruction that is to be executed at run time. If the operand is blank, the assembler assumes that the first instruction to be executed is the first one of the first executable control section in the module. if the operands contains a relocatable expression , the value of that expression is the address of the first instruction to be executed. When the END directive is processed by the assembler, all control sections except the first executable section in the source module are terminated. Any literals remaining in the literal pool are then assembled into the first executable section, and that section is terminated.
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-7
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
DSECT
Opcode DSECT
Operand Blank
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-8
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
COM
Opcode COM
Copyright MCPL.
Unit20.Pseudo-Ops. Pages20-9
Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL
STUDENT NOTEBOOK
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-1 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
CONDITIONAL ASSEMBLIES
Directives:
Enable the assembler to skip over specific statement. Create or modify the variables. AGO, AIF and ANOP are the directives
Figure: 21 - 1. Directives. NOTES: Assembler normally processes the statements of a source module in the order in which they exists; this normal processing sequence can be altered by the use of certain directives. Control directives to denote the directives used to affect the outcome of conditional assemblies.
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-2 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
SEQUENCE SYMBOLS
Identifies the source module statement Indicates the position of the statement First character must be a period (.)
Figure:
21 - 2. Sequence symbols
NOTES: Sequence symbol is not assigned an address when processed by the assembler. Indicates only the position of the statements in the source module. EX: . A , . B1 , . SEQ3 , . XY31AB A sequence symbol can appear in the name field of any statement except the following. GBLx AND LCLx directives. ISEQ, ICTL and OPSYN directives EQU, ACTR, COPY , DSECT , MACRO directives Any other statement in which an ordinary symbols or variable symbol already appears in the name field.
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-3 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Character variables
Figure: 21 - 3. Assembly variables. NOTES: Assembly variables also called as SET SYMBOLS Length is 2 to 8 character. EX: &A , & B1 , & XY31AB
An assembly variables type is always specified in the opcode of the directives GBLx, LCLx and SETx. GBLA, LCLA, SETA for the arithmetic assembly variables. GBLB, LCLB, SETB for the Boolean assembly variables. GBLC, LCLC, SETC for the character assembly variables.
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-4 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
3 . . . . END . END. 1Global scope of &r includes all statements following the first GBLx declaration for&r. 2 = local scope of &x,&y and &s depends on whether they are declared inside or outside a macro. 3 = continuation of open code local scope of &x,&y and &s 4=statements within open code include all except those within macro. 5=statements within macro definition delimited by macro and mend. Figure: 21 - 4. Global and local scope of assembly variables Copyright MCPL. Unit 21.Constants and Data Areas Page 21-5 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Opcode AGO
Opcode ANOP
Operand Blank
Figure: 21 - 5.Conditional Assemblies. NOTES: AIF directive is used to cause the assembler to alter its normal statement-by-statement processing sequence, provided that the condition being tested is TRUE. AGO directive causes the assembler to alter its normal processing sequence by directing it to branch to another statement without testing any condition. ANOP directive provides a means of identifying a statement without causing any action to be taken by the assembler.
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-6 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
& SYSPARM
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-7 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
Arithmetic expressions:
ADDITION ( + ) , SUBSTRACTION ( - ) , MULTIPLICATION( * ) DIVISION ( / )
Boolean expressions
TRUE ( 1 ) , FALSE ( 0 )
Character expressions
CONCATENATION (
.)
Figure: 21- 7.Expressions NOTES: Variable symbols declared by the GBLA or LCLA directives A Boolean expression can be used to assign a value of 0 or 1 to a Boolean assembly variable. A character expression can have one of two forms. It can be either a string enclosed in apostrophes or it can be the concatenation of two or more strings. Ex: (&x + & y) ( arithmetic expression )
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-8 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
ADDITIONAL CAPABILITIES
Figure: 21- 8.Additional Capabilities NOTES: Assembly variables can be subscripted with appropriate dimension. Dimension must be declared in the GBLx or LCLx directive. All components of subscripted assembly variables are of the same type and are assigned the initial values appropriate to that type. EX: GBLA &x ( 10 ) , LCLA B &Y(5) , GBLC &Z(3)
Using sub string notation can refer one or more consecutive characters within a string. This notation can be used only in the operand of AIF , SETB and SETC directives EX : THIS ( 3 , 2 ) designates the sub string IS
Copyright MCPL. Unit 21.Constants and Data Areas Page 21-9 Course Materials may not be reproduced in whole or in part Without the prior written permission of MCPL.
STUDENT NOTEBOOK
UNIT: 22 I/O HARDWARE CONCEPTS Objectives: Magnetic tapes Magnetic disks Tape and disk comparison
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-1 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
About to be
Figure: 22-1 Magnetic tape concepts NOTES: In a tape device, data can be recorded and sensed only while a magnetized tape surface pass under a stationary read/write head. The acceleration time is known as start time, is of order 10 milliseconds. The data-transfer time is of the order 100,00 to 500,000 bytes per second. The ratio of total gap space to the length of a tape provides a useful measure of the efficiency with which a tape is used to store data. Each gap is one-half inch long. The more blocks there are, the more gaps there are. Tape capacity = L B
G + B/ D Where L= Tape length in inches B= Blocksize in bytes D= Tape density in bytes per inch G= Gap space in inches Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-2 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Figure: 22-2 Effect of block size on tape capacity NOTES: Capacity (in bytes) LxB/ (G+B/D) Where L=3600x12 inch G=1/2 inch D=density B=blocksize
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-3 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
Figure: 22-3 Effect of block size on tape transfer time NOTES: Transfer time = start time + (blocksize) (transfer rate) The larger the blocksize, less the effect of start time on transfer time.
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-4 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
MAGNETIC DISKS
Disk characteristics Disks Offline Online Seeking Seek time Rotational-delay time
Figure: 22-4 IBM disk pack concepts NOTES: In disk packs such as those used in the IBM 3330 disk system, there are a number of continuously rotating coaxial plates called disks. As with tape reels, each disk pack can be easily removed from the unit that houses it and be replaced by another pack. when removed pack (like a tape reel) is said to be offline. When placed in the unit and connected to the computer system, it is said to be online. In this type of pack, data are stored in concentric circular tracks on the surface of the disks. The positioning motion is called seeking. The time required for the seeking is called seek time. The time required for this rotation is called rotational-delay time.
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-5 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
COUNT DATA FORMAT: TRACK UTILIZATION FOR IBM 3330 DISK SYSTEM
N=number of Data blocks Per track 1 2 3 4 5 6 7 8 9 10 15 20 25 30 35 40 45 50 55 60 B=maximum possible Blocksize for the indicated number of Data blocks 13030 6447 4253 3156 2498 2059 1745 1510 1327 1181 742 523 391 303 241 194 157 128 104 84 Maximum number of bytes per track Percentage of maximum capacity 100 % 98.96 97.92 96.88 95.86 94.81 93.74 92.71 91.66 90.64 85.42 80.28 75.02 69.76 64.74 59.55 54.22 49.11 43.90 38.68
13030 12894 12759 12624 12490 12354 12215 12080 11943 11810 11130 10460 9775 9090 8435 7760 7065 6400 5720 5040
Figure: 22 - 5 Count-data format NOTES: Block size v/s tape capacity is given by N=13,165/(135+B) Block size of less than about 1000bytes make inefficient use of the available space. A Block size exactly equal to or slightly smaller than one of the Blocksize shown in the table (22-5) should be chosen.
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-6 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
EFFECT OF BLOCKSIZE AND GAP SIZE ON ATTAINABLE TRACK CAPACITY IN IBM 3330
Gap
Not enough room for second 6450-byte block
Figure: 22-6 Effect of block size and gap size NOTES: The average seeks time in cited for IBM publications is 30 ms. The total time required positioning a data block under a read/write head is known as the access time; this is equal to sum of the rotational delay time and seek time.
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-7 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
DATA TRANSFER OVERHEAD FOR IBM 3330 DISK SYSTEM Data transfer overhead Blocksize (Number of bytes) 13030 6447 4253 3156 2498 1181 742 523 391 303 241 Seek time 0 34.2 % 51.2 61.4 68.2 73.1 85.1 90.1 92.8 94.5 95.7 96.6 Seek time 10 ms (1 cyl) 52.3 % 69.7 77.7 82.5 85.6 92.6 95.2 96.6 97.4 98.0 98.4 Seek time Seek time 30 ms 55 ms (Pack avg) (worst case) 70.4 % 82.8 87.9 90.7 92.5 96.3 97.7 98.3 98.7 99.0 99.2 79.7 % 88.8 92.3 94.2 95.3 97.7 98.6 99.0 99.2 99.4 99.5
NOTES:
Overhead =
x100
Where access time is 8.4 plus seek time (in milli seconds),and data transfer time is (Blocksize) (1.24 x10-3 ms per byte)
Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-8 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL
STUDENT NOTEBOOK
DATA RECORD
Count data format Count key data format Tape and disk comparison
Data record (Count data format)
count block
gap
data block
count block
gap
data block
Figure: 22-8 Data records NOTES: In count data format, each data block is preceded by a short (12-byte) count block, used by hardware in operating system to specify the data block size and certain other information. The data block and its count block are separated by a small gap; together known as data record. In count-keydata format, each data block is preceded by two blocks count block and a key block. The key block contains an alphanumeric character string, called the key that identifies data block. In IBM 3330 disk system, there are 19 tracks per cylinder. The maximum capacity of a cylinder is a quarter of a million bytes: 247,570 bytes if all tracks are formatted in count-data format and 246,506 bytes if count-key-data format are used. Copyright MCPL. Unit 22. I/O Hardware Concepts Page 22-9 Course Materials may not be reproduced in whole or in part without the prior written permission of MCPL