ARCHITECTURE AND INSTRUCTIONS

and OFFFFH (16 bits of l's) if the relation- ship is true.

Using a relational operator:

MOV

BX,PORT_VAL LT 5

The assembler will assemble

MOV BX,OFFFFH

if the value of PORT_VAL is < 5;

otherwise the assembler will assemble

MOV BX,O

At first it may appear that relational opera- tors are not useful. It's not often that you want to generate an instruction with a field that contains either 0 or OFFFFH, and no other choices. However, by combining rela- tional operators with logical operators, the two relational results of 0 and OFFFFH can be molded into any numeric values you desire:

MOV BX,((PORT_VAL LT 5)AND 20)

&OR «PORT_VAL GE5) AND 30)

will assemble

MOV BX,20

if PORT_VAL is less than 5, and

MOV BX,30

Statements

There are two kinds. of ASM-86 program statements: instruction statements (MOV, ADD, JMP, etc.) and directive statements (DB, SEGMENT, EQU, etc.)

Each instruction statement causes the assem- bler to generate an instruction in the object code. Directive statements tell the assembler what kind of code to generate for succeed- ing instruction statements. The directive statement

DB ?

tells the assembler that MY_ PLACE IS defined as a byte. The assembler allocates a memory address for MY_PLACE. Later, when the assembler encounters the instruc- tion statement

INC MY_PLACE

it will generate an object code instruction to increment the contents of MY_ PLACE. Because of the previously-encountered direc- tive statement, the assembler will know to place a '0' (to indicate a byte) in the w field of the increment instruction.

The formats of the two kinds of statement are similar. The instruction statements are of the form

label: mnemonic argument,,,.,argument ;comment

otherwise.

Note the generous use of parentheses to force the order that operators are applied. If you always use parentheses to make the ordering explicit, you won't have to memorize the rules about which operators get evaluated first.

Analytic and Synthetic Operators

The directive statements are of the form

name directive argument, ... ,argument ;comment

The label in an instruction statement is fol- lowed by a colon, whereas the name in a directive statement is not. This highlights the difference between the two kinds of statements.

The analytic operators decompose memory- address operands into their components, while synthetic operators build memory- address operands from their components. A discussion of these operators is presented after we learn more about memory-address operands. (see page 2-30)

A label associates a symbolic name with the location of an instruction. A label can be used as an operand in a jump or call instruction.

The name in a directive statement has no relation to an instruction location and can never be jumped to.

2-27

Page 62
Image 62
Intel 210200-002 manual Assembler will assemble