IBM Basic assembly language

IBM Basic assembly language

BAL (Basic Assembly Language) is a low-level language used on IBM mainframes from the earliest 360 series, through systems 370, 390 and z/Series. The earliest version was provided with the System/360 in 1964; the latest version is known as the IBM High Level Assembler (HLASM). Programmers utilizing this family of assemblers refer to them as ALC, for Assembly Language Common, or simply "assembler".

General characteristics

The architecture of IBM mainframes has taken many forms over the years, including System/360, System/370 XA, ESA/390, and z/Architecture. Each of these architectures has retained compatibility with most of the features of its predecessor. "BAL" uses the native instruction set of these machines. It is thus as close to the hardware as a typical programmer is likely to get.

The instruction set consists of the low-level operations supported by the hardware, such as
* "Load" (L) - copy a value from memory to a register,
* "Store" (ST) - copy a value from a register to memory,
* "Compare" (C) - compare a register value with a value in memory,
* "Shift" (SLL,SRL) - move the bits of a register left or right and
* "Execute Channel Program" (EXCP) - perform an I/O operation such as reading data from a disk or tape (usually by the Operating System). The extreme simplicity of these operations means that a program written in Assembler will usually be much longer and harder to read than an equivalent program in, say, COBOL or Fortran. In the past, the speed of hand-coded Assembler programs was often felt to make up for this drawback, but with the advent of optimizing compilers, "C" for the mainframe, and other advances, Assembler has lost much of its appeal. IBM continues to upgrade the Assembler, however, and it is still used when the need for speed or very fine control is paramount.

A small example

The following fragment shows how the logic "If SEX = 'M', add 1 to MALES; else, add 1 to FEMALES" would be performed in Assembler.

CLI SEX,'M' Male? BNE IS_FEM If not, branch around L 7,MALES Load current value of MALES into register 7 LA 7,1(,7) add 1 (pre-XA max value 24 bits) ST 7,MALES and store back the result B GO_ON Finished with this portionIS_FEM EQU * A label L 7,FEMALES If not male, load current value in FEMALES LA 7,1(,7) add 1 (pre-XA max value 24 bits) ST 7,FEMALES and storeGO_ON EQU * - rest of program -
*MALES DC F'0' defines 31 bit memory location (initially=0)FEMALES DC F'0' "" ""

The following is the ubiquitous Hello world program, and would, executing under an IBM Operating systems such as OS VS/1 and MVS, display the words 'Hello World' on the operator's console:

HELLO CSECT The name of this program is 'HELLO'
* Register 15 points here on entry from Op/sys or caller. USING *,12 Tell assembler what register we are using for pgm. base STM 14,12,12(13) Save registers 14,15,and 0 thru 12 in callers Save area LR 12,15 Set up base register with programs entry point address LA 15,SAVE Now Point at our own save area ST 15,8(13) Set forward chain ST 13,4(15) Set back chain LR 13,15 Now switch to new save area
* -end of housekeeping (similar for most programs) - WTO 'Hello World' Write To Operator (Operating System macro)
* L 13,4(13) point at caller's-provided save area LM 14,12,12(13) Restore registers as on entry BR 14 Return to caller
* SAVE DS 18A Define 18 fullwords for calling END HELLO This is the end of the program
Note: "WTO" is an Assembler macro that generates an Operating System call Because of saving registers and later restoring and returning, this small program is usable as a batch program invoked directly by the operating system Job control language (JCL) like this // EXEC PGM=HELLOor, alternatively, it can be CALLed as a subroutine from such a program. CALL HELLO

Types of instructions

Three main types of instructions are found in the source code of a program written in Assembler.

Machine instructions (Mnemonic)

As with any language, the heart of Assembler programming is understanding the instructions that usually have, in this case, a "one-to-one" relationship with machine instructions. The full mnemonic instruction set is described in the "Principles of Operation" manual for each processor. The general syntax for the instruction operands is fairly straightforward
* The target for an instruction appears first, then the source on the right, (as with "a = 6" in C or Algol programming). After one or more blanks, any comment may follow on the same line. A line starting with an asterisk (*) is considered entirely comments.Examples: * This is a comment line L 3,ZIGGY load the fullword integer stored at location labeled 'ZIGGY' into general register 3 SLA 4,5 shift the value in general register 4 left by 5 bits MVC TARGET,SOURCE move characters from memory 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'

Assembler instructions

The assembler itself needs instructions from the programmer too. For instance, CSECT means "start a section of code here"; DC means define a constant to be placed in the object code.

Macros and conditional assembly

The programmer can group instructions together into macros and add them to a library, which can then be invoked in other programs, usually with parameters, much 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.

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) for example, 'GETMAIN' dynamically allocates a block of memory, and 'GET' retrieves the next logical record from a file.

External links

* [http://publibz.boulder.ibm.com/bookmgr_OS390/libraryserver/zosv1r7/ z/OS library—look for "High Level Assembler" and "Principles of Operation" on the left]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Assembly language — See the terminology section below for information regarding inconsistent use of the terms assembly and assembler. Motorola MC6800 Assembly Language An assembly language is a low level programming language for computers, microprocessors,… …   Wikipedia

  • IBM High Level Assembler (HLASM) — For a discussion of high level assemblers in general, see High level assembler. Wikipedia by [SERVERlocalurl:NAMESPACE:HLASM|action=edit expanding it] . IntroductionHLASM is IBM s high level assembler product for its z/OS, z/VSE, z/VM and z/TPF… …   Wikipedia

  • IBM PC compatible — computers are those generally similar to the original IBM PC, XT, and AT. Such computers used to be referred to as PC clones, or IBM clones since they almost exactly duplicated all the significant features of the PC architecture, facilitated by… …   Wikipedia

  • IBM System/34 — The IBM System/34 was a minicomputer marketed by IBM from 1978 to 1983. It was a multi user, multi tasking successor to the single user System/32. Most notably, it included two very different processors, one based on System/32 and the second… …   Wikipedia

  • IBM 1130 — The IBM 1130 Computing System was introduced in 1965. It was IBM s least expensive computer to date, and was aimed at price sensitive, computing intensive technical markets like education and engineering. The IBM 1800 was a process control… …   Wikipedia

  • IBM 700/7000 series — The IBM 700/7000 series was a series of large scale (mainframe) computer systems made by IBM through the 1950s and early 1960s. The series included several different, incompatible processor architectures. The 700s used vacuum tube logic and were… …   Wikipedia

  • IBM System i — The IBM System i is IBM s previous generation of systems designed for IBM i users, and was subsequently replaced by the IBM Power Systems in April 2008. In 2006, the platform was rebranded to System i as part of IBM s Systems branding initiative …   Wikipedia

  • IBM System/370 — The IBM System/370 (often: S/370) was a model range of IBM mainframes announced on June 30, 1970 as the successors to the System/360 family. The series maintained backward compatibility with the S/360, allowing an easy migration path for… …   Wikipedia

  • Business application language — B.A.L. redirects here. For the IBM mainframe Assembly language, see Basic assembly language; for other topics see BAL In computer programming, BAL (an acronym for Business Application Language) refers to a high level programming language similar… …   Wikipedia

  • IBM 7090 — The IBM 7090 was a second generation transistorized version of the earlier IBM 709 vacuum tube mainframe computers and was designed for large scale scientific and technological applications . The 7090 was the third member of the IBM 700/7000… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”