IBM Basic Assembly Language - Examples


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 ST 7,MALES store back the result B GO_ON Finished with this portion IS_FEM EQU * A label L 7,FEMALES Load current value in FEMALES into register 7 LA 7,1(,7) add 1 ST 7,FEMALES store back the result GO_ON EQU * - rest of program - * MALES DC F'0' Counter for MALES (initially=0) FEMALES DC F'0' Counter for FEMALES (initially=0)

The following is the ubiquitous Hello world program, and would, executing under an IBM operating system such as OS/VS1 or 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 OPSYS or caller. 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 USING *,12 Tell assembler what register we are using for pgm. base 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 Set R13 to address of new save area * -end of housekeeping (similar for most programs) - WTO 'Hello World' Write To Operator (Operating System macro) * L 13,4(13) restore address to caller-provided save area LM 14,12,12(13) Restore registers as on entry SR 15,15 Set register 15 to 0 so that the return code (R15) is Zero BR 14 Return to caller * SAVE DS 18F Define 18 fullwords to save calling program registers END HELLO This is the end of the program

"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


or, alternatively, it can be CALLed as a subroutine from such a program.


Read more about this topic:  IBM Basic Assembly Language

Other articles related to "example, examples":

... For example, an acronym is a word formed from the initial letter or letters of each of the successive parts or major parts of a compound term (as radar) ... In the examples ananym and metanym, the correct forms (anonym and metonym) were pre-occupied by other meanings ... Other, late 20th century examples, such as hypernym and characternym, are typically incorrectly formed neologisms for which there are more traditional words formed in -onym (hyperonym and ...
Proverbs in Advertising
... Tatira has given a number of examples of proverbs used in advertising in Zimbabwe ... However, unlike the examples given above in English, all of which are anti-proverbs, Tatira's examples are standard proverbs ... customer smile, in one of the Zimbabwean examples "both the content of the proverb and the fact that it is phrased as a proverb secure the idea of a secure time-honored relationship between the company and ...
English Orthography - Spelling Irregularities - "Ough" Words
... though /oʊ/ as in toe (other examples dough) tough /ʌf/ as in cuff (other examples rough, enough) cough /ɒf/ as in off (other examples Gough (name, some pronunciations)) hiccough (a ...

Famous quotes containing the word examples:

    No rules exist, and examples are simply life-savers answering the appeals of rules making vain attempts to exist.
    André Breton (1896–1966)

    There are many examples of women that have excelled in learning, and even in war, but this is no reason we should bring ‘em all up to Latin and Greek or else military discipline, instead of needle-work and housewifry.
    Bernard Mandeville (1670–1733)

    In the examples that I here bring in of what I have [read], heard, done or said, I have refrained from daring to alter even the smallest and most indifferent circumstances. My conscience falsifies not an iota; for my knowledge I cannot answer.
    Michel de Montaigne (1533–1592)