Professional Documents
Culture Documents
The 8086 microprocessor was a 16 bit processor. By this term what we mean is that firstly it
has a 16 bit wide data bus which, effectively means that it can operate on 16 bit of data from
memory and ports. Secondly, the ALU and registers were designed to work on 16 bits of
data.
Since the 8086 microprocessor has a 20 bit wide address bus, it can effectively address a
maximum of 220 or 1048576 memory locations where each of these locations references to a
byte wide memory register. Therefore, we can say that the 8086 can directly access 1 M byte
of memory.
One thing about the 8086 operation that we have to always remember is that when the first
byte of a 16 bit data is at a even memory address, the 8086 can read (or write) 16 bits (2
bytes) in one cycle. However, in the other case, that is the first byte of a 16 bit data is at an
odd memory location, the 8086 CPU will read (or write) the first byte in one bus cycle
followed by the second byte in the next bus cycle. This effectively cumulates to the fact that
must be always remembered:
1. A 16 bit data will be read in one cycle if located at an even memory address.
2. A 16 bit data will be read in two cycles if located at an odd memory location.
With the 8086 processor, Intel also released the 8088 microprocessor. The 8088 is a scaled
down version of the 8086 that is internally a 16 bit microprocessor having the same ALU and
register file as the 8086 microprocessor. It also has the same 20 bit address bus but the
difference between the 8086 and 8088 lies in the width of the external data bus. The 8088 has
an 8 bit data bus thereby enabling it to read or write only one byte of data from memory or
I/O ports.
1
Since the 8086 followed the 8085, designers pressed for the need for processor speed up. By
speedup, we means to effectively increase the execution speed of a microprocessor. General
terminology for increase in speed (or execution rate) of a microprocessor is called speedup.
The Intel 8086 used advanced processing techniques to speed up execution. For this, the 8086
was internally divided into two functional units:
1. THE EXECUTION UNIT (EU)
2. THE BUS INTERFACE UNIT (BIU)
Both, these units are designed to work simultaneously. It is therefore, obvious that the
processing time required for an instruction will be reduced in comparison to a processor
having only a single unit working at a time. The reason for this is in the division of work
between the two, where, the BIU is designed to function as the external interface of the
processor. Effectively thus the BIU generates addresses and sends them on the address bus
and then reads (or writes) data from memory (and ports) through the data bus. Therefore the
BIU is the interface for the external buses to the EU. In short the BIU is the interface of the
EU to the outside world.
The Execution unit of the 8086 handles all controlling functions such as telling the BIU
where to fetch instructions (or data) from, where to write data to, and does the instruction
decoding as well as does all of the instruction execution.
The division of the 8086 architecture into these two units can be easily seen in the above
figure. Now we shall consider these two units in detail.
2
THE EXECUTION UNIT
Observing the figure for the architecture it can be seen that the 8086 execution unit may be
divided into the following parts:
(a) Instruction Decoder and Control Subsystem
(b) Arithmetic Logic Unit (ALU)
(c) FLAG Register
(d) General Purpose Registers
(e) Index and Pointer Registers
The EU contains the instruction decoder which translates the received instruction from the
BIU and performs the necessary operations. The instruction decoder and the control system
perform the proper sequencing and release the corresponding synchronization signals for the
proper operation of the microprocessor to achieve the task specified by the instruction being
decoded.
A 16 bit ALU which can perform addition, subtraction, multiplication, division and logical
operations such as AND, OR, XOR, NOT is present in the EU. The 8086 ALU can be made
to work on 16 bit or 8 bit data depending on the instruction. On completing the task the ALU
sets the corresponding flags such as zero flag, carry flag etc., of the flag register.
15 14 13 12 11 10 9 b 7 6 b 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
OF — Overflow flag TF — Trap flag AF — Auxiliary carry flag
DF — Direction flag SF — Sign flag PF — Parity flag
IF — Interrupt flag ZF — Zero flag CF — Carry flag
8086/8088 Flag register
FLAG Register
The 8086/8088 flag register is shown in above figure. The 8086 has a 16 bit flag register
which contain 9 active flags. These 9 active flags can be divided into two types.
(a) Conditional flags: Conditional flags are set or reset on the basis of the result generated
from the ALU. Conditional flags are also called status flags.
(b) Control flags: The 8086 contains three control flags which are used for controlling the
microprocessor. These flags are set or reset with the help of instructions that are put in
a program and are used to control program flow.
Specifically, we shall now first discuss the respective flags.
(1) Carry Flag: This conditional flag is set when a carry is generated in the ALU as shown
by the example given below.
e.g., ADD BA2FH and A43BH
Sol. 1011101000101111 (BA2FH)
1010010000111011 (A43BH)
(1) 0101111001101010 (5E6AH)
carry
3
Thus carry flag = 1 [Carry flag is set to shown the carry generated]
In the above operation we find that after two 16 bit numbers are added their sum is 17
bits wide. This excess bit which cannot be contained in a 16 bit register or memory
location is used to set the carry flag thereby can be used by a programmer to check the
state of a result. In 8 bits addition the carry flag is set if the result is in 9 bits.
(2) Auxiliary Carry Flag: This flag is set when a carry is generated from the lower nibble
when data being operated is 8 bit wide.
Here the MSB is used for the sign. What we are doing is we are adding two positive
numbers but the result comes to be negative number. This is because there is a carry from
the 6th bit (MSB is at 7th position for an 8 bit number) and it is added to the sign bit which
generates the wrong result. Here the carry from data bit at 6th position is added to the sign
bit at MSB location, which generate the wrong result.
This carry from the 6th bit location sets the overflow flag so that a programmer can check
the overflow flag and thereby be informed that the result is invalid (wrong). A
programmer can then initiate necessary steps to correct the results.
(6) Parity Flag: Parity flag is set when the ALU output has even parity and reset when
the ALU output has odd parity.
(7) Trap Flag: Used for single stepping through a program.
(8) Interrupt Flag: When the interrupt flag is set a program can be interrupted for
other more important operations. When it is reset the program execution cannot be
interrupted. (Refer to Section on Interrupts)
(9) Direction Flag: This is used with string operation.
Among the above flags 1 to 6 are conditional flags and flags 7 to 9 are control flags.
4
General Purpose Registers
The EU has four 16 bit general purpose register called the AX, BX, CX and DX Registers.
The AX register is also called the Accumulator and is one of the most important registers as
you shall read on later. When the 8086 ALU is programmed to work on 8 bit data then these
registers can be divided as follows
8 bit 8 bit
AX AH AL
BX BH BL
CX CH CL
DX DH DL
16 bit
The 8086 Registers
These 8 registers can be individually used to store 8 bit data. For 8 bit operations AL register
is the accumulator.
The Accumulator is a very important register as it has many features that others do not have.
The accumulator will be studied in great detail when we discuss the 8086 instructions.
The other register BX also called base register is also used in addressing purpose. The register
CX also called counter register is used as counting register for some instructions like LOOP
and REP. The register DX is also called as data register and is also used for some special
purpose.
There are several advantages of using internal registers for data storage:
(1) Since the CPU data transfer speed is generally higher than memory, the data transfer
is faster when during registers to ALU than memory to ALU.
(2) Secondly, since data is already in the EU (i.e., in these registers) this data can be used
faster than data from memory by the ALU.
In addition to the four 16 bit general purpose registers (AX, BX, CX and DX) the execution
unit contains three other registers collectively called the Index and pointer registers. These
registers are all of 16 bits.
These registers include SI (Source index), DI (Destination index), BP (Base pointer) and SP
registers. SI, DI and BP can be used for temporary storage of data. They can only be used to
store 16 bit data unlike the General purpose registers which can be used to store 16 bit data as
well as 8 bit data. Though these registers can be programmed for data storage but they are
actually designed to be used to store the offset address of a data byte (or word) in the data
segment. BP is actually used when passing argument to procedures (functions).
The actual address will be calculated by adding the contents of SI (or DI) to the segment base
so as to produce the effective address of the data byte (or word) in the data segment.
5
BUS INTERFACE UNIT (BIU)
The bus interface unit can be divided into the following units
1. Instruction Queue
2. Segment Registers
3. Instruction Pointer
4. Bus control and address generator
These functional parts can be very clearly seen in the figure for architecture.
The Queue
The 8086 microprocessor used a method called Pipelining for speed up. This is very clearly
demonstrated in the following figure. The instruction queue of the 8086 is a six byte first in
first out (FIFO) register and can be understood as a cache memory. The 8088 on the other
hand has a four byte queue.
When the EU is executing or decoding an instruction which doesn't require the use of external
buses or the segment registers, the BIU can be thought of as being idle. Since the 8086 BIU is
independently functional the BIU fetches the next instruction bytes for the EU and stores
them in the queue. Now when the EU becomes free it can directly access (read) the instruction
from the queue (which in obviously faster when compared to the 8085 processor). It is thus
observed that the 8086 can perform two operations at the same time that is a memory read (of
instruction bytes) and an execution whereas the 8085 can only do one of the above. Thus it is
obvious that the 8086 was much faster. This is demonstrated in the above figure. In the above
figure during time intervals t2 and t3, the 8086/8088 is doing two operations, one by the BIU
and one by the EU. This is faster compared to sequential execution where one operation is
performed after the other.
Segment Registers
Another new concept that was introduced in the 8086 was memory segmentation. Memory
segmentation allowed the 8086 microprocessor to be able to access only four 64 K byte seg-
ments within its 1 M byte memory range at any given time. These four segments are defined
by the data values stored in the four segments, registers, which are named as follows:
1. CS: Code segment Register
2. SS: Stack segment Register
3. DS: Data segment Register
4. ES: Extra Data segment Register.
The use of these registers is discussed in more detail in the topic memory segmentation.
6
By default the 8086 assumes that the code (or instructions) will be fetched from the memory
segment addressed by the CS register value. Similarly, the 8086 by default uses the DS regis-
ter to address the memory segment that shall hold data bytes to be used by the program and
the SS register to address the memory segment that shall be used as stack memory.
Therefore, the default segment registers usage is shown below with the registers that shall
contain the offset address
Segment Memory Default offset
register segment register
CS Code IP
DS Data BX, SI
SS Stack SP, BP
ES Extra DI and segment
override
The instruction pointer stores the offset of the physical address (due to memory segmentation) in the
segment of memory as defined by the segment registers. This, in short, means that the upper 16 bits of
the 20 bit address is stored in the segment register while the offset in the memory segment is stored in
the IP or the pointer and index registers.
The bus control and address generation logic subunit is one which handles the external bus as well as
calculates the effective address from where the instructions has to be fetched.
The address generation circuit is basically an adder where the content of the segment register and the
offset (pointer) registers are added to generate the actual physical address. The segment register is
always appended with four zeros (or multiplied by 10H) before being put in the adder. This is because
segments always start with address exactly divisible by 16 (10H) or at the paragraph boundary. The
output of the adder is the effective memory address or the physical address.
Now consider the following data in segment and offset registers.
3492H Segment Register
564AH Offset Register
The physical address is calculated as
Segment reg. * 10H + Offset reg. = physical memory address
Linear Addressing
The early microprocessors were organized to use the linearly addressed memory organization.
In linear addressing, the whole system memory is available to the processor as one linear
7
array. This was used in the earlier 8085 processor and is shown in following figure. In the
8085 the instruction pointer (IP) known as program counter (PC) was 16 bit wide which was
sufficient for the address of the memory location as the 8085 had a 16 bit address bus.
Segmented Addressing
Segmented memory addressing on the other hand divides the memory into many segments.
For example, the 1 MB memory is divided into smaller segments of 64 KB. This is because
the memory with in the segment is addressed by the pointer registers and they all are of 16 bit
wide (and so 216 bytes = 64 Kilobytes). Each of these segments can be considered as a linear
memory space as discussed above.
Thus if a segment registers has any arbitrary value XXXX H the 8086 assumes it points to
XXXX 0 H (or a 20 bit address where XXXX is the segment registers value). This is known
as the segment base address. Effectively this means that the segment registers is used to refer-
ence to the zeroth address of the segment. So to address within the segment we need other
8
register to indicate the offset of the memory location within the segment. When the offset
address stored in another register is added to the (segment) base address a valid 20 bit address
is produced. As all the address (offset) registers are of 16bit size they can address 64KB at
most within the segment.
Let DS has 3492H and SI has 24ABH then the actual physical address is calculated as:
3492H*10H=34920H
34920H Base Address
+ 24ABH Offset Address
36dCBH Physical Address
The register that is added is said to contain the offset address. This is very clearly understood
as shown in following figure.
In 8086/8088 there are four segment registers so microprocessor can address total of four
segments. Any executable program of 8086 microprocessor can have four segments and these
four segments can be addressed by four segment registers. So the executable program can use
up to 64KB x 4 (256KB) of memory at one time.
9
However the executable programs may not use the entire 64KB segment. In other words the
segment that executable programs use can be smaller than 64KB depending upon the
requirement. For example if a program requires only three data variables each of 16 bits, then
the data segment of that program is of 6 bytes.
The segment registers need not be same all the time during the run time. By changing these
segment registers values during the processor operation we can utilize different spaces in the
1 MB memory. Some time all the four segment registers can address same segment or some
time the segments can overlap. A typical segmented memory space of the 8086 is illustrated
in above figure.
As discussed earlier the addresses within a segment can range from 0000H to FFFFH. The
address within the segment is called offset or logical address. This is because the size of the
register holding the offset address is 16 bit and hence the range of address is from 0000H to
FFFFH.
Now the physical address is the address that is actually sent on the address bus (that is it is 20
bits wide). The offset or logical address is the offset from the location zero of a segment. The
segment address is the location pointed by the base address or the segment register.
The second advantage is the ability to reallocate. For example in a normal computer system
time sharing process is used. Time sharing involves allocating a fixed amount of time for
programs of different users. However, memory segmentation is a boon for time shared
systems as all user programs can be loaded into memory. The 8086 can then be made to work
on a time sharing basis on each of this program by just reloading the segment address of each
of these programs in the segment registers. Thus segmentation allows the programmer to
separately use each of the program loaded in memory by just reloading the 8086 segment
registers.
Addressing Modes
An addressing mode is a way of specifying the operands in any instruction. An operand
address provides a source of data for an instruction to process. Some instructions, such as
STC and RET, do not require an operand, whereas other instructions may have one or two
operands. Where there are two operands, the first operand is the destination, which contains
data in a register or in memory, and which is to be processed. The second operand is the
source, which contains either the data to be delivered (immediate) or the address (in memory
or of a register) of the data. The source data for most instructions is unchanged by the
operation. The three basic modes of addressing are register, immediate, and memory; memory
addressing consists of six types, for eight modes in all.
10
1. Register Addressing
For this mode, a register provides the name of any of the 8- or 16-bit registers. Depending
on the instruction, the register may appear in the first operand, the second operand, or
both, as the following examples illustrate:
MOV DX,WORD_MEM ;Register in first operand
MOV WORD_MEM,CX ;Register in second operand
Because processing data between registers involves no reference to memory, it is the
fastest type of operation.
2. Immediate Addressing
...
SUB BYTE_VAL,50 ;Immediate to memory (byte)
MOV WORD_VAL,40H ;Immediate in memory (word)
MOV DBWD_VAL,0 ;Immediate in memory (doubeword)
MOV AX,0245H ;Immediate to resister (word)
The instruction in the last example moves the immediate constant 0245H to AX. The 3-
byle object code is B84502, where B8 means “move an immediate value to AX” and the
following two bytes contain the value itself (4502H, in reverse byte sequence).
The use of an immediate operand provides faster processing than defining a numeric
constant in the data segment and referencing it in an operand.
The length of an immediate constant cannot exceed the length defined by the first
operand. In the following invalid example, the immediate operand is two bytes, but AL is
only one byte:
MOV AL,0245H ;Invalid immediate length
However, if an immediate operand is shorter than a receiving operand, as in
ADD AX,48H ;Valid immediate length
the assembler expand the immediate operand to two bytes. 0048H. and stores it in object
code as 4800H.
In this format, one of the operands references a memory location and the other operand
references a register. (The only instructions that allow both operands to address memory
directly are MOVS and CMPS.) DS is the default segment register for addressing data in
memory as DS:offset. Here are some examples:
11
ADD BYTE_VAL,DL ;Add register to memory (byte) MOV
BX,WORD_VAL ;Move memory to register (word)
4. Direct-Offset Addressing
Indirect addressing takes advantage of the computer's capability for segment:offset ad-
dressing. The registers used for this purpose are base registers (BX and BP) and index reg-
isters (DI and SI), coded within square brackets, which indicate a reference to memory.
An indirect address such as [DI] tells the assembler that the memory address to use will
be in DI when the program subsequently executes. BX, DI, and SI are associated with DS
as DS:BX, DS:DI, and DS:SI, for processing data in the data segment. BP is associated
with SS as SS:BP, for handling data in the stack.
When the first operand contains an indirect address, the second operand references a
register or immediate value; when the second operand contains an indirect address, the
first operand references a register. Note that a reference in square brackets to BP, BX, DI,
or SI implies an indirect operand, and the processor treats the contents of the register as
an offset address when the program is executing.
In the following example, LEA first initializes BX with the offset address of
DATA_VAL. MOV then uses the address now in BX to store CL in the memory location
to which it points, in this case, DATA_VAL:
DATA_VAL DB 50 ;Define byte
...
LEA BX,DATA_VAL ;Load BX with offset
MOV [BX],CL ;Move CL to DATA_VAL
The effect of the two MOVs is the same as coding MOV DATA_VAL,25. Here are a few
more examples of indirect operands:
ADD CL,[BX] ;2nd operand = DS:BX
MOV BYTE PTR [DI],25 ;1st operand = DS:DI
ADD [BP],CL ;lst operand = SS:BP
12
The next example uses an absolute value for an offset:
MOV CX,DS:[38B0H] ;Word in memory at offset 38B0H
This addressing mode also uses base registers (BX and BP) and index registers (DI and
SI), but combined with a displacement (a number or offset value) to form an effective
address. The following MOV instruction moves zero to a location two bytes immediately
following the start of DATA_TBL:
DATA_TBL DB 365 DUP(?) ;Define bytes
...
LEA BX,DATA_TBL ;Load BX with offset
MOV BYTE PTR [BX+2],0 ;Move 0 to DATA_TBL+2
And here are some additional examples:
ADD CL,[DI+12] ;DI offset plus 12 (or 12[DI])
SUB DATA_TBL[SI] ,25 ;SI contains offset
MOV DATA_TBL[DI],DL ;DI contains offset
7. Base-Index Addressing
This addressing mode combines a base register (BX or BP) with an index register (DI or
SI) to form an effective address; for example, [BX+DI] means the address in BX plus the
address in DI. A common use for this mode is in addressing a 2-dimensional array,
where, say, BX references the row and SI the column. Here are some examples:
MOV AX,[BX+SI] ;Move word from memory
ADD [BX+DI],CL ;Add byte to memory
The processor automatically selects the appropriate segment when addressing: CS:IP for
fetching an instruction, DS:offset for accessing data in memory, and SS:SP for accessing the
stack. There are occasions, especially for large programs, when you have to handle data that
is subject to another segment register, such as the ES. An example would be a large table of
data loaded from external storage into memory in a separate segment of the program.
You can use any instruction to process the data in the other segment, but you must identify
the appropriate segment register. Let's say that the address of the other segment is in ES, and
BX contains an offset address within that segment. The requirement is to move two bytes (a
word) from that location to DX.
MOV DX,ES:[BX] ;Move to DX from ES:[BX]
The coding of "ES:" indicates an override operator that means "Replace the normal use of the
DS segment register with that of ES." The next example moves a byte value from CL into this
other segment, at an offset formed by the value in SI plus 36.
13
MOV ES:[SI+36],CL ;Move to ES:[SI+36] from CL
The assembler generates object code with the override operator inserted as a 1-byte prefix
(26H) immediately preceding the instruction, just as if you had coded the two instructions as
ES: MOV DX,[BX] ;Move to DX from ES :[BX]
ES: MOV [SI+36],CL ;Move to ES:[SI+36] from CL
An address in a program may be near or far. A near address consists of only the 16-bit offset
portion of an address. An instruction that references a near address assumes the current
segment—namely, DS for data segment and CS for code segment.
A far address consists of both the segment and offset portions in the form of 32-bit segment:
offset. An instruction may reference a far address from within the current segment or in
another segment.
Almost all assembly programming in real mode makes use of near addresses, which the
assembler generates unless instructed otherwise. Large programs that consist of many
segments would require far addresses as do programs defined with the Flat memory model.
ARITMETIC
14
It is typically used in multiword binary subtraction to carry an overflowed 1 bit into the next
stage of arithmetic. SBB first subtracts the contents of the CF (0/1) from operand1 and then
subtracts operand2 from operand1, just like SUB. (See also ADC.)
Flags: Affects AF, CF, OF, PF, SF, and ZF.
Source code: SBB register/memory,register/memory/immediate
INC: Increment by 1
Increments by 1 a byte, or word in a register or memory and treats the value as an unsigned
integer, coded, for example, as INC CX. (See also DEC.)
Flags: Affects AF, OF, PF, SF, and ZF (but not CF).
Source code: INC register/memory
DEC: Decrement by 1
Decrements 1 from a byte or word in a register or memory and treats the value as an unsigned
integer. (See also INC.)
Flags: Affects AF, OF, PF, SF, and ZF.
Source code: DEC register/memory
15
Size Dividend Divisor Quotient Remainder Example
16-bit AX 8-bit reg/memory AL AH DIV BH
32-bit DX:AX 16-bit reg/memory AX DX DIV CX
Flags: Affects AF, CF, OF, PF, SF, and ZF. (All undefined.)
Source code: DIV register/memory
NEG: Negate
The instruction reverses a binary value from positive to negative or from negative to positive.
NEG provides the two's complement of the specified operand by subtracting the operand from
zero and adding 1. Operands can be a byte or word in a register or memory. (See also NOT.)
Flags: Affects AF, CF, OF, PF, SF, and ZF.
Source code: NEG register/memory
16
Flags: Affects AF and CF (OF, PF, SF, and ZF are undefined.)
Source code: AAA (no operand)
LOGICAL OPERATIONS
OR: Logical OR
The instruction performs a logical OR operation on bits of two operands. Both operands are
bytes or words, which OR matches bit for bit. For each pair of matched bits, if either or both
are 1, the bit in the first operand is set to 1; otherwise the bit is unchanged. (See also AND
and XOR.)
Flags: Affects CF (0), OF (0), PF, SF, and ZF (AF is undefined.)
Source code: OR register/memory,register/memory/immediate
17
XOR: Exclusive OR
The instruction performs a logical exclusive OR on bits of two operands. Both operands are
bytes or words, which XOR matches bit for bit. For each pair matched bits, if both are the
same, the bit in the first operand is cleared to 0; if the matched bits are different the bit in the
first operand is set to 1. (See also AND and OR.)
Flags: Affects CF (0), OF (0), PF, SF, and ZF (AF is undefined.)
Source code: XOR register/memory,register/memory/immediate
BIT SHIFTING/ROTATING
SHL shifts bits to the left a specified number and fills 0 bits in vacated positions to the right.
SHL acts exactly like SAL. SHR shifts bits to the right a specified number and fills 0 bits to
the left. All bits shifted off are lost.
Flags: Affects CF, OF, PF, SF, and ZF. (AF is undefined.)
Source code: SHL/SHR register/memory,CL/immediate
SAL shifts bits to the left a specified number and fills 0 bits in vacated positions to the right.
SAL acts exactly like SHL. SAR is an arithmetic shift that considers the sign of the
18
referenced field. SAR shifts bits to the right a specified number and fills the sign bit (0 or 1)
to the left. All bits shifted off are lost.
Flags: Affects CF, OF, PF, SF, and ZF. (AF is undefined.)
Source code: SAL/SAR register/memory,CL/immediate
COMPARISON
CMP: Compare
The instruction compares the binary contents of two data fields. CMP internally subtracts
operand 2 from operand 1 and sets/clears flags, but does not store the result. Both operands
are byte or word. CMP may compare register, memory, or immediate to a register or may
compare register or immediate to memory. (CMP makes a numeric comparison; see CMPS
for string comparisons.) The results are the following:
CF SF ZF
operand1 < operand2 1 1 0
operand1 = operand2 0 0 1
operand1 > operand2 0 0 0
Flags: Affects AF, CF, OF, PF, SF, and ZF.
Source code: CMP register/memory,register/memory/immediate
DATA TRANSFER
19
address in the segment register and the offset in the operand 1 register. Used for example as
LDS DI,SEG_ADDRESS.
Flags: Affects none.
Source code: LDS/LES/LSS register,memory
XCHG: Exchange
Exchanges data between two registers (as XCHG AH,BL) or between a register and memory
(as XCHG CX,word).
Flags: Affects none.
Source code: XCHG register/memory,register/memory
XLAT/XLATB: Translate
These instructions translate bytes into a different format, such as encrypted data. Load the
address of a translate table in BX or EBX for 32-bit size, and then load AL with a value that
is to be translated. The operation uses the AL value as an offset into the table, selects the byte
from the table, and stores it in AL. (XLATB is a synonym for XLAT.)
Flags: Affects none.
Source code: XLAT/XLATB [AL] (AL operand is optional)
20
FLAG OPERATIONS
21
Source code: STI (no operand)
LOOPING
BRANCHING
22
return, a subsequent RETN or RETF is used to reverse these steps.
Flags: Affects none.
Source code: CALL register/memory
23
The following list shows the instructions that are typically used after a compare operation,
which compares operand1 to operand2: The instructions using the signed and unsigned data
are listed separately
The following list shows the instructions that are typically used after an arithmetic/logic or
other instructions.
24
STACK OPERATIONS
25
a string operation, it does not require a REP prefix. DS:SI address a byte (if LODSB) or word
(if LODSW) and load it from memory into AL or AX, respectively. If the Direction Flag is 0,
the operation adds 1 (if byte) or 2 (if word) to the SI; otherwise it subtracts 1 or 2.
Flags: Affects none.
Source code: LODS mem or LODS segreg:mem
LODSB/LODSW (no operand)
26
prior to execution. For each execution of the string instruction, REP decrements CX by 1 and
repeats the operation until CX is 0, at which point processing continues with the next
instruction. (See also REPE/REPZ/REPNE/REPNZ.)
Flags: See the associated string instructions.
Source code: REP string-instruction
TYPE CONVERSION
MACHINE CONTROL
27
WAIT: Put Processor in Wait State
It allows the processor to remain in a wait state until an external interrupt occurs, in order to
synchronize it with a coprocessor. The processor waits until the coprocessor finishes exe-
cuting and resumes processing on receiving a signal in the TEST pin.
Flags: Affects none.
Source code: WAIT (no operand)
NOP: No Operation
Used to delete or insert machine code or to delay execution for purposes of timing. NOP
simply performs a null operation by executing XCHG AX,AX.
Flags: Affects none.
Source code: NOP (no operand)
28