ARCHITECTURE AND INSTRUCTIONS

division. Thus 19/7 is2, whereas 19 MOD7 is 5.

Arithmetic operators may always be applied to a pair of numeric operands, and the result will be numeric. The rules for applying arithmetic operators on memory-addressing operands are more restrictive: such opera- tions are valid only if the result has a meaningful physical interpretation.

For example, the product of two memory addresses has no meaningful interpretation. What segment would it be in? What offset would it have? Hence, it is a prohibited operation.

The difference of two memory addresses in the same segment is the numeric distance between them - the difference in their offsets.

The only other meaningful arithmetic opera- tion on a memory address is adding or subtracting a numeric value. Thus SUM+2, CYCLE-5, and NOLDONE-GO would all -be valid expressions in the sample program. SUM -CYCLE would not be a valid expres- sion because they are in different segments.

NOTE: The value of SUM+2 is a memory address two bytes beyond SUM in the MY _ DATA segment; it is not the numeric value that is 2 plus-the-contents-of-Iocation-SUM. Such contents are not known until program execution, whereas expressions are evaluated at assembly time.

logical Operators

The logical operators are bit-by-bit AND, OR, XOR (exclusive-or), and NOT.

The operands of logical operators must be numeric only - memory-address operands are not allowed - and the result will be numeric. This is shown by:

1010101 010101010B AND 11001100110011 OOB is 1000100010001000B;

1100110011001100B OR 1111000011110000B is 1111110011111100B

NOT 1111111111111111 B is OOOOOOOOOOOOOOOOB and

1111000011110000B XOR SUM is invalid.

As an example of logical operators, consider:

IN AL,PORT_VAL

OUT PORT_VAL AND OFEH,AL

The IN instruction gets input from PORT _VAL, wherever that is.

Execution of the OUT instruction sends out- put to port PORT3AL AND OFEH, which is either the same port, if PORT_VAL is even, or the next lower-numbered port, if PORT _VAL is odd. The actual port value of the OUT instruction is determined when the instruction is assembled, not when it is executed.

Observe that AND, OR, XOR, and NOT are instruction mnemonics as well as ASM-86 operators. As ASM-86 operators, they cause a value to be computed when the program is being assembled. As instruction mnemonics, they perform their roles when the program is being executed:

AND

OX,PORT_VAL AND OFEH

will cause the assembler to compute the value of PORT_VAL AND OFEH and then gener- ate an AND-immediate instruction contain- ing that value in its data field. When this instruction is later executed, it will cause the contents of the DX register to be ANDed with that value and the result placed in the DX register.

Relational Operators

1)Equal (EQ)

2)not-equal (NE)

3)less-than (LT)

4)greater-than (GT)

5)less-than-or-equal (LE)

6)greater-than-or-equal (GE)

PORT_VAL LT 5 is a relational operator. The two operands must both be numeric or must both be memory addresses in the same segment. The result is always a numeric value. It will be 0 if the relationship is false,

2-26

Page 61
Image 61
Intel 210200-002 manual AL,PORTVAL OUT Portval and OFEH,AL