ARCHITECTURE AND INSTRUCTIONS

The symbolic register names used in ASM-86 are the names that are used for the registers throughout this book ~

AX

BL

CH

01

BX

CL

OH

CS

CX

OL

BP

OS

DX

AH

SP

ES

AL

BH

SI

SS

InpuVOutput

Both the IN and OUT instructions have a I-bit :wfield and an 8-bit port number field. The port numbers are simply specified in the source code by "IN AX,Y and "OUT ~,AX". The ~ field is specified more subtly by the presence of the AX in "IN AX,S" and "OUT 2,AX". Input/ output always uses AX when words are involved and AL when bytes are involved. So the appearance of AX instead of AL in the IN and OUT instructions indicates that the ~ field is a 1. (The AMS-86 conven- tion is to place the destination before the source; hence AX precedes port number on the IN instruction and follows it on the OUT instruction).

Jump Cycle

Another example of a symbolic name in the above program is the label CYCLE on the IN instruction. This permits the JMP instruction to refer to the location of the IN instruction by name as in "JUMP CYCLE." The assembler now has enough information to

determine that this is a jump backwards of seven bytes and can generate a -7 in the appropriate field of the JMP instruction.

A Complete Program

In the previous section, we used a fragment of an ASM-86 program. To make that frag- ment into a complete program, we need some additional statements (see below).

This entire program will reside in a single segment in the 8088 memory. During the assembly process, we don't know (nor do we care) where that segment will be located; that decision will be made prior to loading the segment into memory.

During the assembly process, we refer to the starting address of the segment by the sym- bolic name IN_AND_OUT. Lines I and 7 delimit the extent of the segment; line 1 introduces the segment name IN_AND_ OUT, and line 7 marks the end of the segment (ENDS).

Line 8 flags the end of the source program, thereby telling the assembler that there are no more lines to assemble. Furthermore, it indi- cates that when the program is executed, it should start with the instruction labeled CYCLE (line 3).

The object code generated by the assembler specifies the contents of all relevant memory locations plus this starting address.

1.

IN_ANQOUT

SEGMENT

 

;start of segment

2.

 

ASSUME

CS: I~ANO_OUT

;that'swhat'sin CS

3.

CYCLE:

IN

AX,5

 

4.

 

INC

AX

 

5.

 

OUT

2,AX

 

6.

 

JMP

CYCLE

 

7. IN_AN~_OUT

ENDS

 

;end of segment

8.

 

END

CYCLE

;end of assembly

2-20

Page 55
Image 55
Intel 210200-002 manual Inanqout Segment