HLASM Language Reference

HLASM Language Reference HLASM Language Reference

faculty.cs.niu.edu
from faculty.cs.niu.edu More from this publisher
22.02.2015 Views

Terms, Literals, and Expressions Terms, Literals, and Expressions The most basic element of the assembler language is the term. Terms may be used alone, or in combination with other terms in expressions. This section describes the different types of terms used in the assembler language, and how they can be used. Terms A term is the smallest element of the assembler language that represents a distinct and separate value. It can, therefore, be used alone or in combination with other terms to form expressions. Terms are classified as absolute or relocatable, depending on the effect of program relocation upon them. Program relocation is the loading of the object program into storage locations other than those originally assigned by the assembler. Terms have absolute or relocatable values that are assigned by the assembler or that are inherent in the terms themselves. A term is absolute if its value does not change upon program relocation. A term is relocatable if its value changes by n if the origin of the control section in which it appears is relocated by n bytes. Terms in Parentheses: Terms in parentheses are reduced to a single value; thus the terms in parentheses, in effect, become a single term. You can use arithmetically combined terms, enclosed in parentheses, in combination with terms outside the parentheses, as follows: 14+BETA-(GAMMA-LAMBDA) When the assembler encounters terms in parentheses in combination with other terms, it first reduces the combination of terms inside the parentheses to a single value which may be absolute or relocatable, depending on the combination of terms. This value is then used in reducing the rest of the combination to another single value. You can include terms in parentheses within a set of terms in parentheses: A+B-(C+D-(E+F)+1) The innermost set of terms in parentheses is evaluated first. Any number of levels of parentheses are allowed. A level of parentheses is a left parenthesis and its corresponding right parenthesis. An arithmetic combination of terms is evaluated as described in “Expressions” on page 44. Figure 12 summarizes the various types of terms, and gives a reference to the page number that discusses the term and the rules for using it. Figure 12 (Page 1 of 2). Summary of Terms Terms Term can be absolute Term can be relocatable Value is assigned by assembler Value is inherent in term Symbols X X X 29 | Literals X X X 41 Self-defining terms X X 34 Page reference 28 HLASM V1R5 Language Reference

Terms, Literals, and Expressions Figure 12 (Page 2 of 2). Summary of Terms Terms Location counter reference Symbol length attribute Other data attributes Term can be absolute Notes: 1. Other valid data attributes are S and I. Term can be relocatable Value is assigned by assembler Value is inherent in term X X 36 X X 38 X X 40 Page reference | For more information about absolute and relocatable expressions, see “Absolute | and Relocatable Expressions” on page 47. Symbols You can use a symbol to represent storage locations or arbitrary values. If you write a symbol in the name field of an instruction, you can then specify this symbol in the operands of other instructions and thus refer to the former instruction symbolically. This symbol represents a relocatable address. You can also assign an absolute value to a symbol by coding it in the name field of an EQU instruction with an operand whose value is absolute. This lets you use this symbol in instruction operands to represent: Registers Displacements in explicit addresses Immediate data Lengths Implicit addresses with absolute values For details of these program elements, see “Operand Entries” on page 85. The advantages of symbolic over numeric representation are: Symbols are easier to remember and use than numeric values, thus reducing programming errors and increasing programming efficiency. You can use meaningful symbols to describe the program elements they represent. For example, INPUT can name a field that is to contain input data, or INDEX can name a register to be used for indexing. You can change the value of one symbol that is used in many instructions (through an EQU instruction) more easily than you can change several numeric values in many instructions. | If the symbols are relocatable, the assembler can calculate displacements and | assign base registers for you. Symbols are entered into a cross reference table that is printed in the Ordinary Symbol and Literal Cross Reference section of the assembler listing. The cross reference helps you find a symbol in the source and object section of the listing because it shows: Chapter 2. Coding and Structure 29

Terms, Literals, and Expressions<br />

Figure 12 (Page 2 of 2). Summary of Terms<br />

Terms<br />

Location counter<br />

reference<br />

Symbol length<br />

attribute<br />

Other data<br />

attributes<br />

Term<br />

can be<br />

absolute<br />

Notes:<br />

1. Other valid data attributes are S and I.<br />

Term can<br />

be<br />

relocatable<br />

Value is<br />

assigned<br />

by<br />

assembler<br />

Value is<br />

inherent<br />

in term<br />

X X 36<br />

X X 38<br />

X X 40<br />

Page<br />

reference<br />

| For more information about absolute and relocatable expressions, see “Absolute<br />

| and Relocatable Expressions” on page 47.<br />

Symbols<br />

You can use a symbol to represent storage locations or arbitrary values. If you<br />

write a symbol in the name field of an instruction, you can then specify this symbol<br />

in the operands of other instructions and thus refer to the former instruction<br />

symbolically. This symbol represents a relocatable address.<br />

You can also assign an absolute value to a symbol by coding it in the name field of<br />

an EQU instruction with an operand whose value is absolute. This lets you use this<br />

symbol in instruction operands to represent:<br />

Registers<br />

Displacements in explicit addresses<br />

Immediate data<br />

Lengths<br />

Implicit addresses with absolute values<br />

For details of these program elements, see “Operand Entries” on page 85.<br />

The advantages of symbolic over numeric representation are:<br />

Symbols are easier to remember and use than numeric values, thus reducing<br />

programming errors and increasing programming efficiency.<br />

You can use meaningful symbols to describe the program elements they<br />

represent. For example, INPUT can name a field that is to contain input data, or<br />

INDEX can name a register to be used for indexing.<br />

You can change the value of one symbol that is used in many instructions<br />

(through an EQU instruction) more easily than you can change several numeric<br />

values in many instructions.<br />

| If the symbols are relocatable, the assembler can calculate displacements and<br />

| assign base registers for you.<br />

Symbols are entered into a cross reference table that is printed in the Ordinary<br />

Symbol and Literal Cross <strong>Reference</strong> section of the assembler listing. The cross<br />

reference helps you find a symbol in the source and object section of the listing<br />

because it shows:<br />

Chapter 2. Coding and Structure 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!