ARCHITECTURE AND INSTRUCTIONS

MY_CODE SEGMENT

UP_COUNT PROCNEAR

ADDCX,1

RETSTART:

U~COUNT ENDP

START:

CALLUPCOUNT

END START

CALLUPCOUNT

Instruction Statements

HLT

MY_CODE ENDS

ENDSTART

RET in a procedure, just as there may be more than cine HLT in a program.

The last instruction in a procedure (program) need not be a RET or (HLT); but, if it isn't, that instruction should be a jump back to some- where within the procedure (program).

The ENDP (END) tells the assembler where the procedure (program) ends, but does not cause the assembler to generate a RET (HLT) instruction.

Termination Statements

With one exception, each terminating state- ment is paired up with some beginning statement. For example, SEGMENT and ENDS, PROe and ENDP. These terminat- ing statements are described with their corresponding beginning statements.

The one exception is END, which flags the end of the source program. It tells the assembler that there are no more instruc- tions to assemble. The form of the END statement is

END expression

where the expression must yield a memory- address value. That address is the address of the first instruction to be executed when the program is executed.

The following example illustrates the use of the END statement:

The instruction statements, for the most part, correspond to the instructions of the 8088 processor. Each instruction statement causes the assembler to generate one 8088 instruc- titm. An 8088 instruction consists of an opcode field and fields specifying the operand- addressing mode (mod field, rim field, reg. field).

So the instruction statements in ASM-86 must contain an instruction mnemonic as well as sufficient addressing. information to p~rmit the assembler to generate the instruc- tion.

INSTRUCTION MNEMONICS

Most of the instruction mnemonics are the same as the symbolic opcode names for the 8088 instructions. Some additional instruc- tion mnemonics, NIL and NOP, make the assembly language more versatile.

No-Operation

The instruction mnemonic NOP causes the assembler to generate the I-byte instruction that exchanges the contents of the AX register with the contents of the AX register (hexadecimal opcode 90). Besides not doing anything, NOP doesn't waste any time not doing it, since it doesn't make any memory accesses. Does it seem strange to waste precious memory locations on instructions that do nothing? There are good reasons for doing so.

The NOPs might serve as placeholders for instructions to be filled in later, possibly when the program is executing - an old trick.

2-37

Page 72
Image 72
Intel 210200-002 manual Retstart