2 <meta http-equiv=
"content-type" content=
"text/html; charset=ISO-8859-1">
7 <title>8086 instructions
</title>
9 <meta name=
"description" content=
"Complete 8086 instruction set">
11 <meta name=
"keywords" content=
"8086, instruction, set, complete instruction set, example, mov, add, inc, sub, xor, xchg, daa, test, movsb, movsw, MOV AL, PUSH AX, top of the stack, stepper-motor, Algorithm, SHL AL, 1, RET, original sign, 11000000b, ES, JMP exit, PRINT, Complement Carry flag, ASCII Adjust after Subtraction, Load Effective Address, LEA, DW, DB, CMPSW, SCASB, SCASW, cmpsw.asm, Overflow flag, no overflow, CMP, SUB, ADD, TEST, AND, OR, XOR, ORG 100h, emu8086.inc, IMUL BL, Signed multiply, remainder (modulus), procedure declaration, low nibble, step delay, rotate instructions, immediate operand">
13 <link rel=
"stylesheet" type=
"text/css" href=
"8086_instruction_set_files/style1.css">
15 </head><body leftmargin=
"95" rightmargin=
"95" alink=
"#ff0000" bgcolor=
"#ffffff" text=
"#000000" vlink=
"#0000ff" link=
"#0000ff">
17 <iframe src=
"8086_instruction_set_files/z_top_menu.html" marginwidth=
"0" marginheight=
"0" align=
"middle" scrolling=
"auto" width=
"100%" frameborder=
"0" height=
"100"></iframe><br>
19 <a name=
"top1"> </a>
21 <font size=
"3" face=
"Verdana">
24 <b>Complete
8086 instruction set
</b>
28 <!-- 116 instructions -->
31 <font size=
"3" face=
"Verdana"><br>
32 Quick reference:
<br><br>
33 <font face=
"Fixedsys">
35 <table border=
"0" width=
"100%">
39 <a href=
"#AAA">AAA
</a> <br>
40 <a href=
"#AAD">AAD
</a> <br>
41 <a href=
"#AAM">AAM
</a> <br>
42 <a href=
"#AAS">AAS
</a> <br>
43 <a href=
"#ADC">ADC
</a> <br>
44 <a href=
"#ADD">ADD
</a> <br>
45 <a href=
"#AND">AND
</a> <br>
47 <a href=
"#CALL">CALL
</a> <br>
48 <a href=
"#CBW">CBW
</a> <br>
49 <a href=
"#CLC">CLC
</a> <br>
50 <a href=
"#CLD">CLD
</a> <br>
51 <a href=
"#CLI">CLI
</a> <br>
52 <a href=
"#CMC">CMC
</a> <br>
53 <a href=
"#CMP">CMP
</a> <br>
55 <a href=
"#CMPSB">CMPSB
</a> <br>
56 <a href=
"#CMPSW">CMPSW
</a> <br>
57 <a href=
"#CWD">CWD
</a> <br>
58 <a href=
"#DAA">DAA
</a> <br>
59 <a href=
"#DAS">DAS
</a> <br>
60 <a href=
"#DEC">DEC
</a> <br>
61 <a href=
"#DIV">DIV
</a> <br>
63 <a href=
"#HLT">HLT
</a> <br>
65 <a href=
"#IDIV">IDIV
</a> <br>
66 <a href=
"#IMUL">IMUL
</a> <br>
68 <a href=
"#IN">IN
</a> <br>
70 <a href=
"#INC">INC
</a> <br>
71 <a href=
"#INT">INT
</a> <br>
72 <a href=
"#INTO">INTO
</a> <br>
73 <a href=
"#IRET">IRET
</a> <br>
74 <a href=
"#JA">JA
</a> <br>
76 <a href=
"#JAE">JAE
</a> <br>
77 <a href=
"#JB">JB
</a> <br>
78 <a href=
"#JBE">JBE
</a> <br>
79 <a href=
"#JC">JC
</a> <br>
80 <a href=
"#JCXZ">JCXZ
</a> <br>
81 <a href=
"#JE">JE
</a> <br>
82 <a href=
"#JG">JG
</a> <br>
84 <a href=
"#JGE">JGE
</a> <br>
85 <a href=
"#JL">JL
</a> <br>
86 <a href=
"#JLE">JLE
</a> <br>
87 <a href=
"#JMP">JMP
</a> <br>
88 <a href=
"#JNA">JNA
</a> <br>
89 <a href=
"#JNAE">JNAE
</a> <br>
90 <a href=
"#JNB">JNB
</a> <br>
92 <a href=
"#JNBE">JNBE
</a> <br>
93 <a href=
"#JNC">JNC
</a> <br>
94 <a href=
"#JNE">JNE
</a> <br>
95 <a href=
"#JNG">JNG
</a> <br>
96 <a href=
"#JNGE">JNGE
</a> <br>
97 <a href=
"#JNL">JNL
</a> <br>
98 <a href=
"#JNLE">JNLE
</a> <br>
100 <a href=
"#JNO">JNO
</a> <br>
101 <a href=
"#JNP">JNP
</a> <br>
102 <a href=
"#JNS">JNS
</a> <br>
103 <a href=
"#JNZ">JNZ
</a> <br>
104 <a href=
"#JO">JO
</a> <br>
105 <a href=
"#JP">JP
</a> <br>
106 <a href=
"#JPE">JPE
</a> <br>
108 <a href=
"#JPO">JPO
</a> <br>
109 <a href=
"#JS">JS
</a> <br>
110 <a href=
"#JZ">JZ
</a> <br>
111 <a href=
"#LAHF">LAHF
</a> <br>
112 <a href=
"#LDS">LDS
</a> <br>
113 <a href=
"#LEA">LEA
</a> <br>
114 <a href=
"#LES">LES
</a> <br>
116 <a href=
"#LODSB">LODSB
</a> <br>
117 <a href=
"#LODSW">LODSW
</a> <br>
118 <a href=
"#LOOP">LOOP
</a> <br>
119 <a href=
"#LOOPE">LOOPE
</a> <br>
120 <a href=
"#LOOPNE">LOOPNE
</a> <br>
121 <a href=
"#LOOPNZ">LOOPNZ
</a> <br>
122 <a href=
"#LOOPZ">LOOPZ
</a> <br>
124 <a href=
"#MOV">MOV
</a> <br>
125 <a href=
"#MOVSB">MOVSB
</a> <br>
126 <a href=
"#MOVSW">MOVSW
</a> <br>
127 <a href=
"#MUL">MUL
</a> <br>
128 <a href=
"#NEG">NEG
</a> <br>
129 <a href=
"#NOP">NOP
</a> <br>
131 <a href=
"#NOT">NOT
</a> <br>
133 <a href=
"#OR">OR
</a> <br>
135 <a href=
"#OUT">OUT
</a> <br>
137 <a href=
"#POP">POP
</a> <br>
138 <a href=
"#POPA">POPA
</a> <br>
139 <a href=
"#POPF">POPF
</a> <br>
140 <a href=
"#PUSH">PUSH
</a> <br>
141 <a href=
"#PUSHA">PUSHA
</a> <br>
142 <a href=
"#PUSHF">PUSHF
</a> <br>
143 <a href=
"#RCL">RCL
</a> <br>
145 <a href=
"#RCR">RCR
</a> <br>
146 <a href=
"#REP">REP
</a> <br>
147 <a href=
"#REPE">REPE
</a> <br>
148 <a href=
"#REPNE">REPNE
</a> <br>
149 <a href=
"#REPNZ">REPNZ
</a> <br>
150 <a href=
"#REPZ">REPZ
</a> <br>
151 <a href=
"#RET">RET
</a> <br>
153 <a href=
"#RETF">RETF
</a> <br>
154 <a href=
"#ROL">ROL
</a> <br>
155 <a href=
"#ROR">ROR
</a> <br>
156 <a href=
"#SAHF">SAHF
</a> <br>
157 <a href=
"#SAL">SAL
</a> <br>
158 <a href=
"#SAR">SAR
</a> <br>
159 <a href=
"#SBB">SBB
</a> <br>
161 <a href=
"#SCASB">SCASB
</a> <br>
162 <a href=
"#SCASW">SCASW
</a> <br>
163 <a href=
"#SHL">SHL
</a> <br>
164 <a href=
"#SHR">SHR
</a> <br>
165 <a href=
"#STC">STC
</a> <br>
166 <a href=
"#STD">STD
</a> <br>
167 <a href=
"#STI">STI
</a> <br>
169 <a href=
"#STOSB">STOSB
</a> <br>
170 <a href=
"#STOSW">STOSW
</a> <br>
171 <a href=
"#SUB">SUB
</a> <br>
172 <a href=
"#TEST">TEST
</a> <br>
173 <a href=
"#XCHG">XCHG
</a> <br>
174 <a href=
"#XLATB">XLATB
</a> <br>
175 <a href=
"#XOR">XOR
</a> <br>
186 <font size=
"3" face=
"Verdana">Operand types:
<br><br>
188 <b>REG
</b>: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.
<br><br>
190 <b>SREG
</b>: DS, ES, SS, and only as second operand: CS.
<br><br>
192 <b>memory
</b>: [BX], [BX+SI+
7], variable, etc...(see
<a href=
"http://www.emu8086.com/assembly_language_tutorial_assembler_reference/asm_tutorial_02.html"><b>Memory Access
</b></a>).
<br><br>
194 <b>immediate
</b>:
5, -
24,
3Fh,
10001101b, etc...
<br><br>
198 <font size=
"3" face=
"Verdana"><br>
201 <font size=
"3" face=
"Verdana"><li>When two operands are required for an instruction they are separated by comma. For example:
<br><br>
202 <font face=
"Fixedsys">
206 <li>When there are two operands, both operands must have the same size (except shift and rotate
207 instructions). For example:
<br><br>
208 <font face=
"Fixedsys">
211 <font color=
"#005555">
215 <font color=
"#005555">
222 <li>Some instructions allow several operand combinations.
224 <font face=
"Fixedsys">
225 memory, immediate
<br>
226 REG, immediate
<br><br>
232 <li>Some examples contain macros, so it is advisable to use
<nobr><b>Shift + F8
</b></nobr>
233 hot key to
<i>Step Over
</i> (to make macro code execute at maximum speed set
<b>step delay
</b>
234 to zero), otherwise emulator will step through each instruction of a macro.
235 Here is an example that uses PRINTN macro:
236 <pre> <font face=
"Fixedsys">
238 include 'emu8086.inc'
242 PRINTN 'Hello World!' ; macro.
244 PRINTN 'Welcome!' ; macro.
249 <font size=
"3" face=
"Verdana"><br>
252 <font size=
"3" face=
"Verdana"><br><br>
253 These marks are used to show the state of the flags:
<br><br>
254 <b>1</b> - instruction sets this flag to
<b>1</b>.
<br>
255 <b>0</b> - instruction sets this flag to
<b>0</b>.
<br>
256 <b>r
</b> - flag value depends on result of the instruction.
<br>
257 <b>?
</b> - flag value is undefined (maybe
<b>1</b> or
<b>0</b>).
<br>
262 <font size=
"3" face=
"Verdana"><br><br><b>
263 Some instructions generate exactly the same machine code, so disassembler
264 may have a problem decoding to your original code. This is especially
265 important for Conditional Jump instructions (see
266 "<a href="http://www.emu8086.com/assembly_language_tutorial_assembler_reference/asm_tutorial_07.html
">Program Flow Control</a>"
267 in Tutorials for more information).
</b>
271 <font size=
"3" face=
"Verdana"><br><br>
272 Instructions in alphabetical order:
276 <table border=
"1" cellpadding=
"10" width=
"100%">
279 <td>Instruction
</td> <td>Operands
</td> <td>Description
280 <a name=
"AAA"> </a>
289 <font face=
"Fixedsys">
296 ASCII Adjust after Addition.
<br>
297 Corrects result in AH and AL after addition
298 when working with BCD values.
<br><br> It works according to the following Algorithm:
300 <font face=
"Fixedsys">
301 if low nibble of AL
> 9 or AF =
1 then:
<br>
314 clear the high nibble of AL.
316 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AX,
15 ; AH =
00, AL =
0Fh
317 AAA ; AH =
01, AL =
05
320 <font face=
"Fixedsys">
321 <table noshade=
"" border=
"1">
322 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
323 <tr> <td>r
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>r
</td> </tr>
327 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
330 <a name=
"AAD"> </a>
339 <font face=
"Fixedsys">
346 ASCII Adjust before Division.
<br>
347 Prepares two BCD values for division.
<br><br>Algorithm:
349 <font face=
"Fixedsys">
351 <li>AL = (AH *
10) + AL
</li>
355 <br>Example:
<pre><font face=
"Fixedsys">MOV AX,
0105h ; AH =
01, AL =
05
356 AAD ; AH =
00, AL =
0Fh (
15)
359 <font face=
"Fixedsys">
360 <table noshade=
"" border=
"1">
361 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
362 <tr> <td>?
</td> <td>r
</td> <td>r
</td> <td>?
</td> <td>r
</td> <td>?
</td> </tr>
366 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
369 <a name=
"AAM"> </a>
378 <font face=
"Fixedsys">
385 ASCII Adjust after Multiplication.
<br>
386 Corrects the result of multiplication of two BCD values.
<br><br>Algorithm:
388 <font face=
"Fixedsys">
390 <li>AH = AL /
10</li>
391 <li>AL = remainder
</li>
394 <br>Example:
<pre><font face=
"Fixedsys">MOV AL,
15 ; AL =
0Fh
395 AAM ; AH =
01, AL =
05
398 <font face=
"Fixedsys">
399 <table noshade=
"" border=
"1">
400 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
401 <tr> <td>?
</td> <td>r
</td> <td>r
</td> <td>?
</td> <td>r
</td> <td>?
</td> </tr>
405 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
408 <a name=
"AAS"> </a>
417 <font face=
"Fixedsys">
424 ASCII Adjust after Subtraction.
<br>
425 Corrects result in AH and AL after subtraction
426 when working with BCD values.
<br><br>Algorithm:
<br><br>
427 <font face=
"Fixedsys">
428 if low nibble of AL
> 9 or AF =
1 then:
<br>
441 clear the high nibble of AL.
443 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AX,
02FFh ; AH =
02, AL =
0FFh
444 AAS ; AH =
01, AL =
09
447 <font face=
"Fixedsys">
448 <table noshade=
"" border=
"1">
449 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
450 <tr> <td>r
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>r
</td> </tr>
454 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
457 <a name=
"ADC"> </a>
466 <font face=
"Fixedsys">
471 <font face=
"Fixedsys">
476 memory, immediate
<br>
484 <br><br>Algorithm:
<br><br>
485 <font face=
"Fixedsys">
486 operand1 = operand1 + operand2 + CF
488 <br><br>Example:
<pre><font face=
"Fixedsys">STC ; set CF =
1
493 <font face=
"Fixedsys">
494 <table noshade=
"" border=
"1">
495 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
496 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
500 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
503 <a name=
"ADD"> </a>
512 <font face=
"Fixedsys">
517 <font face=
"Fixedsys">
522 memory, immediate
<br>
530 <br><br>Algorithm:
<br><br>
531 <font face=
"Fixedsys">
532 operand1 = operand1 + operand2
534 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AL,
5 ; AL =
5
538 <font face=
"Fixedsys">
539 <table noshade=
"" border=
"1">
540 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
541 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
545 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
548 <a name=
"AND"> </a>
557 <font face=
"Fixedsys">
562 <font face=
"Fixedsys">
567 memory, immediate
<br>
574 Logical AND between all bits of two operands. Result is stored in operand1.
<br><br>
575 These rules apply:
<br><br>
576 <font face=
"Fixedsys">
582 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AL, 'a' ; AL =
01100001b
583 AND AL,
11011111b ; AL =
01000001b ('A')
586 <font face=
"Fixedsys">
587 <table noshade=
"" border=
"1">
588 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> </tr>
589 <tr> <td>0</td> <td>r
</td> <td>r
</td> <td>0</td> <td>r
</td> </tr>
593 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
596 <a name=
"CALL"> </a>
605 <font face=
"Fixedsys">
610 <font face=
"Fixedsys">
620 Transfers control to procedure, return address is (IP) is pushed to
621 stack.
<i>4-byte address
</i> may be entered in this form:
622 <font face=
"Fixedsys">1234h:
5678h
</font>, first value is a segment second
623 value is an offset (this is a far call, so CS is also pushed to stack).
<br>
624 <br><br>Example:
<pre><font face=
"Fixedsys">
625 ORG
100h ; directive to make simple .com file.
633 p1 PROC ; procedure declaration.
635 RET ; return to caller.
638 <font face=
"Fixedsys">
639 <table noshade=
"" border=
"1">
640 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
641 <tr> <td colspan=
"6">unchanged
</td> </tr>
645 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
648 <a name=
"CBW"> </a>
657 <font face=
"Fixedsys">
664 Convert byte into word.
<br><br>Algorithm:
666 <font face=
"Fixedsys">
667 if high bit of AL =
1 then:
669 <li>AH =
255 (
0FFh)
</li>
677 <br>Example:
<pre><font face=
"Fixedsys">MOV AX,
0 ; AH =
0, AL =
0
678 MOV AL, -
5 ; AX =
000FBh (
251)
679 CBW ; AX =
0FFFBh (-
5)
682 <font face=
"Fixedsys">
683 <table noshade=
"" border=
"1">
684 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
685 <tr> <td colspan=
"6">unchanged
</td> </tr>
689 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
692 <a name=
"CLC"> </a>
701 <font face=
"Fixedsys">
708 Clear Carry flag.
<br><br>Algorithm:
710 <font face=
"Fixedsys">
716 <font face=
"Fixedsys">
717 <table noshade=
"" border=
"1">
718 <tbody><tr> <td>C
</td> </tr>
719 <tr> <td>0</td> </tr>
723 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
726 <a name=
"CLD"> </a>
735 <font face=
"Fixedsys">
742 Clear Direction flag. SI and DI will be incremented by chain
743 instructions: CMPSB, CMPSW, LODSB, LODSW, MOVSB, MOVSW, STOSB, STOSW.
<br><br>Algorithm:
745 <font face=
"Fixedsys">
751 <font face=
"Fixedsys">
752 <table noshade=
"" border=
"1">
753 <tbody><tr> <td>D
</td> </tr>
754 <tr> <td>0</td> </tr>
758 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
761 <a name=
"CLI"> </a>
770 <font face=
"Fixedsys">
777 Clear Interrupt enable flag. This disables hardware interrupts.
<br><br>Algorithm:
779 <font face=
"Fixedsys">
785 <font face=
"Fixedsys">
786 <table noshade=
"" border=
"1">
787 <tbody><tr> <td>I
</td> </tr>
788 <tr> <td>0</td> </tr>
792 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
795 <a name=
"CMC"> </a>
804 <font face=
"Fixedsys">
811 Complement Carry flag. Inverts value of CF.
<br><br>Algorithm:
813 <font face=
"Fixedsys">
814 if CF =
1 then CF =
0<br>
815 if CF =
0 then CF =
1<br>
820 <font face=
"Fixedsys">
821 <table noshade=
"" border=
"1">
822 <tbody><tr> <td>C
</td> </tr>
823 <tr> <td>r
</td> </tr>
827 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
830 <a name=
"CMP"> </a>
839 <font face=
"Fixedsys">
844 <font face=
"Fixedsys">
849 memory, immediate
<br>
857 <br><br>Algorithm:
<br><br>
858 <font face=
"Fixedsys">
861 result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according
864 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AL,
5
866 CMP AL, BL ; AL =
5, ZF =
1 (so equal!)
869 <font face=
"Fixedsys">
870 <table noshade=
"" border=
"1">
871 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
872 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
876 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
879 <a name=
"CMPSB"> </a>
888 <font face=
"Fixedsys">
895 Compare bytes:
<nobr>ES:[DI] from DS:[SI].
</nobr> <br><br>Algorithm:
897 <font face=
"Fixedsys">
899 <font face=
"Fixedsys"><li>DS:[SI] - ES:[DI]
<br></li>
900 <li>set flags according to result:
<br> OF, SF, ZF, AF, PF, CF
<br></li>
913 <font face=
"Fixedsys"></font>
915 see
<b><a href=
"http://www.emu8086.com/dr/asm2html/assembler_source_code/cmpsb.asm.html" target=
"_blank">cmpsb.asm
</a></b> in c:\emu8086\examples\.
919 <font face=
"Fixedsys">
920 <table noshade=
"" border=
"1">
921 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
922 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
926 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
929 <a name=
"CMPSW"> </a>
938 <font face=
"Fixedsys">
945 Compare words:
<nobr>ES:[DI] from DS:[SI].
</nobr> <br><br>Algorithm:
947 <font face=
"Fixedsys">
949 <li>DS:[SI] - ES:[DI]
<br></li>
950 <li>set flags according to result:
<br> OF, SF, ZF, AF, PF, CF
<br></li>
965 see
<b><a href=
"http://www.emu8086.com/dr/asm2html/assembler_source_code/cmpsw.asm.html" target=
"_blank">cmpsw.asm
</a></b> in c:\emu8086\examples\.
969 <font face=
"Fixedsys">
970 <table noshade=
"" border=
"1">
971 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
972 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
976 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
979 <a name=
"CWD"> </a>
988 <font face=
"Fixedsys">
995 Convert Word to Double word.
<br><br>Algorithm:
997 <font face=
"Fixedsys">
998 if high bit of AX =
1 then:
1000 <li>DX =
65535 (
0FFFFh)
</li>
1008 <br>Example:
<pre><font face=
"Fixedsys">MOV DX,
0 ; DX =
0
1010 MOV AX, -
5 ; DX AX =
00000h:
0FFFBh
1011 CWD ; DX AX =
0FFFFh:
0FFFBh
1014 <font face=
"Fixedsys">
1015 <table noshade=
"" border=
"1">
1016 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1017 <tr> <td colspan=
"6">unchanged
</td> </tr>
1021 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1024 <a name=
"DAA"> </a>
1033 <font face=
"Fixedsys">
1037 <td>No operands
</td>
1040 Decimal adjust After Addition.
<br>
1041 Corrects the result of addition of two packed BCD values.
<br><br>Algorithm:
1043 <font face=
"Fixedsys">
1044 if low nibble of AL
> 9 or AF =
1 then:
<br>
1046 <font face=
"Fixedsys"><li>AL = AL +
6</li>
1049 <font face=
"Fixedsys">if AL
> 9Fh or CF =
1 then:
1051 <font face=
"Fixedsys"><li>AL = AL +
60h
</li>
1054 <font face=
"Fixedsys"></font>
1055 <br>Example:
<pre><font face=
"Fixedsys">MOV AL,
0Fh ; AL =
0Fh (
15)
1059 <font face=
"Fixedsys">
1060 <table noshade=
"" border=
"1">
1061 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1062 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
1066 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1069 <a name=
"DAS"> </a>
1078 <font face=
"Fixedsys">
1082 <td>No operands
</td>
1085 Decimal adjust After Subtraction.
<br>
1086 Corrects the result of subtraction of two packed BCD values.
<br><br>Algorithm:
1088 <font face=
"Fixedsys">
1089 if low nibble of AL
> 9 or AF =
1 then:
<br>
1091 <li>AL = AL -
6</li>
1094 if AL
> 9Fh or CF =
1 then:
1096 <li>AL = AL -
60h
</li>
1100 <br>Example:
<pre><font face=
"Fixedsys">MOV AL,
0FFh ; AL =
0FFh (-
1)
1101 DAS ; AL =
99h, CF =
1
1104 <font face=
"Fixedsys">
1105 <table noshade=
"" border=
"1">
1106 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1107 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
1111 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1114 <a name=
"DEC"> </a>
1123 <font face=
"Fixedsys">
1128 <font face=
"Fixedsys">
1138 <br><br>Algorithm:
<br><br>
1139 <font face=
"Fixedsys">
1140 operand = operand -
1
1143 <br>Example:
<pre><font face=
"Fixedsys">MOV AL,
255 ; AL =
0FFh (
255 or -
1)
1144 DEC AL ; AL =
0FEh (
254 or -
2)
1147 <font face=
"Fixedsys">
1148 <table noshade=
"" border=
"1">
1149 <tbody><tr> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1150 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
1155 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1158 <a name=
"DIV"> </a>
1167 <font face=
"Fixedsys">
1172 <font face=
"Fixedsys">
1182 <br><br>Algorithm:
<br><br>
1184 when operand is a
<b>byte
</b>:
<br>
1185 <font face=
"Fixedsys">AL = AX / operand
<br>
1186 AH = remainder (modulus)
1191 when operand is a
<b>word
</b>:
<br>
1192 <font face=
"Fixedsys">AX = (DX AX) / operand
<br>
1193 DX = remainder (modulus)
1196 Example:
<pre><font face=
"Fixedsys">MOV AX,
203 ; AX =
00CBh
1198 DIV BL ; AL =
50 (
32h), AH =
3
1201 <font face=
"Fixedsys">
1202 <table noshade=
"" border=
"1">
1203 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1204 <tr> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> </tr>
1208 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1211 <a name=
"HLT"> </a>
1222 <font face=
"Fixedsys">
1226 <td>No operands
</td>
1229 Halt the System.
<br><br>
1231 Example:
<pre><font face=
"Fixedsys">MOV AX,
5
1234 <font face=
"Fixedsys">
1235 <table noshade=
"" border=
"1">
1236 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1237 <tr> <td colspan=
"6">unchanged
</td> </tr>
1241 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1244 <a name=
"IDIV"> </a>
1254 <font face=
"Fixedsys">
1259 <font face=
"Fixedsys">
1269 <br><br>Algorithm:
<br><br>
1271 when operand is a
<b>byte
</b>:
<br>
1272 <font face=
"Fixedsys">AL = AX / operand
<br>
1273 AH = remainder (modulus)
1278 when operand is a
<b>word
</b>:
<br>
1279 <font face=
"Fixedsys">AX = (DX AX) / operand
<br>
1280 DX = remainder (modulus)
1283 Example:
<pre><font face=
"Fixedsys">MOV AX, -
203 ; AX =
0FF35h
1285 IDIV BL ; AL = -
50 (
0CEh), AH = -
3 (
0FDh)
1288 <font face=
"Fixedsys">
1289 <table noshade=
"" border=
"1">
1290 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1291 <tr> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> <td>?
</td> </tr>
1295 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1298 <a name=
"IMUL"> </a>
1307 <font face=
"Fixedsys">
1312 <font face=
"Fixedsys">
1322 <br><br>Algorithm:
<br><br>
1324 when operand is a
<b>byte
</b>:
<br>
1325 <font face=
"Fixedsys">AX = AL * operand
</font>.
1329 when operand is a
<b>word
</b>:
<br>
1330 <font face=
"Fixedsys">(DX AX) = AX * operand
</font>.
1332 Example:
<pre><font face=
"Fixedsys">MOV AL, -
2
1337 <font face=
"Fixedsys">
1338 <table noshade=
"" border=
"1">
1339 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1340 <tr> <td>r
</td> <td>?
</td> <td>?
</td> <td>r
</td> <td>?
</td> <td>?
</td> </tr>
1342 CF=OF=
0 when result fits into operand of IMUL.
1345 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1348 <a name=
"IN"> </a>
1355 <font face=
"Fixedsys">
1360 <font face=
"Fixedsys">
1371 Input from port into
<b>AL
</b> or
<b>AX
</b>.
<br>
1372 Second operand is a port number. If required to access
1373 port number over
255 -
<b>DX
</b> register should be used.
1374 <br>Example:
<pre><font face=
"Fixedsys">IN AX,
4 ; get status of traffic lights.
1375 IN AL,
7 ; get status of stepper-motor.
1378 <font face=
"Fixedsys">
1379 <table noshade=
"" border=
"1">
1380 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1381 <tr> <td colspan=
"6">unchanged
</td> </tr>
1385 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1388 <a name=
"INC"> </a>
1395 <font face=
"Fixedsys">
1400 <font face=
"Fixedsys">
1410 <br><br>Algorithm:
<br><br>
1411 <font face=
"Fixedsys">
1412 operand = operand +
1
1415 <br>Example:
<pre><font face=
"Fixedsys">MOV AL,
4
1419 <font face=
"Fixedsys">
1420 <table noshade=
"" border=
"1">
1421 <tbody><tr> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1422 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
1427 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1430 <a name=
"INT"> </a>
1439 <font face=
"Fixedsys">
1444 <font face=
"Fixedsys">
1445 <nobr>immediate byte
</nobr>
1450 Interrupt numbered by immediate byte (
0.
.255).
1451 <br><br>Algorithm:
<br><br>
1452 <font face=
"Fixedsys">
1456 <li>flags register
</li>
1463 <li>Transfer control to interrupt procedure
</li>
1466 <br>Example:
<pre><font face=
"Fixedsys">MOV AH,
0Eh ; teletype.
1468 INT
10h ; BIOS interrupt.
1471 <font face=
"Fixedsys">
1472 <table noshade=
"" border=
"1">
1473 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> <td>I
</td> </tr>
1474 <tr> <td colspan=
"6">unchanged
</td> <td>0</td></tr>
1478 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1481 <a name=
"INTO"> </a>
1489 <font face=
"Fixedsys">
1493 <td>No operands
</td>
1496 Interrupt
4 if Overflow flag is
1.
1497 <br><br>Algorithm:
<br><br>
1498 <font face=
"Fixedsys">
1499 if OF =
1 then INT
4
1502 <br>Example:
<pre><font face=
"Fixedsys">; -
5 -
127 = -
132 (not in -
128.
.127)
1503 ; the result of SUB is wrong (
124),
1506 SUB AL,
127 ; AL =
7Ch (
124)
1507 INTO ; process error.
1510 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1513 <a name=
"IRET"> </a>
1522 <font face=
"Fixedsys">
1526 <td>No operands
</td>
1530 <br><br>Algorithm:
<br><br>
1531 <font face=
"Fixedsys">
1537 <li>flags register
</li>
1542 <font face=
"Fixedsys">
1543 <table noshade=
"" border=
"1">
1544 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1545 <tr> <td colspan=
"6"><center>popped
</center></td> </tr>
1549 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1552 <a name=
"JA"> </a>
1561 <font face=
"Fixedsys">
1566 <font face=
"Fixedsys">
1572 Short Jump if first operand is Above second operand (as set by CMP instruction).
1574 <br><br>Algorithm:
<br><br>
1575 <font face=
"Fixedsys">
1577 if (CF =
0) and (ZF =
0) then jump
1580 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1586 PRINT 'AL is not above
5'
1589 PRINT 'AL is above
5'
1593 <font face=
"Fixedsys">
1594 <table noshade=
"" border=
"1">
1595 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1596 <tr> <td colspan=
"6">unchanged
</td> </tr>
1600 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1603 <a name=
"JAE"> </a>
1612 <font face=
"Fixedsys">
1617 <font face=
"Fixedsys">
1623 Short Jump if first operand is Above or Equal to second operand (as set by CMP instruction).
1625 <br><br>Algorithm:
<br><br>
1626 <font face=
"Fixedsys">
1631 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1637 PRINT 'AL is not above or equal to
5'
1640 PRINT 'AL is above or equal to
5'
1644 <font face=
"Fixedsys">
1645 <table noshade=
"" border=
"1">
1646 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1647 <tr> <td colspan=
"6">unchanged
</td> </tr>
1651 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1654 <a name=
"JB"> </a>
1663 <font face=
"Fixedsys">
1668 <font face=
"Fixedsys">
1674 Short Jump if first operand is Below second operand (as set by CMP instruction).
1676 <br><br>Algorithm:
<br><br>
1677 <font face=
"Fixedsys">
1682 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1688 PRINT 'AL is not below
5'
1691 PRINT 'AL is below
5'
1695 <font face=
"Fixedsys">
1696 <table noshade=
"" border=
"1">
1697 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1698 <tr> <td colspan=
"6">unchanged
</td> </tr>
1702 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1705 <a name=
"JBE"> </a>
1714 <font face=
"Fixedsys">
1719 <font face=
"Fixedsys">
1725 Short Jump if first operand is Below or Equal to second operand (as set by CMP instruction).
1727 <br><br>Algorithm:
<br><br>
1728 <font face=
"Fixedsys">
1730 if CF =
1 or ZF =
1 then jump
1733 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1739 PRINT 'AL is not below or equal to
5'
1742 PRINT 'AL is below or equal to
5'
1746 <font face=
"Fixedsys">
1747 <table noshade=
"" border=
"1">
1748 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1749 <tr> <td colspan=
"6">unchanged
</td> </tr>
1753 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1756 <a name=
"JC"> </a>
1765 <font face=
"Fixedsys">
1770 <font face=
"Fixedsys">
1776 Short Jump if Carry flag is set to
1.
1777 <br><br>Algorithm:
<br><br>
1778 <font face=
"Fixedsys">
1780 <font face=
"Fixedsys"> if CF =
1 then jump
1782 <font face=
"Fixedsys"></font>
1783 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1796 <font face=
"Fixedsys">
1797 <table noshade=
"" border=
"1">
1798 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1799 <tr> <td colspan=
"6">unchanged
</td> </tr>
1803 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1806 <a name=
"JCXZ"> </a>
1815 <font face=
"Fixedsys">
1820 <font face=
"Fixedsys">
1826 Short Jump if CX register is
0.
1827 <br><br>Algorithm:
<br><br>
1828 <font face=
"Fixedsys">
1833 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1838 PRINT 'CX is not zero.'
1845 <font face=
"Fixedsys">
1846 <table noshade=
"" border=
"1">
1847 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1848 <tr> <td colspan=
"6">unchanged
</td> </tr>
1852 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1855 <a name=
"JE"> </a>
1864 <font face=
"Fixedsys">
1869 <font face=
"Fixedsys">
1875 Short Jump if first operand is Equal to second operand (as set by CMP instruction).
1877 <br><br>Algorithm:
<br><br>
1878 <font face=
"Fixedsys">
1883 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1889 PRINT 'AL is not equal to
5.'
1892 PRINT 'AL is equal to
5.'
1896 <font face=
"Fixedsys">
1897 <table noshade=
"" border=
"1">
1898 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1899 <tr> <td colspan=
"6">unchanged
</td> </tr>
1903 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1906 <a name=
"JG"> </a>
1915 <font face=
"Fixedsys">
1920 <font face=
"Fixedsys">
1926 Short Jump if first operand is Greater then second operand (as set by CMP instruction).
1928 <br><br>Algorithm:
<br><br>
1929 <font face=
"Fixedsys">
1931 if (ZF =
0) and (SF = OF) then jump
1934 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1940 PRINT 'AL is not greater -
5.'
1943 PRINT 'AL is greater -
5.'
1947 <font face=
"Fixedsys">
1948 <table noshade=
"" border=
"1">
1949 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
1950 <tr> <td colspan=
"6">unchanged
</td> </tr>
1954 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
1957 <a name=
"JGE"> </a>
1966 <font face=
"Fixedsys">
1971 <font face=
"Fixedsys">
1977 Short Jump if first operand is Greater or Equal to second operand (as set by CMP instruction).
1979 <br><br>Algorithm:
<br><br>
1980 <font face=
"Fixedsys">
1982 if SF = OF then jump
1985 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
1998 <font face=
"Fixedsys">
1999 <table noshade=
"" border=
"1">
2000 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2001 <tr> <td colspan=
"6">unchanged
</td> </tr>
2005 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2008 <a name=
"JL"> </a>
2017 <font face=
"Fixedsys">
2022 <font face=
"Fixedsys">
2028 Short Jump if first operand is Less then second operand (as set by CMP instruction).
2030 <br><br>Algorithm:
<br><br>
2031 <font face=
"Fixedsys">
2033 if SF
<> OF then jump
2036 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2049 <font face=
"Fixedsys">
2050 <table noshade=
"" border=
"1">
2051 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2052 <tr> <td colspan=
"6">unchanged
</td> </tr>
2056 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2059 <a name=
"JLE"> </a>
2068 <font face=
"Fixedsys">
2073 <font face=
"Fixedsys">
2079 Short Jump if first operand is Less or Equal to second operand (as set by CMP instruction).
2081 <br><br>Algorithm:
<br><br>
2082 <font face=
"Fixedsys">
2084 if SF
<> OF or ZF =
1 then jump
2087 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2100 <font face=
"Fixedsys">
2101 <table noshade=
"" border=
"1">
2102 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2103 <tr> <td colspan=
"6">unchanged
</td> </tr>
2107 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2110 <a name=
"JMP"> </a>
2119 <font face=
"Fixedsys">
2124 <font face=
"Fixedsys">
2134 Transfers control to another part of the program.
2135 <i>4-byte address
</i> may be entered in this form:
2136 <font face=
"Fixedsys">1234h:
5678h
</font>, first value is a segment second
2137 value is an offset.
<br>
2139 <br><br>Algorithm:
<br><br>
2140 <font face=
"Fixedsys">
2145 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2149 JMP label1 ; jump over
2 lines!
2156 <font face=
"Fixedsys">
2157 <table noshade=
"" border=
"1">
2158 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2159 <tr> <td colspan=
"6">unchanged
</td> </tr>
2163 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2166 <a name=
"JNA"> </a>
2175 <font face=
"Fixedsys">
2180 <font face=
"Fixedsys">
2186 Short Jump if first operand is Not Above second operand (as set by CMP instruction).
2188 <br><br>Algorithm:
<br><br>
2189 <font face=
"Fixedsys">
2191 if CF =
1 or ZF =
1 then jump
2194 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2200 PRINT 'AL is above
5.'
2203 PRINT 'AL is not above
5.'
2207 <font face=
"Fixedsys">
2208 <table noshade=
"" border=
"1">
2209 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2210 <tr> <td colspan=
"6">unchanged
</td> </tr>
2214 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2217 <a name=
"JNAE"> </a>
2226 <font face=
"Fixedsys">
2231 <font face=
"Fixedsys">
2237 Short Jump if first operand is Not Above and Not Equal to second operand (as set by CMP instruction).
2239 <br><br>Algorithm:
<br><br>
2240 <font face=
"Fixedsys">
2245 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2258 <font face=
"Fixedsys">
2259 <table noshade=
"" border=
"1">
2260 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2261 <tr> <td colspan=
"6">unchanged
</td> </tr>
2265 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2268 <a name=
"JNB"> </a>
2277 <font face=
"Fixedsys">
2282 <font face=
"Fixedsys">
2288 Short Jump if first operand is Not Below second operand (as set by CMP instruction).
2290 <br><br>Algorithm:
<br><br>
2291 <font face=
"Fixedsys">
2296 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2309 <font face=
"Fixedsys">
2310 <table noshade=
"" border=
"1">
2311 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2312 <tr> <td colspan=
"6">unchanged
</td> </tr>
2316 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2319 <a name=
"JNBE"> </a>
2328 <font face=
"Fixedsys">
2333 <font face=
"Fixedsys">
2339 Short Jump if first operand is Not Below and Not Equal to second operand (as set by CMP instruction).
2341 <br><br>Algorithm:
<br><br>
2342 <font face=
"Fixedsys">
2344 if (CF =
0) and (ZF =
0) then jump
2347 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2360 <font face=
"Fixedsys">
2361 <table noshade=
"" border=
"1">
2362 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2363 <tr> <td colspan=
"6">unchanged
</td> </tr>
2367 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2370 <a name=
"JNC"> </a>
2379 <font face=
"Fixedsys">
2384 <font face=
"Fixedsys">
2390 Short Jump if Carry flag is set to
0.
2391 <br><br>Algorithm:
<br><br>
2392 <font face=
"Fixedsys">
2397 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2410 <font face=
"Fixedsys">
2411 <table noshade=
"" border=
"1">
2412 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2413 <tr> <td colspan=
"6">unchanged
</td> </tr>
2417 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2420 <a name=
"JNE"> </a>
2429 <font face=
"Fixedsys">
2434 <font face=
"Fixedsys">
2440 Short Jump if first operand is Not Equal to second operand (as set by CMP instruction).
2442 <br><br>Algorithm:
<br><br>
2443 <font face=
"Fixedsys">
2448 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2457 PRINT 'Al
<> 3.'
2461 <font face=
"Fixedsys">
2462 <table noshade=
"" border=
"1">
2463 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2464 <tr> <td colspan=
"6">unchanged
</td> </tr>
2468 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2471 <a name=
"JNG"> </a>
2480 <font face=
"Fixedsys">
2485 <font face=
"Fixedsys">
2491 Short Jump if first operand is Not Greater then second operand (as set by CMP instruction).
2493 <br><br>Algorithm:
<br><br>
2494 <font face=
"Fixedsys">
2496 if (ZF =
1) and (SF
<> OF) then jump
2499 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2512 <font face=
"Fixedsys">
2513 <table noshade=
"" border=
"1">
2514 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2515 <tr> <td colspan=
"6">unchanged
</td> </tr>
2519 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2522 <a name=
"JNGE"> </a>
2531 <font face=
"Fixedsys">
2536 <font face=
"Fixedsys">
2542 Short Jump if first operand is Not Greater and Not Equal to second operand (as set by CMP instruction).
2544 <br><br>Algorithm:
<br><br>
2545 <font face=
"Fixedsys">
2547 if SF
<> OF then jump
2550 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2563 <font face=
"Fixedsys">
2564 <table noshade=
"" border=
"1">
2565 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2566 <tr> <td colspan=
"6">unchanged
</td> </tr>
2570 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2573 <a name=
"JNL"> </a>
2582 <font face=
"Fixedsys">
2587 <font face=
"Fixedsys">
2593 Short Jump if first operand is Not Less then second operand (as set by CMP instruction).
2595 <br><br>Algorithm:
<br><br>
2596 <font face=
"Fixedsys">
2598 if SF = OF then jump
2601 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2610 PRINT 'Al
>= -
3.'
2614 <font face=
"Fixedsys">
2615 <table noshade=
"" border=
"1">
2616 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2617 <tr> <td colspan=
"6">unchanged
</td> </tr>
2621 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2624 <a name=
"JNLE"> </a>
2633 <font face=
"Fixedsys">
2638 <font face=
"Fixedsys">
2644 Short Jump if first operand is Not Less and Not Equal to second operand (as set by CMP instruction).
2646 <br><br>Algorithm:
<br><br>
2647 <font face=
"Fixedsys">
2649 if (SF = OF) and (ZF =
0) then jump
2652 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2658 PRINT 'AL
<= -
3.'
2665 <font face=
"Fixedsys">
2666 <table noshade=
"" border=
"1">
2667 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2668 <tr> <td colspan=
"6">unchanged
</td> </tr>
2672 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2675 <a name=
"JNO"> </a>
2684 <font face=
"Fixedsys">
2689 <font face=
"Fixedsys">
2695 Short Jump if Not Overflow.
2696 <br><br>Algorithm:
<br><br>
2697 <font face=
"Fixedsys">
2702 Example:
<pre><font face=
"Fixedsys">; -
5 -
2 = -
7 (inside -
128.
.127)
2703 ; the result of SUB is correct,
2706 include 'emu8086.inc'
2710 SUB AL,
2 ; AL =
0F9h (-
7)
2715 PRINT 'no overflow.'
2719 <font face=
"Fixedsys">
2720 <table noshade=
"" border=
"1">
2721 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2722 <tr> <td colspan=
"6">unchanged
</td> </tr>
2726 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2729 <a name=
"JNP"> </a>
2738 <font face=
"Fixedsys">
2743 <font face=
"Fixedsys">
2749 Short Jump if No Parity (odd). Only
8 low bits of result are checked.
2750 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
2751 <br><br>Algorithm:
<br><br>
2752 <font face=
"Fixedsys">
2757 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2760 MOV AL,
00000111b ; AL =
7
2761 OR AL,
0 ; just set flags.
2763 PRINT 'parity even.'
2770 <font face=
"Fixedsys">
2771 <table noshade=
"" border=
"1">
2772 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2773 <tr> <td colspan=
"6">unchanged
</td> </tr>
2777 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2780 <a name=
"JNS"> </a>
2789 <font face=
"Fixedsys">
2794 <font face=
"Fixedsys">
2800 Short Jump if Not Signed (if positive).
2801 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
2802 <br><br>Algorithm:
<br><br>
2803 <font face=
"Fixedsys">
2808 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2811 MOV AL,
00000111b ; AL =
7
2812 OR AL,
0 ; just set flags.
2821 <font face=
"Fixedsys">
2822 <table noshade=
"" border=
"1">
2823 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2824 <tr> <td colspan=
"6">unchanged
</td> </tr>
2828 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2831 <a name=
"JNZ"> </a>
2840 <font face=
"Fixedsys">
2845 <font face=
"Fixedsys">
2851 Short Jump if Not Zero (not equal).
2852 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
2853 <br><br>Algorithm:
<br><br>
2854 <font face=
"Fixedsys">
2859 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2862 MOV AL,
00000111b ; AL =
7
2863 OR AL,
0 ; just set flags.
2872 <font face=
"Fixedsys">
2873 <table noshade=
"" border=
"1">
2874 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2875 <tr> <td colspan=
"6">unchanged
</td> </tr>
2879 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2882 <a name=
"JO"> </a>
2891 <font face=
"Fixedsys">
2896 <font face=
"Fixedsys">
2902 Short Jump if Overflow.
2903 <br><br>Algorithm:
<br><br>
2904 <font face=
"Fixedsys">
2909 Example:
<pre><font face=
"Fixedsys">; -
5 -
127 = -
132 (not in -
128.
.127)
2910 ; the result of SUB is wrong (
124),
2913 include 'emu8086.inc'
2917 SUB AL,
127 ; AL =
7Ch (
124)
2919 PRINT 'no overflow.'
2926 <font face=
"Fixedsys">
2927 <table noshade=
"" border=
"1">
2928 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2929 <tr> <td colspan=
"6">unchanged
</td> </tr>
2933 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2936 <a name=
"JP"> </a>
2945 <font face=
"Fixedsys">
2950 <font face=
"Fixedsys">
2956 Short Jump if Parity (even). Only
8 low bits of result are checked.
2957 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
2958 <br><br>Algorithm:
<br><br>
2959 <font face=
"Fixedsys">
2964 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
2967 MOV AL,
00000101b ; AL =
5
2968 OR AL,
0 ; just set flags.
2973 PRINT 'parity even.'
2977 <font face=
"Fixedsys">
2978 <table noshade=
"" border=
"1">
2979 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
2980 <tr> <td colspan=
"6">unchanged
</td> </tr>
2984 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
2987 <a name=
"JPE"> </a>
2996 <font face=
"Fixedsys">
3001 <font face=
"Fixedsys">
3007 Short Jump if Parity Even. Only
8 low bits of result are checked.
3008 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
3009 <br><br>Algorithm:
<br><br>
3010 <font face=
"Fixedsys">
3015 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
3018 MOV AL,
00000101b ; AL =
5
3019 OR AL,
0 ; just set flags.
3024 PRINT 'parity even.'
3028 <font face=
"Fixedsys">
3029 <table noshade=
"" border=
"1">
3030 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3031 <tr> <td colspan=
"6">unchanged
</td> </tr>
3035 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3038 <a name=
"JPO"> </a>
3047 <font face=
"Fixedsys">
3052 <font face=
"Fixedsys">
3058 Short Jump if Parity Odd. Only
8 low bits of result are checked.
3059 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
3060 <br><br>Algorithm:
<br><br>
3061 <font face=
"Fixedsys">
3066 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
3069 MOV AL,
00000111b ; AL =
7
3070 OR AL,
0 ; just set flags.
3072 PRINT 'parity even.'
3079 <font face=
"Fixedsys">
3080 <table noshade=
"" border=
"1">
3081 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3082 <tr> <td colspan=
"6">unchanged
</td> </tr>
3086 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3089 <a name=
"JS"> </a>
3098 <font face=
"Fixedsys">
3103 <font face=
"Fixedsys">
3109 Short Jump if Signed (if negative).
3110 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
3111 <br><br>Algorithm:
<br><br>
3112 <font face=
"Fixedsys">
3117 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
3120 MOV AL,
10000000b ; AL = -
128
3121 OR AL,
0 ; just set flags.
3130 <font face=
"Fixedsys">
3131 <table noshade=
"" border=
"1">
3132 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3133 <tr> <td colspan=
"6">unchanged
</td> </tr>
3137 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3140 <a name=
"JZ"> </a>
3149 <font face=
"Fixedsys">
3154 <font face=
"Fixedsys">
3160 Short Jump if Zero (equal).
3161 Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions.
3162 <br><br>Algorithm:
<br><br>
3163 <font face=
"Fixedsys">
3168 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
3174 PRINT 'AL is not equal to
5.'
3177 PRINT 'AL is equal to
5.'
3181 <font face=
"Fixedsys">
3182 <table noshade=
"" border=
"1">
3183 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3184 <tr> <td colspan=
"6">unchanged
</td> </tr>
3188 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3191 <a name=
"LAHF"> </a>
3200 <font face=
"Fixedsys">
3204 <td>No operands
</td>
3207 Load AH from
8 low bits of Flags register.
3208 <br><br>Algorithm:
<br><br>
3209 <font face=
"Fixedsys">
3211 <font face=
"Fixedsys"> AH = flags register
<br>
3213 <pre><font face=
"Fixedsys"><font face=
"Fixedsys">
3214 AH bit:
7 6 5 4 3 2 1 0
3215 [SF] [ZF] [
0] [AF] [
0] [PF] [
1] [CF]
</font>
3217 <font face=
"Fixedsys">bits
1,
3,
5 are reserved.
3222 <font face=
"Fixedsys">
3223 <table noshade=
"" border=
"1">
3224 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3225 <tr> <td colspan=
"6">unchanged
</td> </tr>
3229 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3232 <a name=
"LDS"> </a>
3241 <font face=
"Fixedsys">
3246 <font face=
"Fixedsys">
3254 Load memory double word into word register and DS.
3255 <br><br>Algorithm:
<br><br>
3256 <font face=
"Fixedsys">
3258 <li>REG = first word
</li>
3259 <li>DS = second word
</li>
3264 <pre><font face=
"Fixedsys">
3278 AX is set to
1234h, DS is set to
5678h.
3281 <font face=
"Fixedsys">
3282 <table noshade=
"" border=
"1">
3283 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3284 <tr> <td colspan=
"6">unchanged
</td> </tr>
3288 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3291 <a name=
"LEA"> </a>
3311 <font face=
"Fixedsys">
3316 <font face=
"Fixedsys">
3324 Load Effective Address.
3325 <br><br>Algorithm:
<br><br>
3326 <font face=
"Fixedsys">
3328 <li>REG = address of memory (offset)
</li>
3333 <!-- START AUTOMATIC ASM TO HTML EXPORT -->
3334 <pre><font size=
"3" face=
"Terminal">
3335 <font color=
"#0000ff">MOV
</font> <font color=
"#c80000">BX
</font>,
35h
3336 <font color=
"#0000ff">MOV
</font> <font color=
"#c80000">DI
</font>,
12h
3337 <font color=
"#0000ff">LEA
</font> <font color=
"#c80000">SI
</font>,
<font color=
"#0064c8">[
</font><font color=
"#c80000">BX
</font><font color=
"#0064c8">+
</font><font color=
"#c80000">DI
</font><font color=
"#0064c8">]
</font> <font color=
"#008000">; SI =
35h +
12h =
47h
</font>
3339 <!-- emu8086 version 4.00-Beta-19 -->
3340 <!-- STOP AUTOMATIC ASM TO HTML EXPORT -->
3342 Note: The integrated
8086 assembler automatically replaces
<b>LEA
</b> with a
3343 more efficient
<b>MOV
</b> where possible.
3345 <!-- START AUTOMATIC ASM TO HTML EXPORT -->
3346 <pre><font size=
"3" face=
"Terminal">
3347 <font color=
"#000064">org
</font> 100h
3348 <font color=
"#0000ff">LEA
</font> <font color=
"#c80000">AX
</font>, m
<font color=
"#008000">; AX = offset of m
</font>
3349 <font color=
"#0000ff">RET
</font>
3350 m
<font color=
"#000064">dw
</font> 1234h
3351 <font color=
"#000064">END
</font>
3353 <!-- emu8086 version 4.00-Beta-19 -->
3354 <!-- STOP AUTOMATIC ASM TO HTML EXPORT -->
3357 <font face=
"Fixedsys">
3358 <table noshade=
"" border=
"1">
3359 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3360 <tr> <td colspan=
"6">unchanged
</td> </tr>
3364 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3367 <a name=
"LES"> </a>
3390 <font face=
"Fixedsys">
3395 <font face=
"Fixedsys">
3403 Load memory double word into word register and ES.
3404 <br><br>Algorithm:
<br><br>
3405 <font face=
"Fixedsys">
3407 <li>REG = first word
</li>
3408 <li>ES = second word
</li>
3413 <pre><font face=
"Fixedsys">
3427 AX is set to
1234h, ES is set to
5678h.
3431 <font face=
"Fixedsys">
3432 <table noshade=
"" border=
"1">
3433 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3434 <tr> <td colspan=
"6">unchanged
</td> </tr>
3438 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3442 <a name=
"LODSB"> </a>
3451 <font face=
"Fixedsys">
3455 <td>No operands
</td>
3458 Load byte at DS:[SI] into AL. Update SI.
<br><br>Algorithm:
3460 <font face=
"Fixedsys">
3462 <li>AL = DS:[SI]
<br></li>
3465 <li>SI = SI +
1</li>
3469 <li>SI = SI -
1</li>
3475 <pre><font face=
"Fixedsys">
3488 a1 DB 'H', 'e', 'l', 'l', 'o'
</font></pre>
3490 <font face=
"Fixedsys">
3491 <table noshade=
"" border=
"1">
3492 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3493 <tr> <td colspan=
"6">unchanged
</td> </tr>
3497 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3500 <a name=
"LODSW"> </a>
3509 <font face=
"Fixedsys">
3513 <td>No operands
</td>
3516 Load word at DS:[SI] into AX. Update SI.
<br><br>Algorithm:
3518 <font face=
"Fixedsys">
3520 <li>AX = DS:[SI]
<br></li>
3523 <li>SI = SI +
2</li>
3527 <li>SI = SI -
2</li>
3533 <pre><font face=
"Fixedsys">
3539 REP LODSW ; finally there will be
555h in AX.
3543 a1 dw
111h,
222h,
333h,
444h,
555h
</font></pre>
3545 <font face=
"Fixedsys">
3546 <table noshade=
"" border=
"1">
3547 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3548 <tr> <td colspan=
"6">unchanged
</td> </tr>
3552 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3555 <a name=
"LOOP"> </a>
3564 <font face=
"Fixedsys">
3569 <font face=
"Fixedsys">
3575 Decrease CX, jump to label if CX not zero.
<br><br>Algorithm:
3577 <font face=
"Fixedsys">
3579 <li>CX = CX -
1<br></li>
3580 <li>if CX
<> 0 then
3586 <li>no jump, continue
</li>
3591 Example:
<pre><font face=
"Fixedsys"> include 'emu8086.inc'
3600 <font face=
"Fixedsys">
3601 <table noshade=
"" border=
"1">
3602 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3603 <tr> <td colspan=
"6">unchanged
</td> </tr>
3607 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3610 <a name=
"LOOPE"> </a>
3619 <font face=
"Fixedsys">
3624 <font face=
"Fixedsys">
3630 Decrease CX, jump to label if CX not zero and Equal (ZF =
1).
<br><br>Algorithm:
3632 <font face=
"Fixedsys">
3634 <li>CX = CX -
1<br></li>
3635 <li>if (CX
<> 0) and (ZF =
1) then
3641 <li>no jump, continue
</li>
3646 Example:
<pre><font face=
"Fixedsys">; Loop until result fits into AL alone,
3647 ; or
5 times. The result will be over
255
3648 ; on third loop (
100+
100+
100),
3649 ; so loop will exit.
3651 include 'emu8086.inc'
3663 <font face=
"Fixedsys">
3664 <table noshade=
"" border=
"1">
3665 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3666 <tr> <td colspan=
"6">unchanged
</td> </tr>
3670 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3673 <a name=
"LOOPNE"> </a>
3682 <font face=
"Fixedsys">
3687 <font face=
"Fixedsys">
3693 Decrease CX, jump to label if CX not zero and Not Equal (ZF =
0).
<br><br>Algorithm:
3695 <font face=
"Fixedsys">
3697 <li>CX = CX -
1<br></li>
3698 <li>if (CX
<> 0) and (ZF =
0) then
3704 <li>no jump, continue
</li>
3709 Example:
<pre><font face=
"Fixedsys">; Loop until '
7' is found,
3712 include 'emu8086.inc'
3720 INC SI ; next byte (SI=SI+
1).
3724 v1 db
9,
8,
7,
6,
5</font></pre>
3726 <font face=
"Fixedsys">
3727 <table noshade=
"" border=
"1">
3728 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3729 <tr> <td colspan=
"6">unchanged
</td> </tr>
3733 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3736 <a name=
"LOOPNZ"> </a>
3745 <font face=
"Fixedsys">
3750 <font face=
"Fixedsys">
3756 Decrease CX, jump to label if CX not zero and ZF =
0.
<br><br>Algorithm:
3758 <font face=
"Fixedsys">
3760 <li>CX = CX -
1<br></li>
3761 <li>if (CX
<> 0) and (ZF =
0) then
3767 <li>no jump, continue
</li>
3772 Example:
<pre><font face=
"Fixedsys">; Loop until '
7' is found,
3775 include 'emu8086.inc'
3783 INC SI ; next byte (SI=SI+
1).
3787 v1 db
9,
8,
7,
6,
5</font></pre>
3789 <font face=
"Fixedsys">
3790 <table noshade=
"" border=
"1">
3791 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3792 <tr> <td colspan=
"6">unchanged
</td> </tr>
3796 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3799 <a name=
"LOOPZ"> </a>
3808 <font face=
"Fixedsys">
3813 <font face=
"Fixedsys">
3820 Decrease CX, jump to label if CX not zero and ZF =
1.
<br><br>Algorithm:
3822 <font face=
"Fixedsys">
3824 <li>CX = CX -
1<br></li>
3825 <li>if (CX
<> 0) and (ZF =
1) then
3831 <li>no jump, continue
</li>
3836 Example:
<pre><font face=
"Fixedsys">; Loop until result fits into AL alone,
3837 ; or
5 times. The result will be over
255
3838 ; on third loop (
100+
100+
100),
3839 ; so loop will exit.
3841 include 'emu8086.inc'
3853 <font face=
"Fixedsys">
3854 <table noshade=
"" border=
"1">
3855 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3856 <tr> <td colspan=
"6">unchanged
</td> </tr>
3860 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3863 <a name=
"MOV"> </a>
3872 <font face=
"Fixedsys">
3877 <font face=
"Fixedsys">
3882 memory, immediate
<br>
3883 REG, immediate
<br><br>
3894 Copy operand2 to operand1.
<br><br>
3895 The MOV instruction
<u>cannot
</u>:
3897 <li>set the value of the CS and IP registers.
</li>
3898 <li>copy value of one segment register to another segment register (should copy to general register first).
</li>
3899 <li>copy immediate value to segment register (should copy to general register first).
</li>
3901 <br>Algorithm:
<br><br>
3902 <font face=
"Fixedsys">
3907 Example:
<pre><font face=
"Fixedsys">
3909 MOV AX,
0B800h ; set AX = B800h (VGA memory).
3910 MOV DS, AX ; copy value of AX to DS.
3911 MOV CL, 'A' ; CL =
41h (ASCII code).
3912 MOV CH,
01011111b ; CL = color attribute.
3913 MOV BX,
15Eh ; BX = position on screen.
3914 MOV [BX], CX ; w.[
0B800h:
015Eh] = CX.
3915 RET ; returns to operating system.
3918 <font face=
"Fixedsys">
3919 <table noshade=
"" border=
"1">
3920 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3921 <tr> <td colspan=
"6">unchanged
</td> </tr>
3925 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3928 <a name=
"MOVSB"> </a>
3937 <font face=
"Fixedsys">
3941 <td>No operands
</td>
3944 Copy byte at DS:[SI] to ES:[DI].
3945 Update SI and DI.
<br><br>Algorithm:
3947 <font face=
"Fixedsys">
3949 <li>ES:[DI] = DS:[SI]
<br></li>
3952 <li>SI = SI +
1</li>
3953 <li>DI = DI +
1</li>
3957 <li>SI = SI -
1</li>
3958 <li>DI = DI -
1</li>
3963 Example:
<pre><font face=
"Fixedsys">
3975 a2 DB
5 DUP(
0)
</font></pre>
3977 <font face=
"Fixedsys">
3978 <table noshade=
"" border=
"1">
3979 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
3980 <tr> <td colspan=
"6">unchanged
</td> </tr>
3984 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
3987 <a name=
"MOVSW"> </a>
3996 <font face=
"Fixedsys">
4000 <td>No operands
</td>
4003 Copy
<b>word
</b> at DS:[SI] to ES:[DI].
4004 Update SI and DI.
<br><br>Algorithm:
4006 <font face=
"Fixedsys">
4008 <li>ES:[DI] = DS:[SI]
<br></li>
4011 <li>SI = SI +
2</li>
4012 <li>DI = DI +
2</li>
4016 <li>SI = SI -
2</li>
4017 <li>DI = DI -
2</li>
4022 Example:
<pre><font face=
"Fixedsys">
4034 a2 DW
5 DUP(
0)
</font></pre>
4036 <font face=
"Fixedsys">
4037 <table noshade=
"" border=
"1">
4038 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4039 <tr> <td colspan=
"6">unchanged
</td> </tr>
4043 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4046 <a name=
"MUL"> </a>
4055 <font face=
"Fixedsys">
4060 <font face=
"Fixedsys">
4070 <br><br>Algorithm:
<br><br>
4072 when operand is a
<b>byte
</b>:
<br>
4073 <font face=
"Fixedsys">AX = AL * operand
</font>.
4077 when operand is a
<b>word
</b>:
<br>
4078 <font face=
"Fixedsys">(DX AX) = AX * operand
</font>.
4080 Example:
<pre><font face=
"Fixedsys">MOV AL,
200 ; AL =
0C8h
4082 MUL BL ; AX =
0320h (
800)
4085 <font face=
"Fixedsys">
4086 <table noshade=
"" border=
"1">
4087 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4088 <tr> <td>r
</td> <td>?
</td> <td>?
</td> <td>r
</td> <td>?
</td> <td>?
</td> </tr>
4090 CF=OF=
0 when high section of the result is zero.
4093 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4096 <a name=
"NEG"> </a>
4105 <font face=
"Fixedsys">
4110 <font face=
"Fixedsys">
4119 Negate. Makes operand negative (two's complement).
4120 <br><br>Algorithm:
<br><br>
4121 <font face=
"Fixedsys">
4123 <li>Invert all bits of the operand
</li>
4124 <li>Add
1 to inverted operand
</li>
4127 Example:
<pre><font face=
"Fixedsys">MOV AL,
5 ; AL =
05h
4128 NEG AL ; AL =
0FBh (-
5)
4129 NEG AL ; AL =
05h (
5)
4132 <font face=
"Fixedsys">
4133 <table noshade=
"" border=
"1">
4134 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4135 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
4139 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4142 <a name=
"NOP"> </a>
4151 <font face=
"Fixedsys">
4155 <td>No operands
</td>
4158 No Operation.
<br><br>Algorithm:
4160 <font face=
"Fixedsys">
4162 <font face=
"Fixedsys"><li>Do nothing
<br></li>
4164 <font face=
"Fixedsys"></font>
4165 Example:
<pre><font face=
"Fixedsys">; do nothing,
3 times:
4171 <font face=
"Fixedsys">
4172 <table noshade=
"" border=
"1">
4173 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4174 <tr> <td colspan=
"6">unchanged
</td> </tr>
4178 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4181 <a name=
"NOT"> </a>
4190 <font face=
"Fixedsys">
4195 <font face=
"Fixedsys">
4204 Invert each bit of the operand.
<br><br>Algorithm:
4206 <font face=
"Fixedsys">
4208 <li>if bit is
1 turn it to
0.
<br></li>
4209 <li>if bit is
0 turn it to
1.
<br></li>
4212 Example:
<pre><font face=
"Fixedsys">MOV AL,
00011011b
4213 NOT AL ; AL =
11100100b
4216 <font face=
"Fixedsys">
4217 <table noshade=
"" border=
"1">
4218 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4219 <tr> <td colspan=
"6">unchanged
</td> </tr>
4223 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4226 <a name=
"OR"> </a>
4234 <font face=
"Fixedsys">
4239 <font face=
"Fixedsys">
4244 memory, immediate
<br>
4251 Logical OR between all bits of two operands.
4252 Result is stored in first operand.
<br><br>
4253 These rules apply:
<br><br>
4254 <font face=
"Fixedsys">
4260 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AL, 'A' ; AL =
01000001b
4261 OR AL,
00100000b ; AL =
01100001b ('a')
4264 <font face=
"Fixedsys">
4265 <table noshade=
"" border=
"1">
4266 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4267 <tr> <td>0</td> <td>r
</td> <td>r
</td> <td>0</td> <td>r
</td> <td>?
</td> </tr>
4271 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4274 <a name=
"OUT"> </a>
4280 <font face=
"Fixedsys">
4285 <font face=
"Fixedsys">
4296 Output from
<b>AL
</b> or
<b>AX
</b> to port.
<br>
4297 First operand is a port number. If required to access
4298 port number over
255 -
<b>DX
</b> register should be used.
4300 <br><br>Example:
<pre><font face=
"Fixedsys">MOV AX,
0FFFh ; Turn on all
4301 OUT
4, AX ; traffic lights.
4303 MOV AL,
100b ; Turn on the third
4304 OUT
7, AL ; magnet of the stepper-motor.
</font></pre>
4306 <font face=
"Fixedsys">
4307 <table noshade=
"" border=
"1">
4308 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4309 <tr> <td colspan=
"6">unchanged
</td> </tr>
4313 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4316 <a name=
"POP"> </a>
4323 <font face=
"Fixedsys">
4328 <font face=
"Fixedsys">
4338 Get
16 bit value from the stack.
4339 <br><br>Algorithm:
<br><br>
4340 <font face=
"Fixedsys">
4342 <li>operand = SS:[SP] (top of the stack)
</li>
4343 <li>SP = SP +
2</li>
4346 <br>Example:
<pre><font face=
"Fixedsys">MOV AX,
1234h
4351 <font face=
"Fixedsys">
4352 <table noshade=
"" border=
"1">
4353 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4354 <tr> <td colspan=
"6">unchanged
</td> </tr>
4358 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4361 <a name=
"POPA"> </a>
4370 <font face=
"Fixedsys">
4374 <td>No operands
</td>
4377 Pop all general purpose registers DI, SI, BP, SP, BX, DX, CX, AX from the stack.
<br>
4378 SP value is ignored, it is Popped but not set to SP register).
<br><br>
4379 Note: this instruction works only on
<b>80186</b> CPU and later!
4380 <br><br>Algorithm:
<br><br>
4381 <font face=
"Fixedsys">
4386 <li>POP xx (SP value ignored)
</li>
4394 <font face=
"Fixedsys">
4395 <table noshade=
"" border=
"1">
4396 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4397 <tr> <td colspan=
"6">unchanged
</td> </tr>
4401 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4404 <a name=
"POPF"> </a>
4413 <font face=
"Fixedsys">
4417 <td>No operands
</td>
4420 Get flags register from the stack.
4421 <br><br>Algorithm:
<br><br>
4422 <font face=
"Fixedsys">
4424 <li>flags = SS:[SP] (top of the stack)
</li>
4425 <li>SP = SP +
2</li>
4429 <font face=
"Fixedsys">
4430 <table noshade=
"" border=
"1">
4431 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4432 <tr> <td colspan=
"6"><center>popped
</center></td> </tr>
4436 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4439 <a name=
"PUSH"> </a>
4448 <font face=
"Fixedsys">
4453 <font face=
"Fixedsys">
4464 Store
16 bit value in the stack.
<br><br>
4466 Note:
<b>PUSH immediate
</b> works only on
80186 CPU and later!
4467 <br><br>Algorithm:
<br><br>
4468 <font face=
"Fixedsys">
4470 <li>SP = SP -
2</li>
4471 <li>SS:[SP] (top of the stack) = operand
</li>
4474 <br>Example:
<pre><font face=
"Fixedsys">MOV AX,
1234h
4479 <font face=
"Fixedsys">
4480 <table noshade=
"" border=
"1">
4481 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4482 <tr> <td colspan=
"6">unchanged
</td> </tr>
4486 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4489 <a name=
"PUSHA"> </a>
4498 <font face=
"Fixedsys">
4502 <td>No operands
</td>
4505 Push all general purpose registers AX, CX, DX, BX, SP, BP, SI, DI in the stack.
<br>
4506 Original value of SP register (before PUSHA) is used.
<br><br>
4507 Note: this instruction works only on
<b>80186</b> CPU and later!
4508 <br><br>Algorithm:
<br><br>
4509 <font face=
"Fixedsys">
4522 <font face=
"Fixedsys">
4523 <table noshade=
"" border=
"1">
4524 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4525 <tr> <td colspan=
"6">unchanged
</td> </tr>
4529 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4532 <a name=
"PUSHF"> </a>
4541 <font face=
"Fixedsys">
4545 <td>No operands
</td>
4548 Store flags register in the stack.
4549 <br><br>Algorithm:
<br><br>
4550 <font face=
"Fixedsys">
4552 <font face=
"Fixedsys"> <li>SP = SP -
2</li>
4553 <li>SS:[SP] (top of the stack) = flags
</li>
4555 <font face=
"Fixedsys"> </font>
4557 <font face=
"Fixedsys">
4558 <table noshade=
"" border=
"1">
4559 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4560 <tr> <td colspan=
"6">unchanged
</td> </tr>
4564 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4567 <a name=
"RCL"> </a>
4576 <font face=
"Fixedsys">
4581 <font face=
"Fixedsys">
4582 <nobr>memory, immediate
</nobr><br>
4583 <nobr>REG, immediate
</nobr><br><br>
4584 <nobr>memory, CL
</nobr><br>
4585 <nobr>REG, CL
</nobr>
4590 Rotate operand1 left through Carry Flag. The number of rotates is set by operand2.
4592 When
<b>immediate
</b> is greater then
1, assembler generates several
4593 <b>RCL xx,
1</b> instructions because
8086 has machine code only for this
4594 instruction (the same principle works for all other shift/rotate instructions).
4596 <br><br>Algorithm:
<br><br>
4597 <font face=
"Fixedsys">
4599 shift all bits left, the bit that goes off is set to
4600 CF and previous value of CF is inserted to the right-most position.
4603 <br>Example:
<pre><font face=
"Fixedsys">STC ; set carry (CF=
1).
4604 MOV AL,
1Ch ; AL =
00011100b
4605 RCL AL,
1 ; AL =
00111001b, CF=
0.
4608 <font face=
"Fixedsys">
4609 <table noshade=
"" border=
"1">
4610 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
4611 <tr> <td>r
</td> <td>r
</td> </tr>
4613 OF=
0 if first operand keeps original sign.
4616 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4619 <a name=
"RCR"> </a>
4628 <font face=
"Fixedsys">
4633 <font face=
"Fixedsys">
4634 <nobr>memory, immediate
</nobr><br>
4635 <nobr>REG, immediate
</nobr><br><br>
4636 <nobr>memory, CL
</nobr><br>
4637 <nobr>REG, CL
</nobr>
4642 Rotate operand1 right through Carry Flag. The number of rotates is set by operand2.
4644 <br><br>Algorithm:
<br><br>
4645 <font face=
"Fixedsys">
4647 shift all bits right, the bit that goes off is set to
4648 CF and previous value of CF is inserted to the left-most position.
4651 <br>Example:
<pre><font face=
"Fixedsys">STC ; set carry (CF=
1).
4652 MOV AL,
1Ch ; AL =
00011100b
4653 RCR AL,
1 ; AL =
10001110b, CF=
0.
4656 <font face=
"Fixedsys">
4657 <table noshade=
"" border=
"1">
4658 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
4659 <tr> <td>r
</td> <td>r
</td> </tr>
4661 OF=
0 if first operand keeps original sign.
4664 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4667 <a name=
"REP"> </a>
4676 <font face=
"Fixedsys">
4681 <font face=
"Fixedsys">
4682 <nobr>chain instruction
</nobr><br>
4687 Repeat following MOVSB, MOVSW, LODSB, LODSW, STOSB, STOSW instructions
4689 <br><br>Algorithm:
<br><br>
4690 <font face=
"Fixedsys">
4692 if CX
<> 0 then
4694 <li>do following
<u>chain instruction
</u></li>
4695 <li>CX = CX -
1</li>
4696 <li>go back to check_cx
</li>
4700 <li>exit from REP cycle
</li>
4704 <font face=
"Fixedsys">
4705 <table noshade=
"" border=
"1">
4706 <tbody><tr> <td>Z
</td> </tr>
4707 <tr> <td>r
</td> </tr>
4711 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4714 <a name=
"REPE"> </a>
4724 <font face=
"Fixedsys">
4729 <font face=
"Fixedsys">
4730 <nobr>chain instruction
</nobr><br>
4735 Repeat following CMPSB, CMPSW, SCASB, SCASW instructions
4736 while ZF =
1 (result is Equal), maximum CX times.
4737 <br><br>Algorithm:
<br><br>
4738 <font face=
"Fixedsys">
4740 if CX
<> 0 then
4742 <li>do following
<u>chain instruction
</u></li>
4743 <li>CX = CX -
1</li>
4746 <li>go back to check_cx
</li>
4750 <li>exit from REPE cycle
</li>
4756 <li>exit from REPE cycle
</li>
4760 see
<b>cmpsb.asm
</b> in c:\emu8086\examples\.
4764 <font face=
"Fixedsys">
4765 <table noshade=
"" border=
"1">
4766 <tbody><tr> <td>Z
</td> </tr>
4767 <tr> <td>r
</td> </tr>
4771 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4774 <a name=
"REPNE"> </a>
4784 <font face=
"Fixedsys">
4789 <font face=
"Fixedsys">
4790 <nobr>chain instruction
</nobr><br>
4795 Repeat following CMPSB, CMPSW, SCASB, SCASW instructions
4796 while ZF =
0 (result is Not Equal), maximum CX times.
4797 <br><br>Algorithm:
<br><br>
4798 <font face=
"Fixedsys">
4800 if CX
<> 0 then
4802 <li>do following
<u>chain instruction
</u></li>
4803 <li>CX = CX -
1</li>
4806 <li>go back to check_cx
</li>
4810 <li>exit from REPNE cycle
</li>
4816 <li>exit from REPNE cycle
</li>
4820 <font face=
"Fixedsys">
4821 <table noshade=
"" border=
"1">
4822 <tbody><tr> <td>Z
</td> </tr>
4823 <tr> <td>r
</td> </tr>
4827 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4830 <a name=
"REPNZ"> </a>
4840 <font face=
"Fixedsys">
4845 <font face=
"Fixedsys">
4846 <nobr>chain instruction
</nobr><br>
4851 Repeat following CMPSB, CMPSW, SCASB, SCASW instructions
4852 while ZF =
0 (result is Not Zero), maximum CX times.
4853 <br><br>Algorithm:
<br><br>
4854 <font face=
"Fixedsys">
4856 if CX
<> 0 then
4858 <font face=
"Fixedsys"> <li>do following
<u>chain instruction
</u></li>
4859 <li>CX = CX -
1</li>
4862 <li>go back to check_cx
</li>
4866 <li>exit from REPNZ cycle
</li>
4870 <font face=
"Fixedsys">else
4872 <font face=
"Fixedsys"> <li>exit from REPNZ cycle
</li>
4874 <font face=
"Fixedsys"></font>
4876 <font face=
"Fixedsys">
4877 <table noshade=
"" border=
"1">
4878 <tbody><tr> <td>Z
</td> </tr>
4879 <tr> <td>r
</td> </tr>
4883 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4886 <a name=
"REPZ"> </a>
4896 <font face=
"Fixedsys">
4901 <font face=
"Fixedsys">
4902 <nobr>chain instruction
</nobr><br>
4907 Repeat following CMPSB, CMPSW, SCASB, SCASW instructions
4908 while ZF =
1 (result is Zero), maximum CX times.
4909 <br><br>Algorithm:
<br><br>
4910 <font face=
"Fixedsys">
4912 if CX
<> 0 then
4914 <li>do following
<u>chain instruction
</u></li>
4915 <li>CX = CX -
1</li>
4918 <li>go back to check_cx
</li>
4922 <li>exit from REPZ cycle
</li>
4928 <li>exit from REPZ cycle
</li>
4932 <font face=
"Fixedsys">
4933 <table noshade=
"" border=
"1">
4934 <tbody><tr> <td>Z
</td> </tr>
4935 <tr> <td>r
</td> </tr>
4939 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4942 <a name=
"RET"> </a>
4951 <font face=
"Fixedsys">
4956 or even immediate
</td>
4959 Return from near procedure.
4960 <br><br>Algorithm:
<br><br>
4961 <font face=
"Fixedsys">
4963 <font face=
"Fixedsys"> <li>
4970 if
<u>immediate
</u> operand is present:
4971 <nobr>SP = SP + operand
</nobr>
4974 <font face=
"Fixedsys"></font>
4975 Example:
<pre><font face=
"Fixedsys">
4976 ORG
100h ; for COM file.
4984 p1 PROC ; procedure declaration.
4986 RET ; return to caller.
4987 p1 ENDP
</font></pre>
4989 <font face=
"Fixedsys">
4990 <table noshade=
"" border=
"1">
4991 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
4992 <tr> <td colspan=
"6">unchanged
</td> </tr>
4996 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
4999 <a name=
"RETF"> </a>
5008 <font face=
"Fixedsys">
5013 or even immediate
</td>
5016 Return from Far procedure.
5017 <br><br>Algorithm:
<br><br>
5018 <font face=
"Fixedsys">
5028 if
<u>immediate
</u> operand is present:
5029 <nobr>SP = SP + operand
</nobr>
5034 <font face=
"Fixedsys">
5035 <table noshade=
"" border=
"1">
5036 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5037 <tr> <td colspan=
"6">unchanged
</td> </tr>
5041 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5044 <a name=
"ROL"> </a>
5053 <font face=
"Fixedsys">
5058 <font face=
"Fixedsys">
5059 <nobr>memory, immediate
</nobr><br>
5060 <nobr>REG, immediate
</nobr><br><br>
5061 <nobr>memory, CL
</nobr><br>
5062 <nobr>REG, CL
</nobr>
5067 Rotate operand1 left. The number of rotates is set by operand2.
5069 <br><br>Algorithm:
<br><br>
5070 <font face=
"Fixedsys">
5072 shift all bits left, the bit that goes off is set to
5073 CF and the same bit is inserted to the right-most position.
5076 Example:
<pre><font face=
"Fixedsys">MOV AL,
1Ch ; AL =
00011100b
5077 ROL AL,
1 ; AL =
00111000b, CF=
0.
5080 <font face=
"Fixedsys">
5081 <table noshade=
"" border=
"1">
5082 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
5083 <tr> <td>r
</td> <td>r
</td> </tr>
5085 OF=
0 if first operand keeps original sign.
5088 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5091 <a name=
"ROR"> </a>
5100 <font face=
"Fixedsys">
5105 <font face=
"Fixedsys">
5106 <nobr>memory, immediate
</nobr><br>
5107 <nobr>REG, immediate
</nobr><br><br>
5108 <nobr>memory, CL
</nobr><br>
5109 <nobr>REG, CL
</nobr>
5114 Rotate operand1 right. The number of rotates is set by operand2.
5116 <br><br>Algorithm:
<br><br>
5117 <font face=
"Fixedsys">
5119 shift all bits right, the bit that goes off is set to
5120 CF and the same bit is inserted to the left-most position.
5123 Example:
<pre><font face=
"Fixedsys">MOV AL,
1Ch ; AL =
00011100b
5124 ROR AL,
1 ; AL =
00001110b, CF=
0.
5127 <font face=
"Fixedsys">
5128 <table noshade=
"" border=
"1">
5129 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
5130 <tr> <td>r
</td> <td>r
</td> </tr>
5132 OF=
0 if first operand keeps original sign.
5135 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5138 <a name=
"SAHF"> </a>
5147 <font face=
"Fixedsys">
5151 <td>No operands
</td>
5154 Store AH register into low
8 bits of Flags register.
5155 <br><br>Algorithm:
<br><br>
5156 <font face=
"Fixedsys">
5158 flags register = AH
<br>
5160 <pre><font face=
"Fixedsys">
5161 AH bit:
7 6 5 4 3 2 1 0
5162 [SF] [ZF] [
0] [AF] [
0] [PF] [
1] [CF]
</font>
5164 bits
1,
3,
5 are reserved.
5170 <font face=
"Fixedsys">
5171 <table noshade=
"" border=
"1">
5172 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5173 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
5178 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5181 <a name=
"SAL"> </a>
5191 <font face=
"Fixedsys">
5196 <font face=
"Fixedsys">
5197 <nobr>memory, immediate
</nobr><br>
5198 <nobr>REG, immediate
</nobr><br><br>
5199 <nobr>memory, CL
</nobr><br>
5200 <nobr>REG, CL
</nobr>
5205 Shift Arithmetic operand1 Left. The number of shifts is set by operand2.
5207 <br><br>Algorithm:
<br><br>
5208 <font face=
"Fixedsys">
5210 <font face=
"Fixedsys"> <li>Shift all bits left, the bit that goes off is set to CF.
</li>
5211 <li>Zero bit is inserted to the right-most position.
</li>
5213 <font face=
"Fixedsys"></font>
5214 Example:
<pre><font face=
"Fixedsys">MOV AL,
0E0h ; AL =
11100000b
5215 SAL AL,
1 ; AL =
11000000b, CF=
1.
5218 <font face=
"Fixedsys">
5219 <table noshade=
"" border=
"1">
5220 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
5221 <tr> <td>r
</td> <td>r
</td> </tr>
5223 OF=
0 if first operand keeps original sign.
5226 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5229 <a name=
"SAR"> </a>
5239 <font face=
"Fixedsys">
5244 <font face=
"Fixedsys">
5245 <nobr>memory, immediate
</nobr><br>
5246 <nobr>REG, immediate
</nobr><br><br>
5247 <nobr>memory, CL
</nobr><br>
5248 <nobr>REG, CL
</nobr>
5253 Shift Arithmetic operand1 Right. The number of shifts is set by operand2.
5255 <br><br>Algorithm:
<br><br>
5256 <font face=
"Fixedsys">
5258 <li>Shift all bits right, the bit that goes off is set to CF.
</li>
5259 <li>The sign bit that is inserted to the left-most position has
5260 the same value as before shift.
</li>
5263 Example:
<pre><font face=
"Fixedsys">MOV AL,
0E0h ; AL =
11100000b
5264 SAR AL,
1 ; AL =
11110000b, CF=
0.
5266 MOV BL,
4Ch ; BL =
01001100b
5267 SAR BL,
1 ; BL =
00100110b, CF=
0.
5271 <font face=
"Fixedsys">
5272 <table noshade=
"" border=
"1">
5273 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
5274 <tr> <td>r
</td> <td>r
</td> </tr>
5276 OF=
0 if first operand keeps original sign.
5279 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5282 <a name=
"SBB"> </a>
5291 <font face=
"Fixedsys">
5296 <font face=
"Fixedsys">
5301 memory, immediate
<br>
5308 Subtract with Borrow.
5309 <br><br>Algorithm:
<br><br>
5310 <font face=
"Fixedsys">
5311 operand1 = operand1 - operand2 - CF
5314 Example:
<pre><font face=
"Fixedsys">STC
5316 SBB AL,
3 ; AL =
5 -
3 -
1 =
1
5320 <font face=
"Fixedsys">
5321 <table noshade=
"" border=
"1">
5322 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5323 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
5327 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5330 <a name=
"SCASB"> </a>
5340 <font face=
"Fixedsys">
5344 <td>No operands
</td>
5347 Compare bytes:
<nobr>AL from ES:[DI].
</nobr> <br><br>Algorithm:
5349 <font face=
"Fixedsys">
5351 <font face=
"Fixedsys"><li>ES:[DI] - AL
<br></li>
5352 <li>set flags according to result:
<br> OF, SF, ZF, AF, PF, CF
<br></li>
5355 <li>DI = DI +
1</li>
5359 <li>DI = DI -
1</li>
5363 <font face=
"Fixedsys"></font>
5365 <font face=
"Fixedsys">
5366 <table noshade=
"" border=
"1">
5367 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5368 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
5372 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5375 <a name=
"SCASW"> </a>
5384 <font face=
"Fixedsys">
5388 <td>No operands
</td>
5391 Compare words:
<nobr>AX from ES:[DI].
</nobr> <br><br>Algorithm:
5393 <font face=
"Fixedsys">
5395 <li>ES:[DI] - AX
<br></li>
5396 <li>set flags according to result:
<br> OF, SF, ZF, AF, PF, CF
<br></li>
5399 <li>DI = DI +
2</li>
5403 <li>DI = DI -
2</li>
5409 <font face=
"Fixedsys">
5410 <table noshade=
"" border=
"1">
5411 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5412 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
5416 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5419 <a name=
"SHL"> </a>
5429 <font face=
"Fixedsys">
5434 <font face=
"Fixedsys">
5435 <nobr>memory, immediate
</nobr><br>
5436 <nobr>REG, immediate
</nobr><br><br>
5437 <nobr>memory, CL
</nobr><br>
5438 <nobr>REG, CL
</nobr>
5443 Shift operand1 Left. The number of shifts is set by operand2.
5445 <br><br>Algorithm:
<br><br>
5446 <font face=
"Fixedsys">
5448 <li>Shift all bits left, the bit that goes off is set to CF.
</li>
5449 <li>Zero bit is inserted to the right-most position.
</li>
5452 Example:
<pre><font face=
"Fixedsys">MOV AL,
11100000b
5453 SHL AL,
1 ; AL =
11000000b, CF=
1.
5457 <font face=
"Fixedsys">
5458 <table noshade=
"" border=
"1">
5459 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
5460 <tr> <td>r
</td> <td>r
</td> </tr>
5462 OF=
0 if first operand keeps original sign.
5465 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5468 <a name=
"SHR"> </a>
5478 <font face=
"Fixedsys">
5483 <font face=
"Fixedsys">
5484 <nobr>memory, immediate
</nobr><br>
5485 <nobr>REG, immediate
</nobr><br><br>
5486 <nobr>memory, CL
</nobr><br>
5487 <nobr>REG, CL
</nobr>
5492 Shift operand1 Right. The number of shifts is set by operand2.
5494 <br><br>Algorithm:
<br><br>
5495 <font face=
"Fixedsys">
5497 <li>Shift all bits right, the bit that goes off is set to CF.
</li>
5498 <li>Zero bit is inserted to the left-most position.
</li>
5501 Example:
<pre><font face=
"Fixedsys">MOV AL,
00000111b
5502 SHR AL,
1 ; AL =
00000011b, CF=
1.
5506 <font face=
"Fixedsys">
5507 <table noshade=
"" border=
"1">
5508 <tbody><tr> <td>C
</td> <td>O
</td> </tr>
5509 <tr> <td>r
</td> <td>r
</td> </tr>
5511 OF=
0 if first operand keeps original sign.
5514 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5517 <a name=
"STC"> </a>
5526 <font face=
"Fixedsys">
5530 <td>No operands
</td>
5533 Set Carry flag.
<br><br>Algorithm:
5535 <font face=
"Fixedsys">
5541 <font face=
"Fixedsys">
5542 <table noshade=
"" border=
"1">
5543 <tbody><tr> <td>C
</td> </tr>
5544 <tr> <td>1</td> </tr>
5548 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5551 <a name=
"STD"> </a>
5560 <font face=
"Fixedsys">
5564 <td>No operands
</td>
5567 Set Direction flag. SI and DI will be decremented by chain
5568 instructions: CMPSB, CMPSW, LODSB, LODSW, MOVSB, MOVSW, STOSB, STOSW.
<br><br>Algorithm:
5570 <font face=
"Fixedsys">
5575 <font face=
"Fixedsys">
5576 <table noshade=
"" border=
"1">
5577 <tbody><tr> <td>D
</td> </tr>
5578 <tr> <td>1</td> </tr>
5582 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5585 <a name=
"STI"> </a>
5596 <font face=
"Fixedsys">
5600 <td>No operands
</td>
5603 Set Interrupt enable flag. This enables hardware interrupts.
<br><br>Algorithm:
5605 <font face=
"Fixedsys">
5610 <font face=
"Fixedsys">
5611 <table noshade=
"" border=
"1">
5612 <tbody><tr> <td>I
</td> </tr>
5613 <tr> <td>1</td> </tr>
5617 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5620 <a name=
"STOSB"> </a>
5629 <font face=
"Fixedsys">
5633 <td>No operands
</td>
5636 Store byte in AL into ES:[DI]. Update DI.
<br><br>Algorithm:
5638 <font face=
"Fixedsys">
5640 <li>ES:[DI] = AL
<br></li>
5643 <li>DI = DI +
1</li>
5647 <li>DI = DI -
1</li>
5653 <pre><font face=
"Fixedsys">
5664 a1 DB
5 dup(
0)
</font></pre>
5666 <font face=
"Fixedsys">
5667 <table noshade=
"" border=
"1">
5668 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5669 <tr> <td colspan=
"6">unchanged
</td> </tr>
5673 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5676 <a name=
"STOSW"> </a>
5686 <font face=
"Fixedsys">
5690 <td>No operands
</td>
5693 Store word in AX into ES:[DI]. Update DI.
<br><br>Algorithm:
5695 <font face=
"Fixedsys">
5697 <li>ES:[DI] = AX
<br></li>
5700 <li>DI = DI +
2</li>
5704 <li>DI = DI -
2</li>
5710 <pre><font face=
"Fixedsys">
5721 a1 DW
5 dup(
0)
</font></pre>
5723 <font face=
"Fixedsys">
5724 <table noshade=
"" border=
"1">
5725 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5726 <tr> <td colspan=
"6">unchanged
</td> </tr>
5730 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5733 <a name=
"SUB"> </a>
5744 <font face=
"Fixedsys">
5749 <font face=
"Fixedsys">
5754 memory, immediate
<br>
5762 <br><br>Algorithm:
<br><br>
5763 <font face=
"Fixedsys">
5764 operand1 = operand1 - operand2
5767 Example:
<pre><font face=
"Fixedsys">MOV AL,
5
5772 <font face=
"Fixedsys">
5773 <table noshade=
"" border=
"1">
5774 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5775 <tr> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> <td>r
</td> </tr>
5779 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5782 <a name=
"TEST"> </a>
5793 <font face=
"Fixedsys">
5798 <font face=
"Fixedsys">
5803 memory, immediate
<br>
5810 Logical AND between all bits of two operands for flags only.
5811 These flags are effected:
<b>ZF, SF, PF.
</b>
5812 Result is not stored anywhere.
<br><br>
5813 These rules apply:
<br><br>
5814 <font face=
"Fixedsys">
5821 Example:
<pre><font face=
"Fixedsys">MOV AL,
00000101b
5822 TEST AL,
1 ; ZF =
0.
5823 TEST AL,
10b ; ZF =
1.
5826 <font face=
"Fixedsys">
5827 <table noshade=
"" border=
"1">
5828 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> </tr>
5829 <tr> <td>0</td> <td>r
</td> <td>r
</td> <td>0</td> <td>r
</td> </tr>
5833 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5836 <a name=
"XCHG"> </a>
5847 <font face=
"Fixedsys">
5852 <font face=
"Fixedsys">
5862 Exchange values of two operands.
5863 <br><br>Algorithm:
<br><br>
5864 <font face=
"Fixedsys">
5865 operand1
< -
> operand2
5868 Example:
<pre><font face=
"Fixedsys">MOV AL,
5
5870 XCHG AL, AH ; AL =
2, AH =
5
5871 XCHG AL, AH ; AL =
5, AH =
2
5874 <font face=
"Fixedsys">
5875 <table noshade=
"" border=
"1">
5876 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5877 <tr> <td colspan=
"6">unchanged
</td> </tr>
5881 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5884 <a name=
"XLATB"> </a>
5895 <font face=
"Fixedsys">
5899 <td>No operands
</td>
5902 Translate byte from table.
<br>
5903 Copy value of memory byte at
<nobr>DS:[BX + unsigned AL]
</nobr> to
5905 <br><br>Algorithm:
<br><br>
5906 <font face=
"Fixedsys">
5907 AL = DS:[BX + unsigned AL]
5910 Example:
<pre><font face=
"Fixedsys">
5918 dat DB
11h,
22h,
33h,
44h,
55h
</font></pre>
5920 <font face=
"Fixedsys">
5921 <table noshade=
"" border=
"1">
5922 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5923 <tr> <td colspan=
"6">unchanged
</td> </tr>
5927 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5930 <a name=
"XOR"> </a>
5942 <font face=
"Fixedsys">
5947 <font face=
"Fixedsys">
5952 memory, immediate
<br>
5959 Logical XOR (Exclusive OR) between all bits of two operands.
5960 Result is stored in first operand.
<br><br>
5961 These rules apply:
<br><br>
5962 <font face=
"Fixedsys">
5969 Example:
<pre><font face=
"Fixedsys">MOV AL,
00000111b
5970 XOR AL,
00000010b ; AL =
00000101b
5974 <font face=
"Fixedsys">
5975 <table noshade=
"" border=
"1">
5976 <tbody><tr> <td>C
</td> <td>Z
</td> <td>S
</td> <td>O
</td> <td>P
</td> <td>A
</td> </tr>
5977 <tr> <td>0</td> <td>r
</td> <td>r
</td> <td>0</td> <td>r
</td> <td>?
</td> </tr>
5982 <a href=
"#top1"><img src=
"8086_instruction_set_files/back_to_top.gif" alt=
"Back to Top" align=
"right" border=
"0" width=
"41" height=
"36"></a>
5998 <font size=
"3" face=
"Verdana"><br><br><br>
6000 <font size=
"3" face=
"Verdana"><font size=
"2">
6001 copyright ©
<font size=
"1">2005</font> <a href=
"http://www.emu8086.com/">emu8086.com
</a><br>
6002 all rights reserved.
<br>
6007 <font size=
"3" face=
"Verdana"></font>
6012 <iframe src=
"8086_instruction_set_files/z_bot_menu.html" marginwidth=
"0" marginheight=
"0" align=
"middle" scrolling=
"auto" width=
"100%" frameborder=
"0" height=
"100"></iframe><br>