ARCHITECTURE AND INSTRUCTIONS

String Constant

A string constant is one or two characters enclosed with apostrophes. Strings of more than two characters are permitted in res- tricted cases, but are not discussed here. An apostrophe itself may be included in a string constant by writing it as two consecutive apostrophes. Examples of string constants are 'A', 'AB', and "". The last example is the string consisting of the apostrophe character.

The value of a string constant is the ASCII code of the character(s) in the string. For example, the value of 'A' is 41 H and the value of 'AB' is 4l42H. Thus, string constants and whole-number constants can be used inter- changeably.

COMMENTS

Any sequence of characters following a semi- colon (;) up to the end of the line are com- ments. They are ignored by the assembler and should be used generously in your pro- gram to document what you are doing. While comments like

INC CX ;increment CX

Operands with numeric values are constants, or identifiers that represent constants. Some numeric-valued operands, appearing in our sample program are 100 and PORT_VAL. The permissible range of values for such oper- ands is from -65,535 to +65,535.

Note that the value of an operand may be negative, but a constant is never negative. A minus sign can be written in front of a con- stant, but is never considered a part of the constant; it is an arithmetic operator.

Memory-address operands are frequently identifiers, such as SUM and CYCLE in the sample program. The value of a memory address is not simply a number; it is a set of components, each component generally being a number. One component is the 16 most- significant bits of the segment starting address where the memory address is contained. The four least-significant bits of a segment start- ing address are always zeros.

Another component is the offset address within the segment. These two components are referred to as the segment and offset of the memory-address operand.

convey little information, comments like

INC CX ;increment outer loop counter·

make a program more readable.

Expressions

One more building block, namely expres- sions, must be introduced before we can build statements. Expressions are built up from some of the tokens just described.

Loosely speaking, an expression is a sequence of operands and operators combined to pro- duce a value at program assembly time. How are operands and operators combined to produce the value of an expression?

OPERANDS

An operand is something that has either a numeric value or a memory address value.

Another operand is an expression itself, enclosed in parentheses, and used in some bigger expression, as in 3*(PORT_VAL+5).

OPERATORS

An operator takes the value of one or more operands and produces a new value. There are five kinds of operators in ASM-86

1)arithmetic operators

2)logical operators

3)relational operators

4)analytic operators

5)synthetic operators

Arithmetic Operators

Arithmetic operators are the familiar addi- tion operator (+), subtraction operator (-), multiplication operator (*), and division operator (/). Another arithmetic operator, MOD, produces the remainder after doing a

2-25

Page 60
Image 60
Intel 210200-002 manual INC CX increment CX