Three main types of instructions are found in the source code of a program written in assembler.
Assembler instructions Assembler instructions, sometimes termed
directives, pseudo operations or pseudoops on other systems, are requests to the assembler to perform various operations during the code generation process. For instance, CSECT means "start a section of code here"; DSECT provides data definitions for a structure, but generates no code; DC defines a constant to be placed in the object code. One of the more important assembler instructions is USING, which supports the base-displacement addressing of the S/360 architecture. It guides the assembler in determining what base register and offset it should use for a relative address. In BAL, it was limited to the form USING base,reg-1,...,reg-n Machine instruction addresses on S/360 specify a
displacement (0–4095 bytes) from the value in a
base register; while later versions of the architecture added relative-address formats, the older formats are still used by many instructions. USING allows the programmer to tell the assembler that the specified base registers are assumed to contain the address of "base", base+4096 (if multiple registers are specified), etc. This only provides a shortcut for the programmer, who otherwise would have to specify the base register in each instruction. Programmers are still responsible for actually loading the address of "base" into the register before writing code that depends on this value. The related DROP assembler instruction nullifies a previous USING.
Machine instructions (mnemonic) There is a one-to-one relationship with
machine instructions. The full mnemonic instruction set is described in the
Principles of Operation manual for each instruction set. Examples: * This is a comment line * Load the fullword integer stored at the * location labeled 'ZIGGY' into general register 3: L 3,ZIGGY SLA 4,5 shift the value in general register 4 left by 5 bits MVC TARGET,SOURCE move characters from location 'SOURCE' to 'TARGET' AP COUNT,=P'1' add 1 to value in memory location 'COUNT' (packed decimal format) B NEXT unconditional branch to label 'NEXT' HERE EQU * This is a label CLC TARGET,=C'ADDRESS' Compare memory location 'TARGET' to string 'ADDRESS' BE THERE branch if equal to program label 'THERE' Generally accepted standards, although by no means mandatory, include the identification of general purpose registers with mnemonics. Unlike assemblers for some other systems, such as
X86 assembly language, register mnemonics are not reserved symbols but are defined through EQU statements elsewhere in the program. This improves readability of assembler language programs and provides a
cross-reference of register usage. Thus typically you may see the following in an assembler program: R3 EQU 3 ... L R3,ZIGGY Some notable
instruction mnemonics are BALR for a call storing the return address and condition code in a register,
SVC, DIAG, and ZAP. within . --> System/360 machine instructions are one, two, or three
halfwords in length (two to 6 bytes). Originally there were four instruction formats, designated by the first two bits of the operation code field;
z/Architecture added additional formats.
Macros and conditional assembly The Basic Programming Support assembler did not support
macros. Later assembler versions beginning with Assembler D allow the programmer to group instructions together into macros and add them to a library, which can then be invoked in other programs, usually with parameters, like the preprocessor facilities in C and related languages. Macros can include conditional assembler instructions, such as AIF (an ‘if’ construct), used to generate different code according to the chosen parameters. That makes the macro facility of this assembler very powerful. While multiline macros in C are an exception, macro definitions in assembler can easily be hundreds of lines.
Operating system macros Most programs will require services from the
operating system, and the OS provides standard macros for requesting those services. These are analogous to
Unix system calls. For instance, in
MVS (later z/OS), STORAGE (with the OBTAIN parameter) dynamically allocates a block of memory, and GET retrieves the next logical record from a file. These macros are operating-system-dependent; unlike several higher-level languages, IBM mainframe assembly languages don't provide operating-system-independent statements or libraries to allocate memory, perform I/O operations, and so forth, and different IBM mainframe operating systems are not compatible at the system service level. For example, writing a sequential file would be coded differently in z/OS and in z/VSE. ==Examples==