Assembler Programming Introduction
Assembler Programming Introduction
Course Details
Audience
This is an introductory level course for application and system programmers and others who wish to write
programs in Assembler Language. In addition, it is an appropriate introduction for individuals wishing a basic
introduction to System z architecture.
Prerequisites
The student should have a basic knowledge of computing concepts and terminology, and should be able to
program in a high level language.
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 2 of 58
Assembler Programming Introduction
Course Introduction
Assembler Language Introduction provides a basic introduction to programming at the Assembler level. The
architecture to programming at the Assembler level. The architecture of IBM System z is presented, with an
emphasis on storage addressing, use of registers and instruction formats.
The first unit, Assembler Language Overview, explains the format of both Assembler Language and
Machine Language instructions and is presented, along with the operation of the Assembler program, which
translates one to the other.
The second unit, Memory Usage, explains the methods of memory storage and allocation, arithmetical
operations of decimal, binary and hexadecimal numbers and the conversion from one system to the other.
The third unit, Addressing and Instructions, explains the difference between Assembler instructions,
Machine instructions and macro instructions, and how each is used.
The fourth unit, Program Development Process, describes the use of Assembler language syntax and the
conversion of Assembler Language to Machine Language using the Assembler Program.
The fifth unit, Defining Data unit, explains the Assembler instructions used in defining storage and data
areas, along with the use of literals.
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 3 of 58
Assembler Programming Introduction
Course Objectives
Continued…
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 4 of 58
Assembler Programming Introduction
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 5 of 58
Assembler Programming Introduction
Topics:
Language Hierarchy
Program Components
Unit Introduction
Assembler Language is the language most closely related to the instruction set of a computer –
its Machine Language. This unit answers some fundamental questions that many students ask
when beginning to learn this language.
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 7 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview
Unit Objectives
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 8 of 58
Assembler Programming Introduction
Topics:
Language Hierarchy
Program Components
Topic Objectives
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 10 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 11 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Machine Language
CONSTANT
A program consists of instructions and various
CONSTANT
types of data areas.
STORAGE AREA
STORAGE AREA C
C DATA
STORAGE AREA D
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 12 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
MOVE Instruction
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 13 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 14 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 15 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Assemblers
ASSEMBLER LANGUAGE
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 16 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Assemblers (cont’d)
SYMBOLIC NAMES
MENEMONIC CODE ASSEMBLER LANGUAGE
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 17 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Assemblers (cont’d)
The Assembler reads a program written in Assembler Language, as input and translates it into Machine
Language program as output. The Machine Language program can then be executed.
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 18 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Assemblers (cont’d)
The example on the right shows the four ASSEMBLER (OR MACHINE LANGUAGE)
Assembler instructions that might be needed to
add two numbers together. PACKX,A (11110010.........)
PACKY,B (11110010.........)
APX,Y (11111010.........)
UNPKB,X (11110011.........)
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 20 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Are We on Track?
Review Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 21 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 22 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
What is a compiler?
A program called a compiler reads a HLL program as input and translates it into a Machine Language
Program.
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 23 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
FORTRAN C=A+B
• COBOL – another early HLL, designed
to facilitate the programming of business
and commercial programs
C C:=A+B; /*ADD A TO B*/
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 24 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
• Ease of development
• Portability
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 25 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Are We on Track?
Match the term on the left with its description on the right.
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 26 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 27 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
ASSEMBLER ADVANTAGES
• Assembler Language instructions
correspond one-for-one with machine
instructions making it possible to do
P Control of environment
anything the hardware allows
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 28 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 29 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 30 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Are We on Track?
Which of the following are reasons you might decide to use Assembler?
C. To ensure the program is translated into the most efficient Machine Language
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 31 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Glossary
Architecture – The design of computer hardware; incorporating storage, registers, instruction set
and other features.
Bit – The smallest unit of information handled by a computer. One bit expresses a 1 or 0
in binary numerals or a true or false in logic condition, and is represented physically
by an element such as a high or low voltage at one point on the circuit or a small
spot on a disk.
Mnemonic Code – A word, rhyme or other memory aide used to associate a complex or lengthy set of
information with something that is simple and easy to remember. Mnemonics are
widely used in computing. Programming languages other than machine language
for example are known as symbolic languages because they use short mnemonics
such as AD (for addition) and DEF (for define) to represent instructions and
operations.
Accumulator – Register used for logic or arithmetic, usually to count items or accumulate a sum.
Compiler – A program that translates all the source code of a program written in a High-Level
Language into object code, prior to the execution of the program.
Continued…
Glossary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 32 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Glossary (cont’d)
Fortran – Short for formula translation. The first High-Level computer language.
Exit Routines – A user written program segment, designed to be incorporated at a designated point
in an operating system module or utility program.
Glossary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 33 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Language Hierarchy
Topic Summary
Now that you have completed this topic, you should be able to:
Summary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 34 of 58
Assembler Programming Introduction
Topics:
Language Hierarchy
Program Components
Topic Objectives
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 36 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Program Execution
What is an Image?
ADDRESS SPACE
In order for a program to execute, it must be
loaded into the memory or main storage area of
the computer. The image is a program which is
loaded into the memory in order to execute in the
Assembler program space.
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 37 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Executable Instructions
Constants
File Definitions
I/O Areas
Other
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 38 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
MOD 2
INSTRUCTION
DATA
MOD 3
INSTRUCTION
DATA
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 39 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Are We on Track?
Of the following program elements, which one is normally placed at the beginning of
an address space?
A. Instructions
B. Data areas
C. Constant definitions
D. File definitions
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 40 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 41 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
ADDRESS SPACE
The architecture of S/390 computers
provides 16 General Purpose Registers Executable Instructions
(GPRs). GPRs are part of the hardware of the
Constants
computer, and can be used by any Assembler
program when executing. General Storage Areas
File Definitions
What are the functions of GPRs?
I/O Areas
GPRs are very important to the Assembler
Other
programmer. They are used in addressing both
instruction and data, and also for performing
binary arithmetic, counting for loops and many
General Purpose Registers
other purposes.
GPRs are also used in conventional ways, 0 1 2 15
passing control and data from one module to
another.
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 42 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Essentials of GPRs
Binary Address
Arithmetic Values
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 43 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Are We on Track?
How many GPRs are part of the hardware of the hardware of S/390 computer?
A. 12
B. 16
C. 34
D. 22
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 44 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 45 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
What is a DCB ?
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 46 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Macro Instructions
Continued…
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 47 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 48 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Are We on Track?
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 49 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Glossary
Image – A duplicate, copy or representation of all or part of a hard or a floppy disk, a section
of memory or hard drive, a file, a program or data.
File Definition – A way of identifying data to be read from or written to a peripheral device.
DCB – Data Control Block. A file definition, maintaining information about an external file.
The DCB is created using a system macro instruction.
Macro Instruction – A name that defines an instruction or a set of instructions that are substituted for
the macro name wherever the name appears in the program when the program is
compiled or assembled.
Glossary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 50 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Assembler Program Components
Topic Summary
Now that you have completed this topic, you should be able to:
Summary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 51 of 58
Assembler Programming Introduction
Topics:
Language Hierarchy
Program Components
Topic Objectives
Introduction © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 53 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Program Components
Concepts © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 54 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Program Components
Are We on Track?
A. OPEN
B. CLOSE
C. LOAD
D. GET
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 55 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Program Components
Are We on Track?
The programmer can create new, higher level statements in Assembler Language using the
______________ facility.
Review © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 56 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview Topic: Program Components
Topic Summary
Now that you have completed this topic, you should be able to:
Summary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 57 of 58
Assembler Programming Introduction
Unit: Assembler Language Overview
Unit Summary
Now that you have completed this unit, you should be able to:
Summary © Copyright IBM Corp., 2000, 2004. All rights reserved. Page 58 of 58