
ARCHITECTURE AND INSTRUCTIONS
However, the instruction could move either a byte or a word. The assembler must know which is being moved, so it can generate the correct instruction. For this reason, the
For example:
ALPHA DB?
BETA DB?
MOV | SI,OFFSET ALPHA |
MOV | DI,OFFSET BETA |
MOVS | BETA,ALPHA |
The presence of BETA and ALPHA in the MOVS statement tells the assembler to gen- erate a MOVS instruction that moves bytes, because the TYPE components of both BETA and ALPHA are BYTE. Further, from the SEG components of BETA and ALPHA, the assembler determines if the
Details of
Sample One:
Translate the values from input port I into a Gray code and send result to output port 1.
operands of the MOVS instruction are inac- cessible segments. The OFFSET components of ALPHA and BETA are ignored.
Like MOVS, the other four string primitives contain operands, MOVS and CMPS have two operands, while SCAS, LODS, and STOS have one. For example:
CMPS BETA,ALPHA
SCAS ALPHA
LODS ALPHA
STOS BETA
XLAT also requires an operand; the item that was moved into BX to serve as the trans- lation table. The SEG component of this operand enables the assembler to determine if the translation table is in a currently access- ible segment; the OFFSET component is ignored. An example of an XLAT statement is as follows:
MOV BX,OFFSET TABLE
XLAT TABLE
MY_DATA | SEGMENT |
|
|
GRAY | DB | 18H,34H,05H,06H,09H,OAH,OCH,11 H, 12H,14H | |
MY_DATA | ENDS |
|
|
MY_CODE | SEGMENT |
|
|
| ASSUME | CS:MY _CODE, DS:MY _DATA |
|
GO: | MOV | AX,MY_DATA | ;establish data segment |
| MOV | DS,AX |
|
| MOV | BX,OFFSET GRAY | ;translation table into BX |
CYCLE: | IN | AL,1 | ;read in next value |
| XLAT | GRAY | ;translate it |
| OUT | 1,AL | ;output it |
| JMP | CYCLE | ;and repeat |
| ENDS |
|
|
| END | GO |
|