0% found this document useful (0 votes)
104 views191 pages

Mainframe Assembly Language

The document provides an overview of assembler language, highlighting its role in closely controlling program execution down to the byte and bit level. It covers key concepts such as statement format, data representation, registers, addressing methods, and assembler directives. Additionally, it explains the use of symbols and labels for easier programming and debugging.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views191 pages

Mainframe Assembly Language

The document provides an overview of assembler language, highlighting its role in closely controlling program execution down to the byte and bit level. It covers key concepts such as statement format, data representation, registers, addressing methods, and assembler directives. Additionally, it explains the use of symbols and labels for easier programming and debugging.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 191

Course

Course Title
Title ::
ASSEMBLER
ASSEMBLER
LANGUAGE
LANGUAGE

1
Objectives
INTRODUCTION
INTRODUCTION

• Symbolic programming language – lies closest to the


machine language in form and content
• Useful when to control your program closely, down
to the byte and even the bit level
• You must write subroutines for functions that are not
provided by other symbolic programming languages,
such as COBOL, FORTRAN, or PL/I

….Legacy apps

2
INTRODUCTION
INTRODUCTION
Objectives

• An assembler program consists of many statements


• In general, one assembler language statement
corresponds to one machine language instruction
• Assembler translates assembler language program
to machine language
• No separation between data and instructions

3
Assembler/Session 1 Objectives
Sample
Sample program
program

Col1 Col10 Col.16

L 2,A
A 2,B
ST 2,ANS
…..
…..
A DC F’15’
B DC F’20’
ANS DS F

4
Assembler/Session 1

Data
Data representation
representation –– Decimal,
Decimal, Hex
Hex &
& Binary
Binary

Decimal Binary Hexadecimal Decimal Binary Hexadecimal


0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 10 1010 A
3 0011 Objectives
3 11 1011 B
4 0100 4 12 1100 C
5 0101 5 13 1101 D
6 0110 6 14 1110 E
7 0111 7 15 1111 F

5
Assembler/Session 1
Data
Data representation
representation –– Some
Some Common
CommonValues
Values

Objectives

6
Assembler/Session 1

REGISTERS
REGISTERS
Objectives
Registers are storage areas inside the processor

Advantages:
- No need to retrieve data from main
storage
(saves time)
- Shared resource that allows inter
communication between programs

7
Assembler/Session 1

Programmer
ProgrammerAccessible
Accessible REGISTERS
REGISTERS
Objectives
General purpose registers:
* 16 registers available
* Numbered 0 - 15
* Holds 32 bits (4 bytes) of data (1 Fullword)
Floating point registers:
* 4 registers available
* Numbered 0,2,4,6
* Holds 64 bits (8 bytes) of data
There are other registers for processor use like access
registers
Note : The registers 0, 1, 13, 14 and 15 are reserved for special purpose
By IBM convention these registers are used for calling subprograms
8
Assembler/Session 1

PSW
PSW(Program
(Program status
statusWord)
Word)
Objectives
 Special area of the processor
 8 bytes long
 Contains important information like condition code,flags
etc
 Last 4 bytes contains the address of the next instruction
to be executed
 Essential for debugging

9
Assembler/Session 1

STATEMENT
STATEMENTFORMAT
FORMAT
Objectives
1 10 16 30
label operation operands comments

e.g..
INIT1 LA R5,4 ;INITIALISE REGISTER 5

Rules for choosing labels (Or AKA SYMBOLS):


• maximum 8 characters
• Alphabets, digits, @, #, $
• First character should not be a digit
• label should begin in column 1

10
Assembler/Session 1

STATEMENT
STATEMENTFORMAT
FORMAT
Objectives
Label (optional) – to identify the location in the program

Operation
• One of the over 200 M/C instruction mnemonics (e.g..
MVC)
Operand
• can be a register or memory location or a self defining term
or a Literal
Continuing a statement
• Place any character in column 72 of the line to be continued
• Continue the statement from column 16 of next line
• Maximum 2 continuation lines for a statement
11
Statement Format
Format (Labels)
StatementObjectives
(Labels)

LABELS & SYMBOLS


• A sequence of one to eight characters as specified below
under ORDINARY,VARIABLE,SEQUENCE symbols
• Absolute value assigned to a symbol by using 'EQU'
assembler instruction with an absolute value operand
• Symbols can be used in operand fields to represent registers,
displacements, lengths, immediate data, addresses etc.
• Labels are used similar to COBOL paragraph names to
represent a location in the program

12
Assembler/Session 1

SYMBOLS
SYMBOLS
Objectives
Symbols:
Represents storage locations or values (Labels)
To be defined only once in a source module

Advantages:
Easier to change
Listed in cross-reference
Easier to remember and code -Reduce programming errors

13
Assembler/Session 1

STATEMENT
STATEMENTFORMAT
FORMAT(Symbols)
(Symbols)
Objectives
Ordinary Symbols
• Optional
• used in the name and operand field of machine/assembler instructions
• Up to eight Alphanumeric characters A-Z,$,#,&,0-9
• First character must be alphabetic A-Z
• Rest can be alphanumeric
Example ABCD0001

Variable Symbols
• First character must be an ampersand
• second character must be alphabetic
• Up to six alphanumeric characters
Example &ABC0001 (Mainly used in macros)

14
Assembler/Session 1

STATEMENT
STATEMENTFORMAT
FORMAT(Symbols)
(Symbols)
Sequence Symbols
Objectives
• First Character must be a period
• Next Character must be alphabetic
• Up to six alphanumeric characters
Example .ABC0001 (Mainly used in macros)

Advantages of symbols
• Easier to remember and use
• Meaningful symbol names instead of values
• For address the assembler calculates the displacement
• Change the value at one place (through an EQU) instead of several
instructions
• Printed in the cross-reference table by the assembler

15
Assembler/Session 1
SYMBOLS(Attributes)
SYMBOLS(Attributes)

A1 DC CL8’ CDE ’
Objectives
Length: (Attribute)(Assembler calculates the value)
B2 DC CL2’AB'
HIORD MVC A1(L'B2),B2
MVC B2,A1
LOORD MVC A1+L'A1-L'B2(L'B2),B2

Example : length

A DS F 4
B DS 20FL4 4
DS XL3 3

AA EQU A+4 4
S1 EQU 102 1
S2 EQU X'FF +A' 1
S3 EQU C'YUK' 1

16
Assembler/Session 1

SYMBOLS(Attributes)
SYMBOLS(Attributes)
Objectives
Type attribute:
Checked as T’SOMEVAR
Returns the type – Character,Packed decimal etc
A,Y,V,S Address Constants of that type
B,C,D,E,F,H,Z,P Data constants of that type
I For machine instruction
M For a Macro instruction
J For a control section name
T For a EXTRN symbol
$ For a WXTRN symbol
N For a self defining term
O Null string

17
Statement Format
Format (Labels)
StatementObjectives
(Labels)

LABELS (SYMBOLS) – Example

LABEL001 MVC S1,S2


BR QUIT
QUIT BR 14
S1 DS CL100
S2 DC CL100'THE QUICK BROWN FOX'
COUNT EQU 10

18
Assembler/Session 2

ESTABLISHING
ESTABLISHINGADDRESSABILITY
ADDRESSABILITY
Objectives
Absolute Addressing versus
Relative Addressing

• All addresses in our program have to be


relative from some known point.
• For example, some field might be 88 bytes
away from the beginning of the program.
• This is called the displacement.

19
Assembler/Session 2

ESTABLISHING
ESTABLISHINGADDRESSABILITY
ADDRESSABILITY
Objectives
Base-Displacement Addressing
• Remember certain registers for certain
purposes?
• One of them, the base register, is used to
give us that important base address, when
the program executes.
• We can then add this register to all of our
displacements to get an absolute address.
• Called base-displacement addressing or
explicit addressing.

20
Assembler/Session 2

ESTABLISHING
ESTABLISHINGADDRESSABILITY
ADDRESSABILITY
Objectives
• By establishing the addressability of a coding section, you
can refer to the symbolic addresses defined in it in the
operands of machine instruction

• Assembler will convert the implicit addresses (Symbols


and labels) into explicit addresses (base - displacement
form)

21
Assembler/Session 2

ESTABLISHING
ESTABLISHINGADDRESSABILITY
ADDRESSABILITY
Objectives
To establish the address of a coding section :
• Specify a base address from which the
assembler can compute displacements
• Assign a base register to contain this base
address
• Write the instruction that loads the base
register with the base address
Note: The base address should remain in the base
register throughout the execution of the program

22
Assembler/Session 2
ESTABLISHING
ESTABLISHINGADDRESSABILITY
ADDRESSABILITY
Objectives
Establishing Base Register
The USING and DROP assembler instructions
enable one to use expressions representing
implicit addresses as operands of machine
instruction statements, leaving the assignment of
base registers and the calculation of
displacements to the assembler

USING - Use Base Address Register


- allows one to specify a base address and assign
one or more base registers
23
Assembler/Session 1

STATEMENT
STATEMENTFORMAT(Operands)
FORMAT(Operands)
Objectives
Rules for operands:
• A comma must separate operands.
• Parentheses must enclose sub fields.
• A comma must separate sub fields
enclosed in parentheses.
• Rules for omitting sub fields

MVC 0(2,5),0(7)
MVC 0(2,5),B
MVC A,B

24
Assembler/Session 1

STATEMENT
STATEMENTFORMAT-
FORMAT- Operands
Operands
Objectives
Examples of operands:
Register operand
Example SR 5,2
immediate operand
Example MVI DATA,X'FF'
Storage operand
Example L 3,FULLWD
Implied operand,
Example LM 14,12,SAVE
Self Defining Term:
B’00001111’ x’0F’
Literal:
=F’0’
REG5 equ 5
25 DATA DC CL2’ ‘ x’FF40’ mvc a,=C’BC’
Assembler/Session 1
Addressing
Addressing Operands
Operands
Objectives
Implicit addresses (Symbolic addresses using symbols)
► Assembler uses Base register and base address
Explicit addresses (Base displacement form –Object code )
► The programmer supplies the base register
Register addressing
► Base, displacement addressing
► Base, index and displacement addressing

26
Assembler/Session 1

Operand
OperandTypes
Types
Objectives
Register operand:
Example LR 3,2
Immediate operand:
Example MVI CHAR,C’A’ or x’c1’
Storage operand:
Example LA 3,FIELD1
Implied operand:
Example LM 14,12,SAVE+12

27
Assembler/Session 1

STATEMENT
STATEMENTFORMAT
FORMAT
Objectives
Comment Statement
• * in column 1
• Followed by any text in columns 2 - 71

Note : Fields separated by one or more


blanks

28
Assembler/Session 1

TYPES
TYPES OF
OFINSTRUCTIONS
INSTRUCTIONS
Objectives
1. Machine Instructions

2. Assembler Instructions (Directives)

3. Macro Instructions

29
Assembler/Session 1

Machine
MachineInstructions
Instructions
Objectives
Symbolic representation of machine language
instruction
Translated by the assembler
E.g: LR REG1,R2
What is the object code After Translation? XXXX
Refer to the instruction object code formats
REG1 EQU 1
R2 EQU 2

30
Assembler Instructions (Directive)

Objectives
Directive to assembler to perform certain
operations during assembly process

Not translated by assembler E.G: EQU

The EQU statement is used to associate a fixed


value with a symbol
R4 EQU 4
DRBACK EQU OUT+25

COPY directive

31
Assembler/Session 3 & 4

USING
USING EQUATES
EQUATES
Objectives
• To associate a fixed value with a symbol
• Useful for length and relative address calculation
e.g. TABLE DS 0H
var1 DC C’01
DC C’02’
org var1
var2 DS CL1
TBLEND EQU *
TBLSIZE EQU TBLEND-TABLE
32
Assembler/Session 3 & 4
USING
USINGEQUATES
EQUATES

Can be
Objectives
used for the following purposes:
1. To assign single absolute values to symbols.
2. To assign the values of previously defined
symbols or expressions to new symbols, thus
allowing you to use different mnemonics for
different purposes.
3. To compute expressions whose values are
unknown at coding time or difficult to calculate.
The value of the expressions is then assigned to a
symbol.
33
Assembler/Session 1
Some
SomeAssembler
AssemblerDirectives
Directives
Objectives
TITLE : To provide headings for each page of
the assembly listing of the source modules.
EJECT : To stop the printing of the assembler
listing on the current page, and continue the
printing on the next page.
ORG : To reset the location counter – The
location counter is set back – (REDEFINES)

34
Assembler
AssemblerDirectives
Directives

LTORG : A literal pool is created


immediately after a LTORG instruction or,
if no LTORG instruction is specified, at the
end of the first control section.
PRINT : To control the amount of detail to
be printed in the listing of programs.
PRINT NOGEN / GEN

35
Assembler/Session 2

STORAGE
STORAGE DEFINITIONS
DEFINITIONS
Objectives
Two ways to define fields :

1. Define a field and initialise the data in it using


the DC assembler directive

2. Define a field without initialising using the DS


assembler directive
………ws?

36
Assembler/Session 2

STORAGE
STORAGE DEFINITIONS
DEFINITIONS
Objectives
Format:
label {DS/DC} dtLn’value’

where :
label : Label used to name the field (optional)
d : Duplication factor (optional)
t : Type of data ( required)
Ln : The letter ‘L’ followed by the length of the field in
bytes (optional)
value : Represents the value enclosed in apostrophes

37
Assembler/Session 2

STORAGE
STORAGE DEFINITIONS
DEFINITIONS
Objectives
Examples:
ALPHA DC CL6’ABCdefrg’ 6 bytes
FLDS DS 3CL2 6 bytes
H1 DC H’29’
F2 DC F’-10’ ‘
F1 DC XL4’03’ ‘00000003’
F3 DC PL4’-72’ ‘0000072D’
F4 DC PL3’100’ ‘00100C’
B1 DC B’00000001’ 1
AC DC A(symbol)
Note : For character constants truncation or padding is to
the right and for almost all others it is to the left.
38
Assembler/Session 2

STORAGE
STORAGE DEFINITIONS
DEFINITIONS
Objectives
Word boundaries:
Address is divisible by
Half word boundary 2 (Last digit is 0,2,4,6,8,A,C,E)
Full word boundary 4 (Last digit is 0,4,8,C)
Double word boundary 8(Last digit is 0,8)

39
Assembler/Session 2
STORAGE
STORAGE DEFINITIONS
DEFINITIONS
Objectives
DC TYPES
Type Implied Alignment Data Representation
Length
C - None Character
X - None Hex digits
B - None Binary digits
F 4 Full word Binary
H 2 Half word Binary
E 4 Full word Floating point
D 8 Double word Floating point
L 16 Double word Floating point
P - None Packed decimal
A 4 Full word -

Note: These default lengths may be overridden explicitly

40
Assembler/Session 2

STORAGE
STORAGE DEFINITIONS
DEFINITIONS
Objectives
Data Representation in other languages:
Assembler FORTRAN COBOL PASCAL BASIC
Language
DC Type
C Character Display String String
F, H Integer COMP Integer Integer
E Real COMP-1 Real Single
precision
D Double COMP-2 Real Double
Precision Precision
X, B Logical N/A Boolean Hex
P N/A COMP-3 N/A N/A

41
Assembler/Session 2

STORAGE DEFINITIONS
Objectives
Literals
• A literal is a constant preceded by an equals sign ‘=‘.
• Can be used as a main-storage operand but not as a
destination field of an instruction
• Causes assembler to define a field that is initialised with
the data specified
• All constants defined by literals are put by the assembler
in a literal pool, usually at the very end of the program
(Unless changed by LTORG instruction)

L R4,=F’1’

42
Assembler/Session 2

Address Constants (A and V)


Objectives
• An address constant is a main storage address contained
in a constant
• A V-type constant is the value of an external symbol - a
relocatable symbol that is external to the current control
section.
Used for branching to locations in other control sections
e.g L 5,ADCON
ADCON DC A(SOMWHERE)
somewhere dc f’250’
GSUBADDC V(READATA)
43
Assembler/Session 2

Address Constant A
Objectives
• Also can be used to initialize data
DC A(123) generates x’0000007B’
DC A(R12) generates x’0000000C’
DC A(SAVE) generates the address of label SAVE
(Re locatable address constant – Run time)

Uses: To address large tables

44
Assembler/Session 2

Objectives
Exercise 1 Q 1 and Q2.

2.What will happen in the following cases


DC CL5’123’ ‘123 ‘
DC CL5’123456’ ‘12345’
DC X’A1245’ x’0A1245’
DC XL2’A1245’ x’1245’
DC XL5’A1245’ x’00000A1245’
DC F’19’ 4bytes
DC FL1’513’
DC AL2(25) DC H’25’

45
Assembler/Session 1

MacroMacro
Macro Instructions
Instructions
Instructions
• Objectives
Predefined sequence of code
• Also called Macro definition
• Assembler generates machine and assembler
instructions from macro definition
• IBM supplies macros for I/O, data mgt
E.G: GET macro
• GET Infile,Inarea (Read the file named infile
and place the contents in INAREA)
• User defined macros

46
Assembler/Session 1

DATA
DATAREPRESENTATION
REPRESENTATION
Objectives
1.Binary Number:
- Always fixed in length, either 2 or 4 bytes
(Full word or Half word)
- Negative numbers stored in 2’s complement form

Examples:
A DC H’295’ 01 27
DC 2H’295’ 01270127
B DC H’-75’ FF 35
C DC F’10’ 00 00 00 0A
D DS F
47
Assembler/Session 1

2’s
2’s complement
complement form
form
Objectives
How to identify a negative number?
- Leading bit contains a 1 (In Hex 8 to F)
How to convert to a negative number?
- First switch the bits (1 to 0 , 0 to 1)
- Finally add 1

48
Assembler/Session 1
DATA
DATAREPRESENTATION
REPRESENTATION
Objectives
2.Characters:
- One byte (EBCDIC form)
- Character representation of decimal digits is called
Zoned Decimal (first nibble is zone and next is digit)

Zone digit Zone Code


0-9 + C
- D
+, - , blank Blank F

49
Assembler/Session 1

DATA
DATAREPRESENTATION
REPRESENTATION
Objectives
3.Floating Point Numbers:
- Always fixed in length, 4, 8 or 16 bytes
(Full word, double word, double double word)
- Left most bit represents sign
(0 - positive; 1 - negative)
- Next 7 bits represent exponent
- Remaining bytes represent the fraction

50
Assembler/Session 1

DATA
DATAREPRESENTATION
REPRESENTATION
Objectives
4.Decimal numbers ( Packed Decimal representation)
- Each byte but the rightmost has 2 decimal digits (0-9)
- The right most byte contains a digit in the left half and
a sign indicator in the right
- Maximum of 16 bytes
Sign indicator: C - Positive
D - Negative

Example: 753 7 5 3 C
pnum DC PL2’-753’ 753D

51
Assembler/Session 1

DATA
DATAREPRESENTATION
REPRESENTATION
Objectives
Relation between different number formats:
Decimal number 1 can be represented in the following ways:
Zone decimal : F1
Binary : 0000 0001
Comp-3 (Packed) : 1C
Hexadecimal : 01
Decimal : 1

Important: Unless qualified, all numbers appearing in an


assembler programs are decimal

52
Assembler/Session 1
Instruction
Instruction Formats
Formats
RR Format :Objectives
Use the instructions with
the RR format mainly to move data
between registers.
RS Format : Use the instructions with
the RS format mainly to move data
between one or more registers and
virtual storage, or to compare data in
one or more registers.
RX Format : Use the instructions with
the RX format mainly to move data
between a register and virtual storage.

53
Assembler/Session 1
Instruction
Instruction Formats
Formats
Objectives
SI Format: Use the instructions with
the SI format mainly to move immediate
data into virtual storage.
SS Format : Use the instructions with
the SS format mainly to move data
between two virtual storage locations

One length and 2 length


MVC A,B - 1 length
AP P1(3),P2(2) 2 length
MVI A,C’Z’ immediate operand SI

54
Assembler/Session 1
Object
Object Code
Code
INSTRUCTION ––After
AfterAssembly
FORMATS Assembly Formats
Formats
RR op code R1 R2 Objectives
2 bytes

SI op code I2 B1 D1 4 bytes mvi A,C’Z’

SS1 op code L B1 D1 B2 D2 6 bytes

SS2 op code L1 L2 B1 D1 B2 D2 6 bytes

RX op code R1 X2 B2 D2 4 bytes

RS op code R1 R3 B2 D2 4 bytes
RS STM 90ECD00C STM 14,12,12(13)

55 Length will be stored 1 less than actual length in object code


Assembler/Session 1
Assembler
Assembler Instruction
Instruction formats
formats
Type Explicit Objectives
Implicit Mixed Mixed
RR R1,R2 -
RX R1,D2(X2,B2) R1,S2(X2)
RS R1,R2,D3(B3) R1,R2,S3
SI D1(B1),I2 S1,I2
SS1 D1(L,B1),D2(B2) S1,S2 S1(L1),S2 S1,D2(B2)
SS2 D1(L,B1),D2(L2,B2) S1,S2 S1(L1),S2(L2) S1,D2(L2,B2)
Eg for ss1 MVC 5(10,2),0(4) or A,B or A1(2),B or A,0(6)
R1,R2,X2,B2,B3 Registers
D2,D1 Displacements
L,L1,L2 lengths
S1,S2,S3 symbols
I2 immediate operand (1 byte)

56
Assembler/Session 1
Comparison between COBOL and Assembler
COBOL
Objectives
LINKAGE SECTION Access
FUNCTION
the PARM
ASSEMBLER
Register 1 points
and PROCEDURE Field there on entry.
DIVISION USING
88 data type Assign labels to EQU instructions.
arguments.
IF/THEN/ELSE Compare a character CLC and BC
string under 257 instructions.
bytes.
IF/THEN/ELSE Compare a character CLCL and BC
string over 256 bytes. instructions.
IF/THEN/ELSE Compare packed CP and BC
fields. instructions.
Add COMP to a Define a binary item. Depends on the size
PICTURE clause of the field
DS H equates to
PIC S9(4) COMP
PIC X or PIC X(n) Define a character DC C'value'
item.

57
Assembler/Session 1
Comparison between COBOL and Assembler (cont)
Simply
COBOL
code
Objectives
FUNCTION
the Define a literal.
ASSEMBLER
Code as for a DC,
value in quotes. but precede the
value with an equals
sign.
Add COMP-3 to Define a packed DC P'value'
PICTURE clause number.
PROGRAM-ID Module Name Name field on
CSECT or START
statement.
MOVE instruction Move an item MVC or MVCL
instruction.
PERFORM n TIMES Multiple iterations of Use BCT or BCTR
code. instruction.
REDEFINES clause Overlay a storage DSECT with USING
area. statements.
PIC clause Printing packed fields Use EDIT patterns,
formatting with ED or EDMK
characters, i.e. Z instructions.
FILLER clause Reserve storage DS with or without a
without a value. name field.

58
INTRODUCTION –Objectives
INTRODUCTION – Sample
Sample code
code (After
(AfterAssembly)
Assembly)
LOC Object Code First Op Second OP Lineno Macro Expansion

31 SAVE (14,12)
000000 32+ DS 0H
000000 90EC D00C 0000C 33+ STM 14,12,12(13)
000004 0DC0 34 BASR 12,0
R:C 00006 35 USING *,12
000006 50D0 C46E 00474 36 ST R13,SAVE13A
00000A 50D0 C3EE 003F4 37 ST R13,S13
00000E 41D0 C46A 00470 38 LA R13,SAVEREGS
000012 50D0 C472 00478 39 ST R13,SAVE13B
40 SAVE (14,12)
000016 41+ DS 0H
000016 90EC D00C 0000C 42+ STM 14,12,12(13)
43 *
00001A D203 C3EA 1000 003F0 00000 44 MVC LIN,0(R1)
45 *
46 * FIRST TIME THROUGH LOGIC
47 *
000020 4700 C05C 00062 48 FIRST NOP MAINWK
49 SETON FIRST
000F0 51+ON EQU 240
0000F 52+OFF EQU 15
000024 96F0 C01B 00021 54+ OI FIRST+1,ON
55 *

59
Assembler/Session 2

RELATIVE
RELATIVEADDRESSING
ADDRESSING
Objectives
• Relative addressing is the technique of addressing
instructions and data areas by designating their location
in relation to the location counter or to some symbolic
location
theta equ *
ALPHA LR REG3,REG4
CR 4,6 ALPHA+2 or
BETA-4
BCR 1,14
BETA AR 2,3
REG3 EQU 3
REG4 EQU 4
Note
60 : Always avoid using relative addressing
Assembler/Session 3 & 4
HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA
Objectives
Move Character Instruction (MVC)
Copy data from one place in memory to another
Format : MVC operand1,operand2
S1(L), S2 - Implicit
D1(L,B1),D2(B2) - Explicit
MVC INPUT+2(2),OUTPUT
MVC INPUT+2(2),OUTPUT+2
MVC TARGET,SOURCE
MVC TARGET(10),SOURCE
MVC TARGET(L'SOURCE),SOURCE
Note: The length attribute of the first operand is
taken for the move even if relative address is
used. Can be overridden with explicit length

61
Assembler/Session 3 & 4
HANDLING
HANDLINGCHARACTER
CHARACTERDATA
DATA(MVC
(MVC––Mechanics
Mechanicsofofoperation)
operation)

Objectives
The numbers indicate the sequence of activities happening

Processor

MVC FLDA,FLDR
1

2 46 3 5 7

FLDR FLDA

62
Assembler/Session 3 & 4
HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA(Move
(Move
Objectives
Immediate)
Immediate)
Move Immediate Instruction (MVI)
• Can move only one byte of constant data to a field
Format : MVI operand1,operand2
S1,I2 - Implicit
D1(B1),I2 - Explicit
e.g.. MVI CTL,C’B’
MVI CTL+4,C’B’ CTL DS CL1
Value Stored as a part of the instruction CTL1 DS CL4
Ctl ‘ABCDE’ ctl ‘ABCDB’

63
Assembler/Session 3 & 4

HANDLING
HANDLING CHARACTER DATA-- Advanced
CHARACTER DATA Advanced
Objectives
Techniques
Techniques
1. Explicit lengths and relative addressing
MVC PAD(4),=CL4’ ‘
PAD DC CL10’ABCDEF ’
2. Overlapping fields and the MVC instruction
MVC FLDB,FLDA
FLDA DC C’A ’
XYZ DC C’BC’
FLDB DC CL3’ABC‘

Limitation of MVC : Can only move 256 bytes


64
Assembler/Session 3 & 4

HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA
Objectives
Moving more than 256 characters: MVCL instruction
Uses 2 pairs of even-odd pair of registers
Format : MVCL R1,R2 (Both are even registers)
Reg R1 – Address of destination (even)
R1+1 ( Length) (odd) PAD DC C’-’
Reg R2 - Address of Source (even) ICM 9,8,PAD
R2+1 ( Padding character (1st 8 bits) and Length) (odd)
Eg: LA 2,TARGET
LA 3,2000(0,0)
LA 8,SOURCE TARGET DS CL2000
LA 9,1500(0,0) SOURCE DS CL1500
MVCL 2,8 r9- x’000005DC’ r9=‘6D0005DC’ after ICM

65
Assembler/Session 3 & 4

HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA--
Objectives
Comparison
Comparison Instructions
Instructions
Compares 2 values - the values are found in fields, in
registers or in immediate data
CLC - Compare logical character
e.g. CLC FLDA,FLDB

CLI - Compare logical immediate


e.g. CLI FLDA,C’K’

66
Assembler/Session 3 & 4
CONDITION
CONDITION CODE
CODE PROCESSING
PROCESSING
• Objectives
Condition code occupies 2 bits of PSW
• Condition code is set by each of a number of instructions
• Condition code is an extremely important intermediary
between arithmetic instructions and conditional branch
instructions
• Very important in implementing control structures
Arithmetic Compare
0 Zero 0 Contents equal
1 < Zero 1 1st operand < 2nd
2 >Zero 2 1st operand > 2nd
3 Overflow 3 Not set

67
Assembler/Session 3 & 4
HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA
Objectives
Moving to specific bytes of Registers
Single byte to low order position
IC R2,PRESAVE LOAD A SINGLE BYTE
ICM R2,1,PRESAVE LOAD A SINGLE BYTE
(Register,Mask,Source)
Two bytes to the low order positions
LH R2,PRESAVE LOAD TWO BYTES
ICM R2,3,PRESAVE LOAD TWO BYTES
Four bytes at a time
L R2,PRESAVE LOAD FOUR BYTES
ICM R2,15,PRESAVE LOAD FOUR BYTES
Several bytes at a time, other than the above
ICM R2,6,PRESAVE LOAD MIDDLE TWO BYTES
Load multiple registers at a time
LM R14,R12,12(R13) LOAD REGISTERS 14 THRU 12

68
Assembler/Session 3 & 4
HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA
Objectives
Moving from specific bytes from Registers to storage
Single byte to low order position
STC R2,PRESAVE Store low order byte
STCM R2,B’0111’,PRESAVE Store last 3 bytes of register
STCM R2,B’0101’,PRESAVE Store second and 4th bytes of register

(Register,Mask,Target)
What will be the result of the each of the statements if initially:
R2 = C’ABCD’
PRESAVE = C’XYZS’
STC R2,PRESAVE C’DYZS’
STCM R2,B’0111’,PRESAVE C’BCDS’
STCM R2,B’0101’,PRESAVE C’BDDS’

69
Assembler/Session 3 & 4

HANDLING
HANDLING CHARACTER
CHARACTER DATA
DATA
Objectives
What will be the effect of the following instructions :

MVI OUTAREA,C’ ‘
MVC
OUTAREA+1(132),OUTAREA
OUTAREA DS 133C

ALTERNATIVE : MVC OUTAREA(133),=133C’ ‘

70
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Three types of binary instructions
• Full word
• Half word
• Register
The Binary Move Instructions
L, LH, LR ,ST, STH
Type : R,X Register and indexed storage
e.g... L 5,FULL LR 5,7
STH 7,HALF

71
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Note : Do not mix up the instruction types and field types
e.g.
LH 5,FULL - right half of Reg 5 gets 1st 2 bytes at FULL
L 6,HALF - Reg 6 gets 4 bytes starting from HALF
ST 3,RES - 4 bytes of reg 3 are stored starting from RES
RES DS H
HALF DC H’15’ x’000F’ x’000F0000’
FULL DC F’1234’ x’000004D2’ x’00000000’

72
Assembler/Session 3 & 4
BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Load instructions with additional features
Load and Test (LTR) REG 6 = 500
e.g... LTR 15,15 OR LTR 7,6
BZ GOOD OR USE BP OR BM
• Load Address (LA) – Loads the address of the
operand instead of the contents as in L
LA R1,D2(X2,B2) EXPLICT
LA R1,STR1

73
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Load Address with special use:
To Load a small number (<4095) in a register
LA R1,5 (Equivalent to LA R1,5(0,0)
Increment the contents of a register (Not decrement)
LA R1,1(0,R1)
Decrement the contents of a register
BCTR R1,R0 S R1,=F’1’

74
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Binary Addition (A, AH and AR)
• Fixed-point overflow occurs when the sum will not
fit in the receiving register
• Type R-X
e.g. Full=f’300’ HALF=H’10’ reg 3 = 1000
Reg 5,6,7 = 0
A 5,FULL r 5=300
AH 6,HALF r6= 10
AR 7,3 r7=1000
75
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Binary Subtraction (S, SH and SR)
• Type R-X
e.g.
S 5,FULL
SH 6,HALF
SR 7,3

76
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Binary comparisons (C, CH and CR)
e.g.
C 5,FULL
CH 6,HALF
CR 7,3
Be bl bh bne

Condition code set as HIGH, LOW or EQUAL

77
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Binary Multiplication (M, MR, MH)
Format : M op1,op2
op1 : An even numbered register; refers to an even-odd
pair of registers
(any register in case of halfword format)
op2 : storage area (fullword/halfword/register)

6=0 7=50 full=f’1000’


M 6,full 6,7 – together
MH 7,HALF

78
BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Binary Multiplication (M, MR, MH) ...

Function : The value in OP2 is


multiplied by the value in the odd
register of the even-odd pair and the
result placed in even-odd registers
(For half word format : The half word
specified in OP2 is multiplied by the
value in OP1 and result stored in OP1.)

79
Assembler/Session 3 & 4

BINARY
BINARYINSTRUCTIONS
INSTRUCTIONS
Objectives
Binary Division (D, DR)
Format: D op1,op2
Type : R-X / R-R
Op1 : An even numbered register. It refers to an even-odd pair
of registers. The pair holds the double word to be
divided. The even register receives the remainder; the
odd register receives the quotient.

e.g. D 4,FULL

80
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
SS format - OPCODE D1(L1,B1),D2(L2,B2)
AP - Add packed AP A,B A= x’00150C’
SP - Subtract packed SP A,B A=x’00050D’
ZAP - Zero and add packed A=X’00100C’
MP - Multiply packed MP A,B A=X’05000C’
DP - Divide packed DP B,A B=X’2C0000C’
CP - Compare packed CP A,B BL VALID
A DC PL2’50’ B DC PL3’100’
A x’00050C’ B x’00100C’
Note: All these operations ignore the decimal places. You have to track the
decimal places and edit it with ED and EDMK instructions

81
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
MP - Multiply packed MP op1,op2
Result placed in op1. Op2 less than or equal to 8 bytes. Op2 always less
than op1. Op1 should have enough places to accomadate the result
DP - Divide packed DP op1,op2
Remainder placed in the right end of op1 equal to the number of bytes of
op2 and the quotient placed in the reminder position of op1 right justified
Possible truncation

82
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
MP - Multiply packed op1,op2
FLDA DS PL3 value 5100C
FLDB DS PL1 value 2C
What is MP FLDA,FLDB?

FLDA = ??????

83
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
DP - Divide packed DP op1,op2
DIVISOR DS PL2 002C
DIVIDEND DS PL4 0000023C
What is DP DIVIDEND,DIVISOR?

DIVIDEND = 011C001C

84
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
Advanced instructions:
SRP - Shift and Round packed OPCODE D1(L,B1),D2(B2),I3
First operand - Memory location including length
Second operand - Direction and number of places to shift
Third operand - Whether to round or not
-------------------------------------------------------------------------
Second operand, <= 32, left shift is done and 33 to 64 right shift is done.
Number for right shift = ( 64 - number of digits to be shifted)
(No rounding is involved in left shift

85
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
Advanced instructions: (SRP continued)
NUM is a 5 byte packed decimal number and contains X’001234567C’.
What is the value in number after each of these instructions?
1. SRP NUM(5),2,0 123456700C
2. SRP NUM(5),62,0 000012345C
3. SRP NUM(5),62,5 000012346C
4. SRP NUM(5),60,5 000000123C

86
Assembler/Session 3 & 4

Packed
Packed decimal
decimal operations
operations
Objectives
Advanced instructions:
MVZ - Move Zone (Moves the first half of each byte)
MVN - Move numeric (Moves the second half of each byte)
MVO - Move with offset MP A,=PL2’100’
EG: Multiply A by 100 where value of A is 123
MVC TEMP(3),A TEMP = X’00123C..’
MVN TEMP+2(1),=X’00’ TEMP=X’001230..’
MVZ TEMP+3(1),=X’00’ TEMP=X’0012300.’
MVN TEMP+3(1),A+2 TEMP =x’0012300C’
A DC PL3’123’ A = X’00123C’
TEMP DS PL4

87
Assembler/Session 3 & 4

Editing
Editing the
the output
output for
forprinting
printing
Objectives
ED and EDMK instructions ( D1(L,B1), D2(B2)) (Pattern and PD
number) …
Patterns: …
x’20’ - Digit selector Message characters – x’60’, x’4B’ etc
x’21’ - Significance selector
x’22’ - Field seperator x’60’ - (Negative sign) Sign indicator
Pattern and the packed decimal number processed from left 1 byte at a time
X 0 1 2 3 4 5 6 C (Instruction: ED P(12),X)
Fill Character
P 40 20 20 6B 20 21 20 4B 20 20 60 40 (Before execution)
P 40 40 F1 6B F2 F3 F4 4B F5 F6 40 40 (After execution)
1 , 2 3 4 . 5 6 (Last 2 bytes spaces since
number is positive)
…..Significance indicator off - On

88
Assembler/Session 3 & 4

Editing
Editing the
the output
output for
forprinting
printing
Objectives
Significance indicator – Initially turned off
Turned on - When It encounters a digit > 0 or
The digit selector pattern 21 appears
Turned off – When positive sign appears (Useful for printing
negative sign)
Selection continues until all the pattern is exhausted
The pattern should have as many digit selectors as there are
digits in the packed field

89
Assembler/Session 3 & 4

Editing
Editing the
the output
output for
forprinting
printing
Objectives
-ED and EDMK can detect the difference between significant and non signi
ficant digits ie between leading and non leading zeros

- Significance starter forces all subsequent digits to be considered significant


(excluding the significant starter)

-When significance indicator is off and detection of a significant digit turns it


on, the address of that significant digit placed in 8-31 of register 1 by EDMK
(This address can be used to insert a leading dollar sign)

-EDMK allows a floating currency and/or algebric sign but ED does not allow

90
Assembler/Session 3 & 4

Branching
BranchingInstructions
Instructions--BC
BCand
andBCR
BCRInstructions
Instructions
• Instructions thatObjectives
do or do not branch depending on
the value of the condition code
Format : BC M1,S2
BCR M1,R2
e.g. CR 4,2
BC B’1100’,BRPTA or BNH BRPTA
will cause a branch to the instruction named
BRPTA, IF the condition code is 0 or 1.

91
Assembler/Session 3 & 4

BRANCHING
BRANCHING (Using
(Using Mnemonics)
Mnemonics)
Objectives
A branch causes execution to continue at some
other instruction in the program
• Branch conditions : B, BH, BL, BE, BNH, BNL,
BNE, BZ, BNZ, BM, BNM, BO, BNO
(Branch, Branch on High, Branch on Low, Branch
on not high etc…)
e.g : CLI FLDA,C’K’
BNL GOOD

92
Assembler/Session 3 & 4
BRANCHING
BRANCHING (Using
(Using Mnemonics)
Mnemonics)
Mnemonic Objectives
---------------------- Extended Mnemonic Instructions -----------------------
Usage Meaning Machine Instruction
-----------------------------------------------------------------------------
General B or BR Unconditional Branch BC or BCR 15
NOP or NOPR No Operation BC or BCR 0

After BH or BHR Branch on A High BC or BCR 2


Compare BL or BLR Branch on A Low BC or BCR 4
Instructions BE or BER Branch on A Equal B BC or BCR 8
BNH or BNHR Branch on A Not High BC or BCR 13
BNL or BNLR Branch on A Not Low BC or BCR 11
BNE or BNER Branch on A Not Equal B BC or BCR 7

After BO or BOR Branch on Overflow BC or BCR 1


Arithmetic BNO or BNOR Branch on No Overflow BC or BCR 14
Instructions BP or BPR Branch on Plus BC or BCR 2
BM or BMR Branch on Minus BC or BCR 4
BNP or BNPR Branch Not Plus BC or BCR 13
BNM or BNMR Branch Not Minus BC or BCR 11
BNZ or BNZR Branch on Not Zero BC or BCR 7
BXZ or BZR Branch on Zero BC or BCR 8

After Test BO or BOR Branch if Ones BC or BCR 1


Under Mask BNO or BNOR Branch if Not Ones BC or BCR 14
Instructions BM or BMR Branch if Mixed BC or BCR 4
BZ or BZR Branch if Zeros BC or BCR 8
BNM or BNMR Branch if Not Mixed BC or BCR 11
BNZ or BNZR Branch if Not Zeros BC or BCR 7
93
Assembler/Session 3 & 4

BRANCHING
BRANCHING (Using
(Using Mnemonics)
Mnemonics)
Objectives
What is the instruction for unconditional Branch?
BC B’1111’,LABEL B LABEL
What is the intruction for Fallthru?
BC B’0000’,LABEL NOP LABEL

94
Assembler/Session 3 & 4
BRANCHING
BRANCHING
Objectives
Implementing First time logic:

NOBRANCH BC X'00',ONEJUMP or NOP ONEJUMP


MVI NOBRANCH+1,X'F0’
‘’’’’code your one time logic””””
B NOBRANCH
ONEJUMP EQU *

What does this code do?

95
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Operation S-I S-S R-R R-X
OR OI OC OR O
AND NI NC NR N
Exclusive OR XI XC XR X

e.g... OI FLDA,X’0F’ B’10001010’


NR 5,7 B’10001111’
X 9,FULL XR 5,5

96
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
OR Second 0 1 AND Second 0 1
First 0 0 1 First 0 0 0
1 1 1 1 0 1

Exclusive OR
Second 0 1
First 0 0 1
1 1 0 OI NUM+15,=X’F0’

97
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Turn a bit on : OR the data with a constant that has 0’s in all
positions except the ones to be turned on
Turn a bit off: AND the data with a constant which has 1’s in all
positions except the ones to be turned off
Toggle a bit: Exclusive OR the data with a constant that has 0’s
in all positions except the ones to be toggled

98
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Some common uses:
Change the zone portion of a field to F
OI FLD,x’F0’
Change the sign bit of a 3 byte packed field PKF
XC PKF+2(1),=x’01’
Initialise register 5 with 0
XR 5,5 OR SR 5,5 OR L 5,=F’0’ LH 5,=H’0’

99
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Try:
FLDA = X’F1’ FLDB = X’F2’ FLDC=X’F3’
What will happen after these instructions?
XC FLDA,FLDB 11110001 11110010 00000011
XC FLDB,FLDA
XC FLDA,FLDB

100
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Testing individual bits - Test under mask (TM)
TM S1,I2
Function : The bits of S1 ( a single byte) are tested
under the control of the mask in I2 and condition
code is set as ‘all zeroes’, all ones’ or ‘mixed’
e.g. TM EMP,B’00000101’
BNM NEXT
BO, BNO, BZ,BNZ, BM, BNM

101
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Bit Shifting Instructions
SLL, SLDL Left logical
SRL, SRDL Right logical
(No condition code set)
SLA, SLDA Left arithmetic
SRA, SRDA Right arithmetic
(Sign bit not affected and condition code set)
B’0000 0000 0000 0000 0000 0000 0000 0001’ REG 5
B’0000 0000 0000 0000 0000 0000 0000 0010’ AFTER
e.g. SLL 5,1 X’00000001’
102
SRDA 4,5 B ‘0010’
Assembler/Session 3 & 4

BIT
BITMANIPULATIONS
MANIPULATIONS
Objectives
Bit Shifting Instructions
Condition code setting for arithmetic shift
instructions
0- Result is zero
1- Result is negative
2- Result is positive
3- Overflow generated
Overflow is generated when a bit other than the sign
bit is shifted out
BZ, BNZ, BP, BM ….

103
Assembler/Session 3 & 4
BIT MANIPULATIONS (Translations - TR)
Objectives
To translate from one bit combination to another
Format : TR S1(L),S2 or S1,S2
S1 : The field whose data is to be
translated
S2 : A 256-byte translation table
Function : The value of the original byte is used as a
displacement into the translation table. The byte found there
replaces the original byte.
e.g. TR WORK,XTABLE
If the source byte is x’40’ (Space), then the displacement into
the table is 64. The value in the table at displacement 64 will
be replacing the source.

104
Assembler/Session 3 & 4
BIT MANIPULATIONS (Translations - TR)
Objectives
1 byte - 256 possible combinations
x’00’,x’01’, x’02’, x’03’,…………..x’0F’
x’10’,x’11’,x’12’,…………………..x’1F’
…………………………………………..
x’F1’,x’F2’,x’F3’,…………………x’FF’

The table should start with replacement byte for


x’00’ and end with replacement for x’FF’

105
Assembler/Session 3 & 4
BIT MANIPULATIONS (TRT)
Objectives
Translations - TRT (Translate and test register)
-Similar to TR but the source is not changed
-Table is searched similar to TR taking the displacement into
the table
-Usually employed for editing purposes
-The characters we need to search will have non zeros (x’00’)
but other characters will be x’00’.
-Source is searched one character at a time from left to right
-The first nonzero match in the table halts the instruction
-Condition code is set to 1 if match found before last byte, 2
if found at the last and 0 if not found
-Loads address of source operand if found in last 24 bits of
register 1, value from the table into last bYTE of register
2. No bits are changed in both the registers

106
Assembler/Session 3 & 4
BIT MANIPULATIONS (TRT continued)
Objectives
Translations - TRT (Translate and test register)
STR = ‘ABC.’
TRT STR,TABLE
This example searches for a period X’4B’
The period 4B is decimal 75. So the X’4B’ is placed at the
76th position in the table. (Any non zero character may
be placed in the table
Table should be declared as follows:

TABLE DC 75X’00’
DC X’4B’
DC 180X’00’

107
Assembler/Session 3 & 4
BIT MANIPULATIONS (TRT continued)
Objectives
Exercise: What does this TRT table do?

DEFINES THE TRANSLATION


TRTTAB DC 256X'0'
TABLE.
ORG TRTTAB+C' '
BLANK DC CL1' ' A BLANK
ORG TRTTAB+C','
COMMA DC CL1',' A COMMA
ORG TRTTAB+C'='
EQUALS DC CL1'=' AN EQUALS SIGN
ORG , LOGICAL END OF TABLE

108
Assembler/Session 3 & 4

Numeric
Numeric Conversions
Conversions
Objectives
1. Conversion to binary (CVB)
Format: CVB operand1,operand2
operand1 : Register
operand2 : a double word (containing
valid packed decimal number)
e.g. CVB 5,DOUBLE
Use : Character data -(PACK)->Packed decimal-(CVB)->
binary

109
Assembler/Session 3 & 4

Numeric
Numeric Conversions
Conversions
Objectives
2. Conversion from binary (CVD)
Format: CVD operand1,operand2
operand1 : Register
operand2 : a double word
e.g. CVD 5,DOUBLE
Use : Binary-(CVD)->Packed decimal-(UNPK)->
Character data

110
Assembler/Session 3 & 4

Numeric
Numeric Conversions
Conversions
Objectives
3. Conversion from Zoned decimal to packed
(PACK) (SS instruction)
Format: PACK operand1,operand2
operand1 : Packed decimal
operand2 : Zoned Decimal
e.g. PACK PACKED(3),ZONED(5)

111
Assembler/Session 3 & 4

Numeric
Numeric Conversions
Conversions
Pack
Objectives
Mechanism: PACK PACKF,CHARF

F5F8F7F4F2 CHARF

00 00 58 74 2F PACKF
TM PACKF+4,X’0F’
BO POS
MVN PACKF+4,=X’0D’
B NEXT
POS MVN PACKF+4,X=‘0C’
NEXT DS 0H

112
Assembler/Session 3 & 4

Numeric
Numeric Conversions
Conversions
Objectives
4 Packed decimal to Zoned decimal (UNPK)
Format: UNPK operand1,operand2
operand1 : Zoned decimal
operand2 : Packed decimal
e.g. UNPK ZD(5),PACKED(2)
Makes all the bytes printable except for the sign
byte. Puts leading character 0’s for unfilled bytes.

113
Assembler/Session 3 & 4

Numeric
Numeric Conversions
Conversions
Objectives
Packed decimal to Zoned decimal (UNPK)
Example: UNPK CFLD,PFLD
CFLD – CL6 PFLD – 92805C
Result:
F0 F9 F2 F8 F0 C5
FIX THE SIGN LAST DIGIT
OI CFLD+5,=X’F0’ OR
MVZ CFLD+5,=X’F0’
114
Assembler/Session 3 & 4

Relation
Relation between
between CVD,CVB,PACK
CVD,CVB,PACK and
and UNPACK
UNPACK
Objectives

PACK Input
CVB
Binary in Packed Zoned
Register UNPK Output
CVD Decimal Decimal

115
Assembler/Session 3 & 4

Different
Different conversions
conversions ––A
Asample
sample
Objectives
PACK PNUM(8),START(3)
CVB 7,PNUM
A 7,=F’1’
CVD 7,PNUM
UNPK ANS(3),PNUM(8)

ANS CONTAINS C’126’ AT THE END…


START DC C’125’
ANS DS CL3
PNUM DS D

116
Assembler/Session 3 & 4

TABLE
TABLE PROCESSING
PROCESSING
Objectives
A table is a named storage structure consisting of
subunits or entries
e.g. RATEDS DC 6F
L 4,RATEDS+8
Accessing table elements with indexed storage
operands:
e.g. LH 9,=F’8’
L 5,RATEDS (9) (9 - index register)

117
Assembler/Session 3 & 4
Multi-purpose
Multi-purpose branching
branching instructions-Looping
instructions-Looping
Objectives
Convenient when counted repetition structure (table processing) is needed
Branch on count (BCT and BCTR)
Format: BCT op1,op2 (R-X)
BCTR R1,R2
Function: First the op1 value is decremented by 1. Second the
branch is taken to the address specified in op2 only if the value in op1
is not 0.
e.g. LH 9,=H’12’
REPEAT EQU *
..
BCT 9,REPEAT
Special use: Decrement a register contents by 1
BCTR R1,0

118
Assembler/Session 3 & 4

Branching
Branching -BXH
-BXH and
and BXLE
BXLE

Objectives
Branch on index high and branch on index low or equal (BXH
and BXLE)
Format: BXLE op1,op2,op3
BXH
op1 : A register known as the index register
op2 : A even-odd pair of registers
Even register - increment register
Odd register - Limit register
op3 : A storage operand. This is the branch address.

119
Assembler/Session 3 & 4

Branching
Branching -BXH
-BXH and
and BXLE
BXLE
Objectives
Function : First, the value in the increment
register is added to the indexed register. Second,
the branch is taken only when the value in the
index register is ‘lower than or equal to’ / ‘higher
than’ the value in the limit register

Useful when the same register is to be used as the


count and index register

120
Assembler/Session 3 & 4

Branching
Branching -BXH
-BXH and
and BXLE
BXLE
BXLE -
Objectives
‘DO UNTIL’ repetitions
BXH - ‘DO WHILE’ repetitions
e.g... LH 7,=H’0’ index
LH 2,=H’2’ increment amount
LH 3,=H’18’ the limit
---
REPEAT ...
LH 6,TABLE(7)
...
BXLE 7,2,REPEAT

121
Assembler/Session 3 & 4

Branching
Branching -BXH
-BXH
BXH -
Objectives
‘DO WHILE’ repetitions
e.g... LH 7,=H’0’ index
LH 2,=H’2’ increment amount
LH 3,=H’18’ the limit
REPEAT BXH 7,2,DONE
LH 6,TABLE(7)
----- (other instructions)
B REPEAT
DONE DS 0H
---- (other instructions)

122
Assembler/Session 9

Special
Special Instructions
Instructions -- EX
EX
Objectives
The EXecute Instruction – Dynamically modifying
the length parameter
• EX instruction is a R-X type instruction that directs
the execution of an instruction called the subject
instruction, which is addressed by the second
operand
• The subject instruction is in effect a one-instruction
subroutine

123
Special
Special Instructions
Instructions –– EX
EX (Contd)
(Contd)

• The subject instruction is modified before


execution (though not altered at its main storage
location) : bits 8-15 of the instruction ORed with
bits 24-31 of register R1 to form the second byte of
the instruction actually executed
e.g. Let reg 9 have the length of string to be moved
EX R9,VARMVC
VARMVC MVC A(0),B

124
Assembler/Session 5

Assembler
Assembler Language
Language

SESSION 5
Program Sectioning

125
Assembler/Session 5

Beginning
Beginning and
and End
End of
of Source
Source Modules
Modules
Objectives
• Code a CSECT segment before any statement
that affects the location counter
• END statement is required as the last
statement in the assembly
• The label given after the END statement will
be the first statement executed in a multi csect
source

126
Assembler/Session 5

CONTROL
CONTROL SECTIONS
SECTIONS
Objectives
• A source module can be divided into
one or more control sections
• A control section is the smallest
subdivision of a program that can be
relocated as a unit at run time

127
CONTROL
CONTROL SECTIONS
SECTIONS
• At coding time, establish the addressability
of each control section within the source
module, and provide any symbolic linkages
between control sections that lie in different
source modules.
• Initiated by using the START or CSECT
instruction

128
Assembler/Session 5
CONTROL
CONTROL SECTIONS
SECTIONS
Objectives
• Any instruction that affects the location
counter, or uses its current value,
establishes the beginning of the first
control section.

129
CONTROL
CONTROL SECTIONS
SECTIONS

Format of CSECT:
Name Operation Operand
Any symbol CSECT Not required or blank

Note: The end of a control section or portion of a


control section is marked by (a) any instruction that
defines a new or continued control section, or (b) the
END instruction.

130
Assembler/Session 5

DUMMY
DUMMY SECTIONS
SECTIONS
Objectives
• A dummy control section is a reference
control section that allows you to describe
the layout of data in a storage area without
actually reserving any virtual storage.

131
DUMMY
DUMMY SECTIONS
SECTIONS

• Use the DSECT instruction to initiate a dummy


control section or to indicate its continuation.
Format of DSECT:
Name Operation Operand
Any symbol DSECT Not required or blank

132
Assembler/Session 5
DUMMY
DUMMY SECTIONS
SECTIONS
Objectives
To use a dummy section :
• Reserve a storage area for the
unformatted data
• Ensure that this data is loaded into the area
at execution time
Analogy: Cobol copybook

133
DUMMY
DUMMY SECTIONS
SECTIONS

• Ensure that the locations of the symbols in


the dummy section actually correspond to
the locations of the data being described
• Establish the addressability of the dummy
section in combination with the storage area
You can then refer to the unformatted data
symbolically by using the symbols defined in the
dummy section.
134
Assembler/Session 6

Program
Program Entry
Entry and
and Exit
Exit Logic
Logic
Objectives
Program entry - Preserve register contents
Program Exit - Restore register contents
Register save area
Always calling program provides a savearea of
18 Full words long used for storage of
registers
Savearea address passed through register 13 by
IBM convention
135
Assembler/Session 6

A register save area (18 consecutive fullwords)


Word Address
Objectives
Contents
1 SAV
2 SAV+4 Address of calling program’s save area
3 SAV+8 Address of called program’s save area
4 SAV+12 Contents of Register 14
5 SAV+16 Contents of Register 15
6 SAV+20 Contents of Register 0
...
18 SAV+68 Contents of Register 12

136
Assembler/Session 6

Responsibilities of called program


Objectives
Program entry conventions
1.Save contents of registers 0-12,14 & 15 in
calling program’s save area
2.Establish base register
3.Store calling program’s save area in the 2nd
word of its own save area

137
Assembler/Session 6

Program entry conventions (contd..)


Objectives
4. Store the address of its register savearea in the
third word of the calling program’s register save area
(The addresses in the 3d word of save area establish
a chain of register save areas. This will be useful in
reading the dump when program crashes).

138
Assembler/Session 6
Responsibilities of called program (contd..)
Program Entry Objectives
STM R14,R12,12(R13)
BALR R12,0
USING *,R12
ST R13,SAVOWN+4 store calling programs save area
LR R14,R13
LA R13,SAVOWN Reg 13 contains current prog’s SA
...
ST R13,8(R14)
SAVEOWN DS 18F

139
Assembler/Session 6

Responsibilities of called program (contd..)


Objectives
Program Exit conventions
1. Restore registers 0-12 and 14
2. Place the address of the save area provided by the
calling program in Reg 13
3. Place a return code in the low order byte of
register 15 if one is required. Otherwise restore
register 15.

140
Assembler/Session 6

Responsibilities of called program (contd..)


Objectives
Program Exit
L R13,4(R13)
LM R14,R12,12(R13)
LA 15,8(0,0) 8 IS THE RETURN CODE
BR R14

141
Assembler/Session 6
Responsibilities of calling program
1. Register 13 mustObjectives
contain the address of a register
save area.
2. Register 15 should be set to the beginning address
of the subroutine
L R15,=V(SUBENTRY)
where SUBENTRY is the entry address (usually the CSECT
name) of the subroutine

142
Assembler/Session 6
Responsibilities of calling program (contd...)
Objectives
3. Register 14 should have the return address
4. Register 1 should have the address of the parameter
list
A BALR instruction stores the address of the next
instruction in the calling program into register 14 and
transfers control to the called subroutine
BALR R14,R15

143
Assembler/Session 6
Passing parameters to a subroutine
Objectives
• The standard interface requires that addresses of
parameters be placed in a block of storage, and the
address of the block be loaded into register 1 as the
subroutine is called
• Both input and output parameters are treated the
same way
e.g... ADDS DC A(T)
DC A(U)
DC A(V)
LA R1,ADDS

144
Assembler/Session 6

R1 Main storage
Objectives
Addr of parmlist Parmlist parm3
Addr of parm1
Addr of parm2 parm1
Addr of parm3 parm2

145
Assembler/Session 6

Called subroutine B may get the parameters by


Objectives
firstparm fullword 3 parm character 10byte
rd

L R3,0(,R1) first parameter address


L R8,0(,R3) first parameter value
L R3,4(,R1) second parameter address
L R7,0(,R3) second parameter value
L R3,8(,R1) thirdparameter address
MVC VAR1,0(R3)
var1 ds CL10
146
Assembler/Session 6

Objectives
Registers with special use
R0 : Contains single word output of a
subroutine
R1 : contains the address of an area of
main storage that contains addresses of
parameters

147
Assembler/Session 6

Objectives
Registers with special use (contd...)
R14 : Contains the return address, the address
in the calling routine to which a subroutine
should return control when finished
R15 : contains the address of the entry point in
the subroutine
R13 : contains the address of an area in which
register contents can be stored by a subroutine

148
Assembler/Session 6
The subroutine RANDOM
Objectives
RANDOM STM R14,R12,12(R13)
BALR R12,0
USING *,R12
L R7,RN
M R6,=F’65541’
ST R7,RN
LR R0,R7
LM R1,R12,24(R13)
BR R14
RN DC F’8193’

149
Assembler/Session 6
Subroutine RDIGIT
RDIGIT STM
Objectives
R14,R12,12(R13)
BALR R12,0
USING *,R12
ST R13,SAV+4
LA R13,SAV
...
L R15,=V(RANDOM)
BALR R14,R15
...
L R13,SAV+4
LM R14,R15,12(R13)
LM R1,R12,24(R13)
BR R14
SAV DS 18F

150
Assembler/Session 6

Establishing symbolic linkage


• Identify externalObjectives
symbols in the EXTRN or WXTRN
instruction or the V-type address constant
• provide A-type or V-type address constants to reserve
storage for addresses represented by external symbols
• In the external source modules, identify these symbols
with the ENTRY instruction
(name entry of a START or CSECT instruction is
automatically identified as an entry symbol)
External symbol dictionary

151
Assembler/Session 6
Establishing symbolic linkage (contd...)
e.g. Objectives
program A
EXTRN TABLEB
WXTRN TABLEB
TABADR DS A(TABLEB)
program B
ENTRY TABLEB
TABLEB DS ...

152
Assembler/Session 6

Dynamically loading programs:


Load macro
Objectives
Load EP=Module to be loaded
Register 0 points to the entry point address after the execution
If already loaded, already loaded address is returned
DELETE macro
DELETE EP=Module to be deleted
Register 15 returns 0 for successful deletion, 4 otherwise

LOAD EP=subpgm
LR 15,0
LA 1,PARMLIST
BALR 14,15
DELETE EP=subpgm

153
Assembler/Session 7

JCL ‘ parm’ processing


Objectives
EXEC PGM=pgmname,PARM=
When program gets control :
• Register 1 contains the address of a full word on a
full word boundary in program’s address space
• the high order bit of this full word is set to 1
(This convention is to indicate the last word in a
variable length parameter list)

154
JCL ‘ parm’ processing ...

• Bits 1-31 of the fullword contain the


address of a 2-byte length field on a
halfword boundary
• The length field contains a binary count
of the no. of bytes in the PARM field
which immediately follows the length
field

155
Assembler/Session 7
JCL parm processing:
Objectives
General register 1 --- Contains
Address of fullword --- Points to
Address of data --- Points to
Length in binary followed by actual
information

156
Assembler/Session 7
JCL parm processing:
Objectives
How to access the parameter data?
L R1,0(0,R1)
LA R1,2(R1)
Now R1 points to the actual parameter
MVC parmchar(3),2(R1)
What is the contents of parmchar if you
invoke the program with parm=‘MYDATA’

157
Assembler/Session 8

Macros Objectives
• Short source routines written and
stored in libraries
• Assembler inserts the source
statements in the program where
the macro appears

158
Macro Definition
Format :
• A header statement
• A prototype
• Model statements
• A trailer statement

159
Assembler/Session 8

Header statement:
Objectives
MACRO
Prototype:
&name MOVE &TO,&FROM,&LENGTH
Model statements: &where=0
A set of machine and assembler instructions

Trailer statement:
&name MEND

160
Assembler/Session 8

SET Symbols (global or local)


3 types :
Objectives
• arithmetic (SETA)
• binary (SETB)
• character (SETC)
• SET symbols are declared using,
LCLA LCLB LCLC
GCLA GCLB GCLC

161
Assembler/Session 8
Macro Instruction:
Objectives
• A statement containing the name of a
macro
• when expanded, the symbolic parameters in
the model statements are replaced by
corresponding parameters from the macro
instructions
• symbolic parameters may be positional or
keyword
162
Macro Instruction ...

MACRO
&LABEL HALFSWAP &REG,&SV
ST &REG,&SV
SLL &REG,8
IC &REG,&SV
SLL &REG,8
IC &REG,&SV+1
MEND
To invoke HALFSWAP 9,SAVE

163
Assembler/Session 8
Format:
Label Objectives
operation operands
symbol-name SETA An expression
SETB
SETC
e.g. LCLC &C1
LCLA &A1
GCLA &A2
&A1 SETA 1
&A2 SETA &A1+3
&C1 SETC “BLANK”

164
Assembler/Session 8

Conditional Assembly
Objectives
The assembler can be made to branch and loop
among assembler language statements using
sequence symbols and the assembler
instructions AIF and AGO

Sequence symbol : Period followed by 1 to 7


alphabets or digits of which the first is a letter
e.g. .Z23Ab

165
Assembler/Session 8

Format:
Objectives
Label Operation Operand
seq symbol AGO seq. symbol
or blank
-do- AIF A logical expression
enclosed in parenthesis,
followed by seq symbol

166
Expressions & Relation:
A logical expression is composed of one or more
relations or values of SETB symbols connected by
logical connects AND, OR, AND NOT, OR NOT
A relation consists of 2 arithmetic expressions or 2
character expressions connected by a relational
operator EQ, NE, LT, LE, GT, GE

167
Assembler/Session 8
e.g.
MACRO Objectives
PSRCH &PARAMS,&STRING
GBLB &FOUND
LCLA &I
&FOUND SETB 0
.LP AIF ((&I GE N’&PARAMS) OR &FOUND) .E
&I SETA &I+1
&FOUND SETB (‘&PARAMS(&I)’ EQ ‘&STRING’)
AGO .LP
.E MEND
168
Assembler/Session 9

SYSTEM
SYSTEM MACROS
MACROS
Objectives
Data Management Macros & SVC (256 possible)
DCB - Construct a data control block
OPEN - Logically connect a dataset
CLOSE - Logically disconnect a dataset
GET - Obtain next logical record (queued access)
PUT - Write next logical record (queued access)
READ - Read a block (basic access)
WRITE - Write a block (basic access)

169
Assembler/Session 8
Accessing QSAM files: Keywords in DCB parameter:
DSORG Objectives
PS Physical sequential
RECFM F,FA,FB,FBA,V,VBA
BLKSIZE Block length
LRECL Record Length
DDNAME Dataset name in JCL
EODAD Label to branch when end of file is reached
MACRF Macro GM - Get Move GL - Get Locate
PM - Put Move PL - Put locate
Move parameter directly puts the record in the storage area specified
while Locate mode Loads the address of the record in Register 1

170
Assembler/Session 9
SYSTEM
SYSTEM MACROS
MACROS
e.g. File I/O Objectives
OPEN (INFILE,INPUT)
GET INFILE,RECAREA
PUT OUTFILE,RECAREA
CLOSE (INFILE)
INFIL DCB
DSORG=PS,MACRF=GM,DDNAME=IFILE
EODAD=EPILOGUE
OUTFIL DCB DSORG=PS, MACRF=PM,DDNAME=OFIL
(RECFM=,LRECL=,BLKSIZE=,)
171
Assembler/Session 8
Accessing QSAM files: Continued
Objectives
Open macro – Parameter Input, output & update
MACRF for update – (GL,PM) both specified
For update PUTX macro is issued instead of PUT
CLOSE macro
Return code available in register 15

172
Assembler/Session 9

SYSTEM
SYSTEM MACROS
MACROS
Objectives
Supervisor Services Macros
ABEND - Abnormally terminate a task
CALL - Pass control to a control section
GETMAIN - Allocate virtual storage
FREEMAIN - Free virtual storage
LOAD - Bring a load module into virtual storage
RETURN - return control to the calling program
SAVE - Save register contents
173
Assembler/Session 9

SYSTEM
SYSTEM MACROS
MACROS
Objectives
Supervisor Services Macros (contd)
SNAP - Dump virtual storage and continue
LINK - Pass control to a Program in
Another load module
WTO - Write to operator
TIME – Get the current system time

174
Assembler/Session 9
SYSTEM
SYSTEM MACROS
MACROS (SNAP)
(SNAP)
Open (SNAPSHOT,OUTPUT)
----
Objectives
SNAP DCB=SNAPSHOT, x
ID=002, x
PDATA =(REGS,SA) x
STORAGE=(START,END)
--
CLOSE SNAPSHOT
--
SNAPSHOT DCB DSORG=PS, X
RECFM=VBA, X
MACRF=W, x
LRECL=125 x
BLKSIZE=SNAPDUMP
REGS – Contents of Registers SA- Save area trace

175
Assembler/Session 9
SYSTEM
SYSTEM MACROS
MACROS (TIME)
(TIME)
Objectives
Execution of time macro stores the current time in register 0
Date in register 1
Format: HHMMSSTH (08:32:48 becomes in HEX 08324800 in register 0)
00YYDDDC (January 1,2003 stored as : 0003001C)
Code to store the Hours and minutes:
TIME DEC
ST 0,TIMEWORK
MVN TIMEWORK+3(1),=X’0F’
MVC PTIME,PATTERN
ED PTIME,TIMEWORK
---
---
TIMEWORK DS CL4 X’000000f0’ ‘X’00000000’
PATTERN DC X’4021207A2020’
PTIME DS CL6

176
Assembler/Session 9
SYSTEM
SYSTEM MACROS
MACROS (WTO)
(WTO)

Write to operator
Objectives
Standard format: WTO ‘Message’,routecde=11 (routes messages to the job log)
Optional DESC=Descriptor code (Classification of messages)
WTO – Execute method using user defined buffers:

MVC WTOTEXT(76),WTOMSG1
WTO MF=(E,WTOBLOCK)
DS 0H * INSURE HALF-WORD ALIGNMENT
WTOBLOCK EQU *
DC H'80' * For WTO, length of WTO buffer...
DC H'0' should be binary zeroes...
WTOTEXT DC CL76'ASMWTOA1 - WTO with user-coded buffer...'
*
WTOMSG1 DC CL76'ASMWTOA1 - User message number one...'
WTOMSG2 DC CL76'ASMWTOA1 - User message number two...'

177
Assembler/Session 8
Accessing VSAM files: ACB macro
AM - VSAMObjectives
(For documentation)
BUFND - No. of I/O buffers for data control intervals
BUFNI - No. of I/O buffers for index control intervals
BUFSP - Size of an area for data and Index I/O buffers
DDNAME - Filename used in the DD statement. If omitted
refers to the ACB macro name
EXLST - Address to the EXLST macro. Generates a list of
addresses for user routines
MACRF - Types of processing the file will do

178
Assembler/Session 8
Accessing VSAM files: ACB macro (Continued)
EXLST options: Objectives
AM - VSAM
EODAD = (Address, A/N, L) – End of dataset
EXCPAD = (Address, A/N, L) – Execute channel program
JRNAD = (Address, A/N, L) - Journal
LERAD = (Address, A/N, L) - Logical Error
SYNAD = (Address, A/N, L) - Physical error

Address – Where the label of the first instruction to execute


Active or Inactive, Stored in load module

179
Assembler/Session 8
Accessing VSAM files: RPL macro (Request parameter list)
ACB - Address of Objectives
the ACB macro
AREA - Address of the work area to be used
AREALEN - Length of the workarea (Should be large enough
to hold largest record in Move mode and atleast 4 bytes in the Locate mode )
RECLEN -Length of the records in the file (For VB you have
to put the length before writing using MODCB)
ARG - Label containing the key for the search (Key for
KSDS, RRN for RRDS and RBA for ESDS)
OPTCD - 5 sets of groups of parameters

180
Assembler/Session 8
Accessing VSAM files: RPL macro (Continued)
Options for OPTCD: Objectives
KEY/CNV/ADR - Access by key,Control interval or
Relative byte address
SEQ/DIR/SKP - Sequential processing,Direct, Skip
sequential
FWD/BWD - Forward sequential processing,Backward
ARD/LRD -Start seq.processing with ARG specified/
Backward processing from the last record
NUP/NSP/UPD - No updating(Next rec not ready),No
updating Next rec ready(DA only), Record updating)
MVE/LOC - Move mode/ Locate mode

181
Assembler/Session 8
Accessing VSAM files:
OPEN (acbname)Objectives
/(R) - Open the file
CLOSE (acbname) /(R) - Close the file
GET RPL=rplname / (R) - Read a record
PUT RPL=rplname / (R) - Store a record
ERASE RPL=rplname / (R) - Delete a record
POINT RPL=rplname / (R) - Position for access
Where R is a register containing the address of ACB or
RPL

182
Assembler/Session 8
Accessing VSAM files: RPL parameters
With GetObjectivesWith PUT
For retrieval only OPTCD=(…,NUP,LOC,…) NA
OPTCD=(…,NUP,MVE,…) NA

For updating OPTCD=(…,UPD,MVE,…) OPTCD=(…,UPD,MVE,…)


For adding new recs ------ OPTCD=(…,NUP,MVE,….)

183
Assembler/Session 8
Accessing VSAM files: Manipulative macros
SHOWCB – ShowingObjectives
a value from control block
SHOWCB RPL= ,FIELDS=(KEYWORD) ,AREA= , LENGTH =
Moves information from control block to a field
AREA holds the result and should be on a full word boundary
Keywords that can be used:
ACB, AREA, AREALEN, ARG
RECLEN, OPTCD, FDBK, AREA

FDBK returns the return code of a VSAM operation

184
Assembler/Session 8
Accessing VSAM files: Manipulative macros
MODCB – Changing Objectives
the value in control block
MODCB RPL= ,KEYWORD=new value (Valid value)
Modifies information in a control block

Example:
MODCB RPL=TESTRPL,OPTCD=UPD

185
Assembler/Session 8
Accessing VSAM files: Manipulative macros
TESTCB – Compare Objectives
a value from control block field to a
specific value
Example:
TESTCB RPL=TESTRPL, ERET=ERROR ,RECLEN=50
BL SMALL
After the execution of the macro, control branches to SMALL if the
record length is less than 50
Incase of error, control branches to label ERROR
The actual error code is placed in register 0

186
Assembler/Session 8

Objectives
Characteristics of good assembler program
• has simple, easy to understand logic
• uses mostly simple instructions
• has no relative addressing
• uses subroutines

187
Characteristics of good assembler program ...

• uses DSECTs
• has efficient code (LA R10, 4(0,R10 - A R10,=F’4)
• does not abnormally terminate due to user error
• requests and check feedback from macro instructions
• provides meaningful error messages

188
Assembler/Session 8

Characteristics of good assembler program


(contd..)
Objectives
• lets the assembler determine lengths
• has opcodes, operand and comments aligned
• contains meaningful comments
• uses meaningful labels

189
Assembler/Session 8

Structured Programming
Objectives
• To improve design and understandability of a
program
• made up of building blocks of subroutines

Conventions for general purpose registers


• Base registers (12)
• Link registers (14)

190
k yo u
Than

191

You might also like