0% found this document useful (0 votes)
129 views80 pages

Assembler Language III

The program loads the numbers 4 and 6 into registers 1 and 2, adds the registers and stores the result in memory at location 24, then returns to the caller. The assembly process generated object code from the source code statements.

Uploaded by

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

Assembler Language III

The program loads the numbers 4 and 6 into registers 1 and 2, adds the registers and stores the result in memory at location 24, then returns to the caller. The assembly process generated object code from the source code statements.

Uploaded by

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

Assembler Language

"Boot Camp"
Part 3 - Assembly and
Execution; Branching
SHARE in Minneapolis
July 22 - 27, 2001
Session 8183

1
Introduction
Who are we?

John Dravnieks, IBM

John Ehrman, IBM

Michael Stack, Northern Illinois University

2
Introduction
Who are you?
An applications programmer who needs to write
something in S/390 assembler?
An applications programmer who wants to
understand S/390 architecture so as to better
understand how HLL programs work?
A manager who needs to have a general
understanding of assembler?

Our goal is to provide for professionals a brief


introduction to the S/390 assembly language
3
Introduction
These sessions are based on notes of a course in
assembler language at Northern Illinois University

The notes are in turn based on the textbook,


Assembler Language with ASSIST and ASSIST/I by
Ross A Overbeek and W E Singletary, Fourth
Edition, published by Macmillan

4
Introduction
The original ASSIST (Assembler System for
Student Instruction and Systems Teaching) was
written by John R Mashey at Penn State University

ASSIST/I, the PC version of ASSIST, was written


by Bob Baker, Terry Disz and John McCharen at
Northern Illinois University

Both ASSIST and ASSIST/I are in the public


domain, and are compatible with the System/370
architecture of about 1975 (fine for beginners) 5
Introduction
Both ASSIST and ASSIST/I are available at
http://mstack.cs.niu.edu/pub/assist

Other materials described in these sessions can


be found at the same site, at
http://mstack.cs.niu.edu/pub/share

Disclaimer: please keep in mind that neither Penn


State nor NIU are able to provide support for
ASSIST or ASSIST/I
6
Introduction
Other references used in the course at NIU are:
Principles of Operation
System/370 Reference Summary
High Level Assembler Language Reference

Access to PoO and HLASM Ref is normally online

Students use the white "green card" booklet all


the time, including during examinations
(SA22-7209)
7
Agenda for the Week
Session 8181: Numbers and Basic Arithmetic

Session 8182: Instructions and Addressing

Session 8183: Assembly and Execution; Branching

Session 8184: Arithmetic; Program Structures

Session 8185: Decimal and Logical Instructions

8
Today's Agenda
Assembly of a Complete Program

Execution of a Complete Program

Implicit Addresses and USING

The Condition Code and Branching

X-Instructions and ASSIST

9
Assembly of a
Complete Program

10
A Complete Program
Yesterday, we introduced a few instructions and
used them to create a complete, if short, program

Today, we will analyze the object code generated by


the assembly of the program, then look at what
happens when ASSIST/I executes the program

"Object code - nothing else matters"

11
First Demo Program, Source List
* This program adds two numbers that are taken
* from the 5th and 6th words of the program.
* The sum is stored in the 7th word.
ADD2 CSECT
L 1,16(,15) Load 1st no. into R1
L 2,20(,15) Load 2nd no. into R2
AR 1,2 Get sum in R1
ST 1,24(,15) Store sum
BCR B'1111',14 Return to caller
DC F'4' Fullword initially 4
DC F'6' Fullword initially 6
DS F Rsrvd only, no init
END ADD2
12
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

13
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

14
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

15
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

16
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

17
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

18
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

19
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

20
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

21
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

22
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

23
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

24
First Demo Program, Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 5810 F010 L 1,16(,15)
000004 5820 F014 L 2,20(,15)
000008 1A12 AR 1,2
00000A 5010 F018 ST 1,24(,15)
00000E 07FE BCR B'1111',14
000010 00000004 DC F'4'
000014 00000006 DC F'6'
000018 DS F
END ADD2

25
Execution of a
Complete Program

26
ADD2 Program Before Execution
PSW AT BREAK FFC50000 0F000000

R0-7 : F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
27
ADD2 Program Before Execution
PSW AT BREAK
Here is our
FFC50000 0F000000

R0-7 :
program loaded
F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4
R8-15: F4F4F4F4into memory
F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
28
ADD2 Program Before Execution
PSW AT BREAK FFC50000 0F000000 Address of the
first instruction
R0-7 : F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4
R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
29
ADD2 Program Before Execution
Address of the
next instruction

PSW AT BREAK FFC50000 0F000000

R0-7 : F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
30
ADD2 Program After 1st Instruction
PSW AT BREAK FFC50000 8F000004

R0-7 : F4F4F4F4 00000004 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
31
ADD2
ContentsProgram
of After 1st Instruction
word 5 "loaded"
to
PSW AT BREAK R1FFC50000 8F000004

R0-7 : F4F4F4F4 00000004 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
32
ADD2next
Program
Address of the
instruction
After 1st Instruction
PSW AT BREAK FFC50000 8F000004

R0-7 : F4F4F4F4 00000004 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
33
ADD2 Program After 2nd Instruction
PSW AT BREAK FFC50000 8F000008

R0-7 : F4F4F4F4 00000004 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
34
ADD2 Program
Contents of
After 2nd Instruction
word 6 "loaded"
PSW AT BREAK to R2 8F000008
FFC50000

R0-7 : F4F4F4F4 00000004 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
35
ADD2 Program After 2nd Instruction
Address of the
next instruction

PSW AT BREAK FFC50000 8F000008

R0-7 : F4F4F4F4 00000004 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
36
ADD2 Program After 3rd Instruction
PSW AT BREAK FFC50000 8F00000A

R0-7 : F4F4F4F4 0000000A 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
37
ADD2
Contents ofProgram
R2 After 3rd Instruction
added to
PSW ATcontents
BREAK ofFFC50000
R1 8F00000A

R0-7 : F4F4F4F4 0000000A 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
38
ADD2next
Program
Address of the
instruction After 3rd Instruction
PSW AT BREAK FFC50000 8F00000A

R0-7 : F4F4F4F4 0000000A 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 F5F5F5F5 F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
39
ADD2 Program After 4th Instruction
PSW AT BREAK FFC50000 8F00000E

R0-7 : F4F4F4F4 0000000A 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 0000000A F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
40
ADD2
Contents ofProgram
R1 After 4th Instruction
(sum) "stored"
PSW to word FFC50000
AT BREAK 7 8F00000E

R0-7 : F4F4F4F4 0000000A 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 0000000A F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
41
ADD2next
Program
Address of the
instruction
After 4th Instruction
PSW AT BREAK FFC50000 8F00000E

R0-7 : F4F4F4F4 0000000A 00000006 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4


R8-15: F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 F4F4F4F4 00000020 00000068 00000000

000000 5810F010 5820F014 1A125010 F01807FE *..0.......&.....*


000010 00000004 00000006 0000000A F5F5F5F5 *........55555555*
000020 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000030 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000040 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000050 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000060 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000070 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000080 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
000090 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000A0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000B0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000C0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000D0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000E0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*
0000F0 F5F5F5F5 F5F5F5F5 F5F5F5F5 F5F5F5F5 *5555555555555555*

===> B(rkpt.), D(ump), G(o), M(emory), P(SW), Q(uit), R(eg.), S(tep), T(race)
:
42
Implicit Addresses
and USING

Making Assembler
Programming "Easy"

43
A Slight Change
What if we want to make a change to our original
program? Maybe use register 12 as the base instead
of R15

That's no problem - just insert one instruction in


front of the first, copying R15 to R12, then change
all instructions which use R15 as the base register

But that moves everything down and our data areas


are no longer where they were, and that means we
have to re-calculate the displacements
44
Updated Demo Program
* This program adds two numbers that are taken
* from the 5th and 6th words of the program.
* The sum is stored in the 7th word.
ADD2 CSECT
LR 12,15 Copy addr of 1st inst
L 1,??(,12) Load 1st no. into R1
L 2,??(,12) Load 2nd no. into R2
AR 1,2 Get sum in R1
ST 1,??(,12) Store sum
BCR B'1111',14 Return to caller
DC F'4' Fullword initially 4
DC F'6' Fullword initially 6
DS F Rsrvd only, no init
END ADD2 45
Updated Demo Program
* This program adds two numbers that are taken
* from the 5th and 6th words of the program.
* The sum is stored in the 7th word.
ADD2 CSECT
LR 12,15 Copy addr of 1st inst
L 1,20(,12) Load 1st no. into R1
L 2,24(,12) Load 2nd no. into R2
AR 1,2 Get sum in R1
ST 1,28(,12) Store sum
BCR B'1111',14 Return to caller
DC F'4' Fullword initially 4
DC F'6' Fullword initially 6
DS F Rsrvd only, no init
END ADD2 46
Updated Demo Program
As you are looking at this altered program, you
should ask yourself why the locations of the three
data areas increased by four bytes, when we added
only a two-byte instruction at the beginning of the
program

Specifically, look at the first DC, just after the BCR


instruction, and notice that BCR occupies only two
bytes of storage

47
Updated Demo Program Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 18CF LR 12,15
000002 5810 C014 L 1,20(,12)
000006 5820 C018 L 2,24(,12)
00000A 1A12 AR 1,2
00000C 5010 C01C ST 1,28(,12)
000010 07FE BCR B'1111',14
000014 00000004 DC F'4'
000018 00000006 DC F'6'
00001C DS F
END ADD2
48
Updated Demo Program Assembled
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 18CF LR 12,15
The next field is
000002
fullword aligned,5810 C014 L 1,20(,12)
even though this5820 C018
000006 L 2,24(,12)
instruction ends
two00000A
bytes "early"1A12 AR 1,2
00000C 5010 C01C ST 1,28(,12)
000010 07FE BCR B'1111',14
000014 00000004 DC F'4'
000018 00000006 DC F'6'
00001C DS F
END ADD2
49
There Must Be an Easier Way!
What if our program has hundreds or thousands of
instructions? Do we have to calculate displacements
for every data area?

Or, what if we change something? Do we have to


re-calculate all displacements?

Fortunately, no (or no one would ever use the


assembler)

50
Use Labels!
Remember: "Object Code - Nothing Else Matters"

So, as long as the assembler generates the correct


object code, we can do anything we want

We want to use labels - implicit addresses - instead


of explicit base and displacement, and let the
assembler do the calculations

We can do this as long as we tell the assembler


what base register and base address to use
51
The USING Instruction
So, instead of writing a base and displacement form
of address, we will simply place a label on the
storage area definition, then write that label in any
instruction operand which references that data

The assembler must convert the reference to a valid


base and displacement

We tell the assembler which base register it can use


and what base address it has via the USING
assembler instruction (or directive)
52
The USING Instruction
The USING instruction is not executable, and has
the following format:
USING baseaddress,baseregister

This is used by the assembler to choose the correct


base register and assign displacements

USING is a "promise" that at execution time the


base register will contain the memory address at
which the base address has been loaded
53
The USING Instruction
Be sure to compare the object code generated by
the next version of the program, with the object
code generated by the version without USING and
labels

The object code is exactly the same, so the program


will execute in exactly the same way

"Object code - nothing else matters"

54
Demo Program with Labels
* This program adds two numbers that are taken
* from WORD1 and WORD2 in the program.
* The sum is stored in WORD3.
ADD2 CSECT
LR 12,15 Copy addr of 1st inst
USING ADD2,12 Tell assembler
L 1,WORD1 Load 1st no. into R1
L 2,WORD2 Load 2nd no. into R2
AR 1,2 Get sum in R1
ST 1,WORD3 Store sum
BCR B'1111',14 Return to caller
WORD1 DC F'4' Fullword initially 4
WORD2 DC F'6' Fullword initially 6
WORD3 DS F Rsrvd only, no init
55
END ADD2
Demo Program with Labels
LOC OBJECT CODE SOURCE STATEMENT

000000 ADD2 CSECT


000000 18CF LR 12,15
000000 USING ADD2,12
000002 5810 C014 L 1,WORD1
000006 5820 C018 L 2,WORD2
00000A 1A12 AR 1,2
00000C 5010 C01C ST 1,WORD3
000010 07FE BCR B'1111',14
000014 00000004 WORD1 DC F'4'
000018 00000006 WORD2 DC F'6'
00001C WORD3 DS F
END ADD2
56
The Condition Code
and Branching

57
The Condition Code
The ADD (A, AR) and SUBTRACT (S, SR)
instructions have an additional characteristic not yet
mentioned - they set the condition code in the
following way

CC Meaning
0 Result is 0
1 Result is < 0
2 Result is > 0
3 Overflow occurred
58
The Condition Code
Another pair of instructions, COMPARE (C, CR)
also set the condition code, but the values are
interpreted in a slightly different way

CC Meaning
0 Contents equal
1 1st operand value < 2nd operand value
2 1st operand value > 2nd operand value
3 ---- (not set)

59
The Condition Code
The condition code is actually two bits of the PSW
(bits 34 & 35 in ASSIST/I, bits 18 & 19 in S/390)

In order to test for all possible combinations of the


four CC values, we can use a four-bit mask
Mask B'x x x x' (B means binary)
CC 0 1 2 3

Then a bit mask of B'1010' will test for condition


codes 0 and 2
60
BRANCH ON CONDITION
The condition code can be tested in only one way -
by using the BRANCH ON CONDITION
instruction (BC, BCR)

If the mask part of the BC or BCR has a 1 in a


position corresponding to the current setting of the
CC, the next instruction to be executed will be the
one whose address is given by the second operand

Otherwise, the next instruction will be the one


whose address is already in the PSW, the one in
memory immediately after the branch instruction 61
BRANCH ON CONDITION
The two forms of BRANCH ON CONDITION are
[RX] label BC B'mask',D2(X2,B2)
[RR] label BCR B'mask',R2

The encoded form of each instruction is


[RX] hOPhOPhM1hX2 hB2hD2hD2hD2
[RR] hOPhOPhM1hR2

Note that BCR B'1111',R14 is an


unconditional branch to the address in R14 and is
the instruction used to end execution of a program 62
A Program Which Tests the
Condition Code by Branching
MAX CSECT
USING MAX,15
L 1,W1 Get First number
L 2,W2 Get second number
CR 1,2 Compare
BC B'0010',ONEHIGH Branch if W1 high
ST 2,W3 Else store second number
BCR B'1111',14 Return to caller
ONEHIGH ST 1,W3 Store first number
BCR B'1111',14 Return to caller
W1 DC F'321' First number
W2 DC F'123' Second number
W3 DS F Max of first and second
END MAX
63
A Program Which Tests the
Condition Code by Branching
LOC OBJECT CODE SOURCE STATEMENT
000000 MAX CSECT
000000 USING MAX,15
000000 5810 F01C L 1,W1
000004 5820 F020 L 2,W2
000008 1912 CR 1,2
00000A 4720 F014 BC B'0010',ONEHIGH
00000E 5020 F024 ST 2,W3
000012 07FE BCR B'1111',14
000014 5010 F024 ONEHIGH ST 1,W3
000018 07FE BCR B'1111',14
00001C 00000141 W1 DC F'321'
000020 0000007B W2 DC F'123'
000024 W3 DS F
END MAX 64
X-Instructions and
ASSIST/I

Getting Data In and Out


of an Assembler Program

65
Character Data
At this point, we've seen only numeric data,
represented as binary fullwords (data type F)

In order to work with external data, we will have to


know how to represent characters

There are two basic possibilities: EBCDIC & ASCII

We will stick to EBCDIC in these sessions, since


It's the only representation known to ASSIST/I
It's the representation most common in OS/390
66
Some EBCDIC Representations
A C1 N D5 0 F0 . 4B
B C2 O D6 1 F1 < 4C
C C3 P D7 2 F2 ( 4D
D C4 Q D8 3 F3 + 4E
E C5 R D9 4 F4 & 50
F C6 S E2 5 F5 ! 5A
G C7 T E3 6 F6 $ 5B
H C8 U E4 7 F7 * 5C
I C9 V E5 8 F8 ) 5D
J D1 W E6 9 F9 - 60
K D2 X E7 > 6E
blank 40
L D3 Y E8 @ 7C
M D4 Z E9 ' 7D 67
Character Data
We can create character data in our programs by
using data type C in a DC instruction

MESSAGE DC C'1HELLO WORLD!'

The object code generated by this DC is


F1C8C5D3D3D640E6D6D9D3C45A

The 1 in front of the message is a "carriage control"


character which will cause the message to be
printed at the top of a new page
68
The X-Instructions of ASSIST/I
For assembler programmers, moving data into and
out of a program is a very complex affair, involving
numerous operating system I/O "macros"

For users of ASSIST and ASSIST/I, however, the


process is extremely simple and requires only the
use of a few non-standard instructions

In ASSIST and ASSIST/I, these instructions assemble


just like "real" instructions, but they are not part of
the standard (or any other) instruction set
69
The XREAD Instruction
The XREAD instruction reads a record from the
input file and places as many bytes as are requested
at the memory address provided
Note that the record contains character data

label XREAD D1(X1,B1),L2


D1(X1,B1) is the address of the first byte of the
input buffer
L2 is the number of characters (1 to 80) to be
transferred from the input record
70
The XREAD Instruction
The XREAD instruction sets the condition code
0 - Read was successful, data placed in memory
1 - end-of-file encountered, no data transferred
2 - not set
3 - not set

If the data which was read is numeric, it is EBCDIC


characters and must be converted to binary before
we can manipulate it (e.g., ADD or SUBTRACT)

Input conversion is the job of XDECI 71


The XDECI Instruction
The XDECI instruction converts an EBCDIC
numeric value in memory to a binary numeric value
and places it in a register

label XDECI R1,D2(X2,B2)


R1 is the register to hold the result
D2(X2,B2) is the memory location at which the
search for numeric characters begins

72
The XDECI Instruction Logic
1. Start at D2(X2,B2), scan for the first non-blank
2. If the first non-blank is anything but + or - or a
decimal digit, set the condition code to 3 and quit
3. Otherwise, 1 to 9 digits are scanned and the
resulting number converted to binary, placed in
register R1
4. Register 1 is set to the address of the first
non-digit (so R1 should not be 1!)
5. If ten or more digits are found, register 1 is set to
the address of the first non-digit, the condition
code is set to 3, and R1 is unchanged 73
The XDECI Instruction Logic
XDECI sets the condition code
0 - The number converted was 0
1 - The number converted was < 0
2 - The number converted was > 0
3 - Non-numeric attempted

How to avoid scanning past the end of the buffer


INPUT DS CL80 Input Buffer
DC C'*' Non-digit

74
The XDECO Instruction
The XDECO instruction converts a binary numeric
value in a register to an EBCDIC numeric value in
memory (action opposite that of XDECI)

label XDECO R1,D2(X2,B2)


R1 is the register containing the binary number
to convert
D2(X2,B2) is the beginning memory location,
usually within a print buffer, to store the EBCDIC
number, right-justified, occupying 12 bytes
75
The XPRNT Instruction
The XPRNT instruction will print one line of output

label XPRNT D1(X1,B1),L2


D1(X1,B1) is the address of the first byte of the
output buffer, the carriage control character
L2 is the number of characters (including CCC)
to be transferred from memory to the print line

The print line may be no more than 133 characters,


including carriage control
76
Carriage Control Characters
The carriage control characters include
blank - single space before print
0 - double space before print
- - triple space before print
1 - go to top of next page before print

77
Example With X-Instructions (1 of 2)
* THIS PROGRAM READS DATA CARDS EACH HAVING TWO
* NUMBERS. THE SUM OF THE NUMBERS IS PRINTED.
*
SUMUP CSECT
USING SUMUP,15
*
XPRNT HEADING,28 PRINT PAGE HDR
XREAD CARD,80 READ 1ST CARD
*
CHECKEOF DC B'0100',EXIT BR ON EOF
*
XDECI 2,CARD ASSUME BOTH NUMS
XDECI 3,0(1) ARE VALID
*
78
AR 2,3 CALCULATE THE SUM
Example With X-Instructions (2 of 2)
XDECO 2,OUTPUT PRINTABLE FORM
* INTO PRINT LINE
XPRNT CRG,13 PRINT THE SUM
* AFTER SINGLE SPACE
XREAD CARD,80 TRY ANOTHER READ
BC B'1111',CHECKEOF GO CHECK FOR EOF
*
EXIT BCR B'1111',14 TERMINATE PROGRAM
*
CARD DS CL80 INPUT BUFFER
*
CRG DC C' ' SINGLE SPACE CC
OUTPUT DS CL12 SUM GOES HERE
HEADING DC C'1THIS IS THE OUTPUT OF SUMUP'
79
END SUMUP
What's Next?
Tomorrow, we will see the conventions which allow
routines to communicate, even though written at
different times by different people

We will also encounter one of the most challenging


ideas in the machine language, the LOAD ADDRESS
instruction (when you understand LA, you will have
"passed the course")

80

You might also like