Introduce pet-projects dir
[lcapit-junk-code.git] / pet-projects / emu8086 / docs / 8086_instruction_set.html
blobdbefa2856fb0b02cd5cf02654c6fa6876b0963df
1 <html><head>
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"> &nbsp; </a>
21 <font size="3" face="Verdana">
23 <font size="+2">
24 <b>Complete 8086 instruction set</b>
25 </font>
28 <!-- 116 instructions -->
30 </font><hr>
31 <font size="3" face="Verdana"><br>
32 Quick reference:<br><br>
33 <font face="Fixedsys">
35 <table border="0" width="100%">
36 <tbody><tr>
38 <td>
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>
54 </td><td>
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>
75 </td><td>
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>
91 </td><td>
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>
107 </td><td>
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>
123 </td><td>
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>
144 </td><td>
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>
160 </td><td>
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>
176 </td>
177 </tr>
178 </tbody></table>
180 </font>
181 <br><br>
183 </font><hr>
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>
196 </font><hr>
198 <font size="3" face="Verdana"><br>
199 Notes:<br><br>
200 </font><ul>
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">
203 REG, memory
204 </font>
205 <br><br></li>
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">
209 AL, DL<br>
210 DX, AX<br>
211 <font color="#005555">
212 m1 DB ?<br>
213 </font>
214 AL, m1<br>
215 <font color="#005555">
216 m2 DW ?<br>
217 </font>
218 AX, m2
219 </font>
220 <br><br>
221 </li>
222 <li>Some instructions allow several operand combinations.
223 For example:<br><br>
224 <font face="Fixedsys">
225 memory, immediate<br>
226 REG, immediate<br><br>
227 memory, REG<br>
228 REG, SREG
229 </font><br><br>
230 </li>
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'
239 ORG 100h
240 MOV AL, 1
241 MOV BL, 2
242 PRINTN 'Hello World!' ; macro.
243 MOV CL, 3
244 PRINTN 'Welcome!' ; macro.
245 RET</font></pre>
246 </li>
248 </font></ul>
249 <font size="3" face="Verdana"><br>
251 </font><hr>
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>
258 <br><br>
260 </font><hr>
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>
268 <br><br><br>
269 </font><hr>
271 <font size="3" face="Verdana"><br><br>
272 Instructions in alphabetical order:
274 <br><br>
276 <table border="1" cellpadding="10" width="100%">
278 <tbody><tr>
279 <td>Instruction</td> <td>Operands</td> <td>Description
280 <a name="AAA">&nbsp;</a>
281 </td>
282 </tr>
287 <tr>
288 <td>
289 <font face="Fixedsys">
291 </font>
292 </td>
293 <td>No operands</td>
294 <td>
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:
299 <br><br>
300 <font face="Fixedsys">
301 if low nibble of AL &gt; 9 or AF = 1 then:<br>
302 <ul>
303 <li>AL = AL + 6</li>
304 <li>AH = AH + 1</li>
305 <li>AF = 1</li>
306 <li>CF = 1</li>
307 </ul>
308 else
309 <ul>
310 <li>AF = 0</li>
311 <li>CF = 0</li>
312 </ul>
313 in both cases:<br>
314 clear the high nibble of AL.
315 </font>
316 <br><br>Example:<pre><font face="Fixedsys">MOV AX, 15 ; AH = 00, AL = 0Fh
317 AAA ; AH = 01, AL = 05
318 RET</font></pre>
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>
324 </tbody></table>
325 </font>
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">&nbsp;</a>
331 </td>
332 </tr>
337 <tr>
338 <td>
339 <font face="Fixedsys">
341 </font>
342 </td>
343 <td>No operands</td>
344 <td>
346 ASCII Adjust before Division.<br>
347 Prepares two BCD values for division. <br><br>Algorithm:
348 <br><br>
349 <font face="Fixedsys">
350 <ul>
351 <li>AL = (AH * 10) + AL</li>
352 <li>AH = 0</li>
353 </ul>
354 </font>
355 <br>Example:<pre><font face="Fixedsys">MOV AX, 0105h ; AH = 01, AL = 05
356 AAD ; AH = 00, AL = 0Fh (15)
357 RET</font></pre>
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>
363 </tbody></table>
364 </font>
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">&nbsp;</a>
370 </td>
371 </tr>
376 <tr>
377 <td>
378 <font face="Fixedsys">
380 </font>
381 </td>
382 <td>No operands</td>
383 <td>
385 ASCII Adjust after Multiplication.<br>
386 Corrects the result of multiplication of two BCD values. <br><br>Algorithm:
387 <br><br>
388 <font face="Fixedsys">
389 <ul>
390 <li>AH = AL / 10</li>
391 <li>AL = remainder</li>
392 </ul>
393 </font>
394 <br>Example:<pre><font face="Fixedsys">MOV AL, 15 ; AL = 0Fh
395 AAM ; AH = 01, AL = 05
396 RET</font></pre>
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>
402 </tbody></table>
403 </font>
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">&nbsp;</a>
409 </td>
410 </tr>
415 <tr>
416 <td>
417 <font face="Fixedsys">
419 </font>
420 </td>
421 <td>No operands</td>
422 <td>
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 &gt; 9 or AF = 1 then:<br>
429 <ul>
430 <li>AL = AL - 6</li>
431 <li>AH = AH - 1</li>
432 <li>AF = 1</li>
433 <li>CF = 1</li>
434 </ul>
435 else
436 <ul>
437 <li>AF = 0</li>
438 <li>CF = 0</li>
439 </ul>
440 in both cases:<br>
441 clear the high nibble of AL.
442 </font>
443 <br><br>Example:<pre><font face="Fixedsys">MOV AX, 02FFh ; AH = 02, AL = 0FFh
444 AAS ; AH = 01, AL = 09
445 RET</font></pre>
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>
451 </tbody></table>
452 </font>
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">&nbsp;</a>
458 </td>
459 </tr>
464 <tr>
465 <td>
466 <font face="Fixedsys">
468 </font>
469 </td>
470 <td>
471 <font face="Fixedsys">
472 <nobr>
473 REG, memory<br>
474 memory, REG<br>
475 REG, REG<br>
476 memory, immediate<br>
477 REG, immediate
478 </nobr>
479 </font>
480 </td>
481 <td>
483 Add with Carry.<br>
484 <br><br>Algorithm:<br><br>
485 <font face="Fixedsys">
486 operand1 = operand1 + operand2 + CF
487 </font>
488 <br><br>Example:<pre><font face="Fixedsys">STC ; set CF = 1
489 MOV AL, 5 ; AL = 5
490 ADC AL, 1 ; AL = 7
491 RET</font></pre>
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>
497 </tbody></table>
498 </font>
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">&nbsp;</a>
504 </td>
505 </tr>
510 <tr>
511 <td>
512 <font face="Fixedsys">
514 </font>
515 </td>
516 <td>
517 <font face="Fixedsys">
518 <nobr>
519 REG, memory<br>
520 memory, REG<br>
521 REG, REG<br>
522 memory, immediate<br>
523 REG, immediate
524 </nobr>
525 </font>
526 </td>
527 <td>
529 Add.<br>
530 <br><br>Algorithm:<br><br>
531 <font face="Fixedsys">
532 operand1 = operand1 + operand2
533 </font>
534 <br><br>Example:<pre><font face="Fixedsys">MOV AL, 5 ; AL = 5
535 ADD AL, -3 ; AL = 2
536 RET</font></pre>
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>
542 </tbody></table>
543 </font>
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">&nbsp;</a>
549 </td>
550 </tr>
555 <tr>
556 <td>
557 <font face="Fixedsys">
559 </font>
560 </td>
561 <td>
562 <font face="Fixedsys">
563 <nobr>
564 REG, memory<br>
565 memory, REG<br>
566 REG, REG<br>
567 memory, immediate<br>
568 REG, immediate
569 </nobr>
570 </font>
571 </td>
572 <td>
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">
577 1 AND 1 = 1<br>
578 1 AND 0 = 0<br>
579 0 AND 1 = 0<br>
580 0 AND 0 = 0<br>
581 </font>
582 <br><br>Example:<pre><font face="Fixedsys">MOV AL, 'a' ; AL = 01100001b
583 AND AL, 11011111b ; AL = 01000001b ('A')
584 RET</font></pre>
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>
590 </tbody></table>
591 </font>
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">&nbsp;</a>
597 </td>
598 </tr>
603 <tr>
604 <td>
605 <font face="Fixedsys">
606 CALL
607 </font>
608 </td>
609 <td>
610 <font face="Fixedsys">
611 <nobr>
612 procedure name<br>
613 label<br>
614 4-byte address<br>
615 </nobr>
616 </font>
617 </td>
618 <td>
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.
627 CALL p1
629 ADD AX, 1
631 RET ; return to OS.
633 p1 PROC ; procedure declaration.
634 MOV AX, 1234h
635 RET ; return to caller.
636 p1 ENDP</font></pre>
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>
642 </tbody></table>
643 </font>
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">&nbsp;</a>
649 </td>
650 </tr>
655 <tr>
656 <td>
657 <font face="Fixedsys">
659 </font>
660 </td>
661 <td>No operands</td>
662 <td>
664 Convert byte into word. <br><br>Algorithm:
665 <br><br>
666 <font face="Fixedsys">
667 if high bit of AL = 1 then:
668 <ul>
669 <li>AH = 255 (0FFh)</li>
670 </ul>
671 <br>
672 else
673 <ul>
674 <li>AH = 0</li>
675 </ul>
676 </font>
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)
680 RET</font></pre>
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>
686 </tbody></table>
687 </font>
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">&nbsp;</a>
693 </td>
694 </tr>
699 <tr>
700 <td>
701 <font face="Fixedsys">
703 </font>
704 </td>
705 <td>No operands</td>
706 <td>
708 Clear Carry flag. <br><br>Algorithm:
709 <br><br>
710 <font face="Fixedsys">
711 CF = 0
712 </font>
714 <br><br>
716 <font face="Fixedsys">
717 <table noshade="" border="1">
718 <tbody><tr> <td>C</td> </tr>
719 <tr> <td>0</td> </tr>
720 </tbody></table>
721 </font>
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">&nbsp;</a>
727 </td>
728 </tr>
733 <tr>
734 <td>
735 <font face="Fixedsys">
737 </font>
738 </td>
739 <td>No operands</td>
740 <td>
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:
744 <br><br>
745 <font face="Fixedsys">
746 DF = 0
747 </font>
749 <br><br>
751 <font face="Fixedsys">
752 <table noshade="" border="1">
753 <tbody><tr> <td>D</td> </tr>
754 <tr> <td>0</td> </tr>
755 </tbody></table>
756 </font>
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">&nbsp;</a>
762 </td>
763 </tr>
768 <tr>
769 <td>
770 <font face="Fixedsys">
772 </font>
773 </td>
774 <td>No operands</td>
775 <td>
777 Clear Interrupt enable flag. This disables hardware interrupts. <br><br>Algorithm:
778 <br><br>
779 <font face="Fixedsys">
780 IF = 0
781 </font>
783 <br><br>
785 <font face="Fixedsys">
786 <table noshade="" border="1">
787 <tbody><tr> <td>I</td> </tr>
788 <tr> <td>0</td> </tr>
789 </tbody></table>
790 </font>
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">&nbsp;</a>
796 </td>
797 </tr>
802 <tr>
803 <td>
804 <font face="Fixedsys">
806 </font>
807 </td>
808 <td>No operands</td>
809 <td>
811 Complement Carry flag. Inverts value of CF. <br><br>Algorithm:
812 <br><br>
813 <font face="Fixedsys">
814 if CF = 1 then CF = 0<br>
815 if CF = 0 then CF = 1<br>
816 </font>
818 <br><br>
820 <font face="Fixedsys">
821 <table noshade="" border="1">
822 <tbody><tr> <td>C</td> </tr>
823 <tr> <td>r</td> </tr>
824 </tbody></table>
825 </font>
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">&nbsp;</a>
831 </td>
832 </tr>
837 <tr>
838 <td>
839 <font face="Fixedsys">
841 </font>
842 </td>
843 <td>
844 <font face="Fixedsys">
845 <nobr>
846 REG, memory<br>
847 memory, REG<br>
848 REG, REG<br>
849 memory, immediate<br>
850 REG, immediate
851 </nobr>
852 </font>
853 </td>
854 <td>
856 Compare.
857 <br><br>Algorithm:<br><br>
858 <font face="Fixedsys">
859 operand1 - operand2
860 <br><br>
861 result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according
862 to result.
863 </font>
864 <br><br>Example:<pre><font face="Fixedsys">MOV AL, 5
865 MOV BL, 5
866 CMP AL, BL ; AL = 5, ZF = 1 (so equal!)
867 RET</font></pre>
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>
873 </tbody></table>
874 </font>
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">&nbsp;</a>
880 </td>
881 </tr>
886 <tr>
887 <td>
888 <font face="Fixedsys">
889 CMPSB
890 </font>
891 </td>
892 <td>No operands</td>
893 <td>
895 Compare bytes: <nobr>ES:[DI] from DS:[SI].</nobr> <br><br>Algorithm:
896 <br><br>
897 <font face="Fixedsys">
898 </font><ul>
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>
901 <li>if DF = 0 then
902 <ul>
903 <li>SI = SI + 1</li>
904 <li>DI = DI + 1</li>
905 </ul>
906 else
907 <ul>
908 <li>SI = SI - 1</li>
909 <li>DI = DI - 1</li>
910 </ul>
911 </li>
912 </font></ul>
913 <font face="Fixedsys"></font>
914 Example:<br>
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\.
917 <br><br>
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>
923 </tbody></table>
924 </font>
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">&nbsp;</a>
930 </td>
931 </tr>
936 <tr>
937 <td>
938 <font face="Fixedsys">
939 CMPSW
940 </font>
941 </td>
942 <td>No operands</td>
943 <td>
945 Compare words: <nobr>ES:[DI] from DS:[SI].</nobr> <br><br>Algorithm:
946 <br><br>
947 <font face="Fixedsys">
948 <ul>
949 <li>DS:[SI] - ES:[DI]<br></li>
950 <li>set flags according to result:<br> OF, SF, ZF, AF, PF, CF<br></li>
951 <li>if DF = 0 then
952 <ul>
953 <li>SI = SI + 2</li>
954 <li>DI = DI + 2</li>
955 </ul>
956 else
957 <ul>
958 <li>SI = SI - 2</li>
959 <li>DI = DI - 2</li>
960 </ul>
961 </li>
962 </ul>
963 </font>
964 Example:<br>
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\.
967 <br><br>
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>
973 </tbody></table>
974 </font>
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">&nbsp;</a>
980 </td>
981 </tr>
986 <tr>
987 <td>
988 <font face="Fixedsys">
990 </font>
991 </td>
992 <td>No operands</td>
993 <td>
995 Convert Word to Double word. <br><br>Algorithm:
996 <br><br>
997 <font face="Fixedsys">
998 if high bit of AX = 1 then:
999 <ul>
1000 <li>DX = 65535 (0FFFFh)</li>
1001 </ul>
1002 <br>
1003 else
1004 <ul>
1005 <li>DX = 0</li>
1006 </ul>
1007 </font>
1008 <br>Example:<pre><font face="Fixedsys">MOV DX, 0 ; DX = 0
1009 MOV AX, 0 ; AX = 0
1010 MOV AX, -5 ; DX AX = 00000h:0FFFBh
1011 CWD ; DX AX = 0FFFFh:0FFFBh
1012 RET</font></pre>
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>
1018 </tbody></table>
1019 </font>
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">&nbsp;</a>
1025 </td>
1026 </tr>
1031 <tr>
1032 <td>
1033 <font face="Fixedsys">
1035 </font>
1036 </td>
1037 <td>No operands</td>
1038 <td>
1040 Decimal adjust After Addition.<br>
1041 Corrects the result of addition of two packed BCD values. <br><br>Algorithm:
1042 <br><br>
1043 <font face="Fixedsys">
1044 if low nibble of AL &gt; 9 or AF = 1 then:<br>
1045 </font><ul>
1046 <font face="Fixedsys"><li>AL = AL + 6</li>
1047 <li>AF = 1</li>
1048 </font></ul>
1049 <font face="Fixedsys">if AL &gt; 9Fh or CF = 1 then:
1050 </font><ul>
1051 <font face="Fixedsys"><li>AL = AL + 60h</li>
1052 <li>CF = 1</li>
1053 </font></ul>
1054 <font face="Fixedsys"></font>
1055 <br>Example:<pre><font face="Fixedsys">MOV AL, 0Fh ; AL = 0Fh (15)
1056 DAA ; AL = 15h
1057 RET</font></pre>
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>
1063 </tbody></table>
1064 </font>
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">&nbsp;</a>
1070 </td>
1071 </tr>
1076 <tr>
1077 <td>
1078 <font face="Fixedsys">
1080 </font>
1081 </td>
1082 <td>No operands</td>
1083 <td>
1085 Decimal adjust After Subtraction.<br>
1086 Corrects the result of subtraction of two packed BCD values. <br><br>Algorithm:
1087 <br><br>
1088 <font face="Fixedsys">
1089 if low nibble of AL &gt; 9 or AF = 1 then:<br>
1090 <ul>
1091 <li>AL = AL - 6</li>
1092 <li>AF = 1</li>
1093 </ul>
1094 if AL &gt; 9Fh or CF = 1 then:
1095 <ul>
1096 <li>AL = AL - 60h</li>
1097 <li>CF = 1</li>
1098 </ul>
1099 </font>
1100 <br>Example:<pre><font face="Fixedsys">MOV AL, 0FFh ; AL = 0FFh (-1)
1101 DAS ; AL = 99h, CF = 1
1102 RET</font></pre>
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>
1108 </tbody></table>
1109 </font>
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">&nbsp;</a>
1115 </td>
1116 </tr>
1121 <tr>
1122 <td>
1123 <font face="Fixedsys">
1125 </font>
1126 </td>
1127 <td>
1128 <font face="Fixedsys">
1129 <nobr>
1130 REG<br>
1131 memory<br>
1132 </nobr>
1133 </font>
1134 </td>
1135 <td>
1137 Decrement.
1138 <br><br>Algorithm:<br><br>
1139 <font face="Fixedsys">
1140 operand = operand - 1
1141 <br><br>
1142 </font>
1143 <br>Example:<pre><font face="Fixedsys">MOV AL, 255 ; AL = 0FFh (255 or -1)
1144 DEC AL ; AL = 0FEh (254 or -2)
1145 RET</font></pre>
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>
1151 </tbody></table>
1152 CF - unchanged!
1153 </font>
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">&nbsp;</a>
1159 </td>
1160 </tr>
1165 <tr>
1166 <td>
1167 <font face="Fixedsys">
1169 </font>
1170 </td>
1171 <td>
1172 <font face="Fixedsys">
1173 <nobr>
1174 REG<br>
1175 memory<br>
1176 </nobr>
1177 </font>
1178 </td>
1179 <td>
1181 Unsigned divide.
1182 <br><br>Algorithm:<br><br>
1183 <blockquote>
1184 when operand is a <b>byte</b>:<br>
1185 <font face="Fixedsys">AL = AX / operand<br>
1186 AH = remainder (modulus)
1187 </font>
1188 </blockquote>
1190 <blockquote>
1191 when operand is a <b>word</b>:<br>
1192 <font face="Fixedsys">AX = (DX AX) / operand<br>
1193 DX = remainder (modulus)
1194 </font>
1195 </blockquote>
1196 Example:<pre><font face="Fixedsys">MOV AX, 203 ; AX = 00CBh
1197 MOV BL, 4
1198 DIV BL ; AL = 50 (32h), AH = 3
1199 RET</font></pre>
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>
1205 </tbody></table>
1206 </font>
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">&nbsp;</a>
1212 </td>
1213 </tr>
1220 <tr>
1221 <td>
1222 <font face="Fixedsys">
1224 </font>
1225 </td>
1226 <td>No operands</td>
1227 <td>
1229 Halt the System.<br><br>
1231 Example:<pre><font face="Fixedsys">MOV AX, 5
1232 HLT</font></pre>
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>
1238 </tbody></table>
1239 </font>
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">&nbsp;</a>
1245 </td>
1246 </tr>
1252 <tr>
1253 <td>
1254 <font face="Fixedsys">
1255 IDIV
1256 </font>
1257 </td>
1258 <td>
1259 <font face="Fixedsys">
1260 <nobr>
1261 REG<br>
1262 memory<br>
1263 </nobr>
1264 </font>
1265 </td>
1266 <td>
1268 Signed divide.
1269 <br><br>Algorithm:<br><br>
1270 <blockquote>
1271 when operand is a <b>byte</b>:<br>
1272 <font face="Fixedsys">AL = AX / operand<br>
1273 AH = remainder (modulus)
1274 </font>
1275 </blockquote>
1277 <blockquote>
1278 when operand is a <b>word</b>:<br>
1279 <font face="Fixedsys">AX = (DX AX) / operand<br>
1280 DX = remainder (modulus)
1281 </font>
1282 </blockquote>
1283 Example:<pre><font face="Fixedsys">MOV AX, -203 ; AX = 0FF35h
1284 MOV BL, 4
1285 IDIV BL ; AL = -50 (0CEh), AH = -3 (0FDh)
1286 RET</font></pre>
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>
1292 </tbody></table>
1293 </font>
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">&nbsp;</a>
1299 </td>
1300 </tr>
1305 <tr>
1306 <td>
1307 <font face="Fixedsys">
1308 IMUL
1309 </font>
1310 </td>
1311 <td>
1312 <font face="Fixedsys">
1313 <nobr>
1314 REG<br>
1315 memory<br>
1316 </nobr>
1317 </font>
1318 </td>
1319 <td>
1321 Signed multiply.
1322 <br><br>Algorithm:<br><br>
1323 <blockquote>
1324 when operand is a <b>byte</b>:<br>
1325 <font face="Fixedsys">AX = AL * operand</font>.
1326 </blockquote>
1328 <blockquote>
1329 when operand is a <b>word</b>:<br>
1330 <font face="Fixedsys">(DX AX) = AX * operand</font>.
1331 </blockquote>
1332 Example:<pre><font face="Fixedsys">MOV AL, -2
1333 MOV BL, -4
1334 IMUL BL ; AX = 8
1335 RET</font></pre>
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>
1341 </tbody></table>
1342 CF=OF=0 when result fits into operand of IMUL.
1343 </font>
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">&nbsp;</a>
1349 </td>
1350 </tr>
1353 <tr>
1354 <td>
1355 <font face="Fixedsys">
1357 </font>
1358 </td>
1359 <td>
1360 <font face="Fixedsys">
1361 <nobr>
1362 AL, im.byte<br>
1363 AL, DX<br>
1364 AX, im.byte<br>
1365 AX, DX
1366 </nobr>
1367 </font>
1368 </td>
1369 <td>
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.
1376 </font></pre>
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>
1382 </tbody></table>
1383 </font>
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">&nbsp;</a>
1389 </td>
1390 </tr>
1393 <tr>
1394 <td>
1395 <font face="Fixedsys">
1397 </font>
1398 </td>
1399 <td>
1400 <font face="Fixedsys">
1401 <nobr>
1402 REG<br>
1403 memory<br>
1404 </nobr>
1405 </font>
1406 </td>
1407 <td>
1409 Increment.
1410 <br><br>Algorithm:<br><br>
1411 <font face="Fixedsys">
1412 operand = operand + 1
1413 <br>
1414 </font>
1415 <br>Example:<pre><font face="Fixedsys">MOV AL, 4
1416 INC AL ; AL = 5
1417 RET</font></pre>
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>
1423 </tbody></table>
1424 CF - unchanged!
1425 </font>
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">&nbsp;</a>
1431 </td>
1432 </tr>
1437 <tr>
1438 <td>
1439 <font face="Fixedsys">
1441 </font>
1442 </td>
1443 <td>
1444 <font face="Fixedsys">
1445 <nobr>immediate byte</nobr>
1446 </font>
1447 </td>
1448 <td>
1450 Interrupt numbered by immediate byte (0..255).
1451 <br><br>Algorithm:<br><br>
1452 <font face="Fixedsys">
1453 <ul>
1454 Push to stack:
1455 <ul>
1456 <li>flags register</li>
1457 <li>CS</li>
1458 <li>IP</li>
1459 </ul>
1461 <li>IF = 0</li>
1463 <li>Transfer control to interrupt procedure</li>
1464 </ul>
1465 </font>
1466 <br>Example:<pre><font face="Fixedsys">MOV AH, 0Eh ; teletype.
1467 MOV AL, 'A'
1468 INT 10h ; BIOS interrupt.
1469 RET</font></pre>
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>
1475 </tbody></table>
1476 </font>
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">&nbsp;</a>
1482 </td>
1483 </tr>
1487 <tr>
1488 <td>
1489 <font face="Fixedsys">
1490 INTO
1491 </font>
1492 </td>
1493 <td>No operands</td>
1494 <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
1500 <br>
1501 </font>
1502 <br>Example:<pre><font face="Fixedsys">; -5 - 127 = -132 (not in -128..127)
1503 ; the result of SUB is wrong (124),
1504 ; so OF = 1 is set:
1505 MOV AL, -5
1506 SUB AL, 127 ; AL = 7Ch (124)
1507 INTO ; process error.
1508 RET</font></pre>
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">&nbsp;</a>
1514 </td>
1515 </tr>
1520 <tr>
1521 <td>
1522 <font face="Fixedsys">
1523 IRET
1524 </font>
1525 </td>
1526 <td>No operands</td>
1527 <td>
1529 Interrupt Return.
1530 <br><br>Algorithm:<br><br>
1531 <font face="Fixedsys">
1532 <ul>
1533 Pop from stack:
1534 <ul>
1535 <li>IP</li>
1536 <li>CS</li>
1537 <li>flags register</li>
1538 </ul>
1539 </ul>
1540 </font>
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>
1546 </tbody></table>
1547 </font>
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">&nbsp;</a>
1553 </td>
1554 </tr>
1559 <tr>
1560 <td>
1561 <font face="Fixedsys">
1563 </font>
1564 </td>
1565 <td>
1566 <font face="Fixedsys">
1567 <nobr>label</nobr>
1568 </font>
1569 </td>
1570 <td>
1572 Short Jump if first operand is Above second operand (as set by CMP instruction).
1573 Unsigned.
1574 <br><br>Algorithm:<br><br>
1575 <font face="Fixedsys">
1576 <ul>
1577 if (CF = 0) and (ZF = 0) then jump
1578 </ul>
1579 </font>
1580 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1582 ORG 100h
1583 MOV AL, 250
1584 CMP AL, 5
1585 JA label1
1586 PRINT 'AL is not above 5'
1587 JMP exit
1588 label1:
1589 PRINT 'AL is above 5'
1590 exit:
1591 RET</font></pre>
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>
1597 </tbody></table>
1598 </font>
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">&nbsp;</a>
1604 </td>
1605 </tr>
1610 <tr>
1611 <td>
1612 <font face="Fixedsys">
1614 </font>
1615 </td>
1616 <td>
1617 <font face="Fixedsys">
1618 <nobr>label</nobr>
1619 </font>
1620 </td>
1621 <td>
1623 Short Jump if first operand is Above or Equal to second operand (as set by CMP instruction).
1624 Unsigned.
1625 <br><br>Algorithm:<br><br>
1626 <font face="Fixedsys">
1627 <ul>
1628 if CF = 0 then jump
1629 </ul>
1630 </font>
1631 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1633 ORG 100h
1634 MOV AL, 5
1635 CMP AL, 5
1636 JAE label1
1637 PRINT 'AL is not above or equal to 5'
1638 JMP exit
1639 label1:
1640 PRINT 'AL is above or equal to 5'
1641 exit:
1642 RET</font></pre>
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>
1648 </tbody></table>
1649 </font>
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">&nbsp;</a>
1655 </td>
1656 </tr>
1661 <tr>
1662 <td>
1663 <font face="Fixedsys">
1665 </font>
1666 </td>
1667 <td>
1668 <font face="Fixedsys">
1669 <nobr>label</nobr>
1670 </font>
1671 </td>
1672 <td>
1674 Short Jump if first operand is Below second operand (as set by CMP instruction).
1675 Unsigned.
1676 <br><br>Algorithm:<br><br>
1677 <font face="Fixedsys">
1678 <ul>
1679 if CF = 1 then jump
1680 </ul>
1681 </font>
1682 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1684 ORG 100h
1685 MOV AL, 1
1686 CMP AL, 5
1687 JB label1
1688 PRINT 'AL is not below 5'
1689 JMP exit
1690 label1:
1691 PRINT 'AL is below 5'
1692 exit:
1693 RET</font></pre>
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>
1699 </tbody></table>
1700 </font>
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">&nbsp;</a>
1706 </td>
1707 </tr>
1712 <tr>
1713 <td>
1714 <font face="Fixedsys">
1716 </font>
1717 </td>
1718 <td>
1719 <font face="Fixedsys">
1720 <nobr>label</nobr>
1721 </font>
1722 </td>
1723 <td>
1725 Short Jump if first operand is Below or Equal to second operand (as set by CMP instruction).
1726 Unsigned.
1727 <br><br>Algorithm:<br><br>
1728 <font face="Fixedsys">
1729 <ul>
1730 if CF = 1 or ZF = 1 then jump
1731 </ul>
1732 </font>
1733 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1735 ORG 100h
1736 MOV AL, 5
1737 CMP AL, 5
1738 JBE label1
1739 PRINT 'AL is not below or equal to 5'
1740 JMP exit
1741 label1:
1742 PRINT 'AL is below or equal to 5'
1743 exit:
1744 RET</font></pre>
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>
1750 </tbody></table>
1751 </font>
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">&nbsp;</a>
1757 </td>
1758 </tr>
1763 <tr>
1764 <td>
1765 <font face="Fixedsys">
1767 </font>
1768 </td>
1769 <td>
1770 <font face="Fixedsys">
1771 <nobr>label</nobr>
1772 </font>
1773 </td>
1774 <td>
1776 Short Jump if Carry flag is set to 1.
1777 <br><br>Algorithm:<br><br>
1778 <font face="Fixedsys">
1779 </font><ul>
1780 <font face="Fixedsys"> if CF = 1 then jump
1781 </font></ul>
1782 <font face="Fixedsys"></font>
1783 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1785 ORG 100h
1786 MOV AL, 255
1787 ADD AL, 1
1788 JC label1
1789 PRINT 'no carry.'
1790 JMP exit
1791 label1:
1792 PRINT 'has carry.'
1793 exit:
1794 RET</font></pre>
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>
1800 </tbody></table>
1801 </font>
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">&nbsp;</a>
1807 </td>
1808 </tr>
1813 <tr>
1814 <td>
1815 <font face="Fixedsys">
1816 JCXZ
1817 </font>
1818 </td>
1819 <td>
1820 <font face="Fixedsys">
1821 <nobr>label</nobr>
1822 </font>
1823 </td>
1824 <td>
1826 Short Jump if CX register is 0.
1827 <br><br>Algorithm:<br><br>
1828 <font face="Fixedsys">
1829 <ul>
1830 if CX = 0 then jump
1831 </ul>
1832 </font>
1833 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1835 ORG 100h
1836 MOV CX, 0
1837 JCXZ label1
1838 PRINT 'CX is not zero.'
1839 JMP exit
1840 label1:
1841 PRINT 'CX is zero.'
1842 exit:
1843 RET</font></pre>
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>
1849 </tbody></table>
1850 </font>
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">&nbsp;</a>
1856 </td>
1857 </tr>
1862 <tr>
1863 <td>
1864 <font face="Fixedsys">
1866 </font>
1867 </td>
1868 <td>
1869 <font face="Fixedsys">
1870 <nobr>label</nobr>
1871 </font>
1872 </td>
1873 <td>
1875 Short Jump if first operand is Equal to second operand (as set by CMP instruction).
1876 Signed/Unsigned.
1877 <br><br>Algorithm:<br><br>
1878 <font face="Fixedsys">
1879 <ul>
1880 if ZF = 1 then jump
1881 </ul>
1882 </font>
1883 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1885 ORG 100h
1886 MOV AL, 5
1887 CMP AL, 5
1888 JE label1
1889 PRINT 'AL is not equal to 5.'
1890 JMP exit
1891 label1:
1892 PRINT 'AL is equal to 5.'
1893 exit:
1894 RET</font></pre>
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>
1900 </tbody></table>
1901 </font>
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">&nbsp;</a>
1907 </td>
1908 </tr>
1913 <tr>
1914 <td>
1915 <font face="Fixedsys">
1917 </font>
1918 </td>
1919 <td>
1920 <font face="Fixedsys">
1921 <nobr>label</nobr>
1922 </font>
1923 </td>
1924 <td>
1926 Short Jump if first operand is Greater then second operand (as set by CMP instruction).
1927 Signed.
1928 <br><br>Algorithm:<br><br>
1929 <font face="Fixedsys">
1930 <ul>
1931 if (ZF = 0) and (SF = OF) then jump
1932 </ul>
1933 </font>
1934 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1936 ORG 100h
1937 MOV AL, 5
1938 CMP AL, -5
1939 JG label1
1940 PRINT 'AL is not greater -5.'
1941 JMP exit
1942 label1:
1943 PRINT 'AL is greater -5.'
1944 exit:
1945 RET</font></pre>
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>
1951 </tbody></table>
1952 </font>
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">&nbsp;</a>
1958 </td>
1959 </tr>
1964 <tr>
1965 <td>
1966 <font face="Fixedsys">
1968 </font>
1969 </td>
1970 <td>
1971 <font face="Fixedsys">
1972 <nobr>label</nobr>
1973 </font>
1974 </td>
1975 <td>
1977 Short Jump if first operand is Greater or Equal to second operand (as set by CMP instruction).
1978 Signed.
1979 <br><br>Algorithm:<br><br>
1980 <font face="Fixedsys">
1981 <ul>
1982 if SF = OF then jump
1983 </ul>
1984 </font>
1985 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
1987 ORG 100h
1988 MOV AL, 2
1989 CMP AL, -5
1990 JGE label1
1991 PRINT 'AL &lt; -5'
1992 JMP exit
1993 label1:
1994 PRINT 'AL &gt;= -5'
1995 exit:
1996 RET</font></pre>
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>
2002 </tbody></table>
2003 </font>
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">&nbsp;</a>
2009 </td>
2010 </tr>
2015 <tr>
2016 <td>
2017 <font face="Fixedsys">
2019 </font>
2020 </td>
2021 <td>
2022 <font face="Fixedsys">
2023 <nobr>label</nobr>
2024 </font>
2025 </td>
2026 <td>
2028 Short Jump if first operand is Less then second operand (as set by CMP instruction).
2029 Signed.
2030 <br><br>Algorithm:<br><br>
2031 <font face="Fixedsys">
2032 <ul>
2033 if SF &lt;&gt; OF then jump
2034 </ul>
2035 </font>
2036 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2038 ORG 100h
2039 MOV AL, -2
2040 CMP AL, 5
2041 JL label1
2042 PRINT 'AL &gt;= 5.'
2043 JMP exit
2044 label1:
2045 PRINT 'AL &lt; 5.'
2046 exit:
2047 RET</font></pre>
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>
2053 </tbody></table>
2054 </font>
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">&nbsp;</a>
2060 </td>
2061 </tr>
2066 <tr>
2067 <td>
2068 <font face="Fixedsys">
2070 </font>
2071 </td>
2072 <td>
2073 <font face="Fixedsys">
2074 <nobr>label</nobr>
2075 </font>
2076 </td>
2077 <td>
2079 Short Jump if first operand is Less or Equal to second operand (as set by CMP instruction).
2080 Signed.
2081 <br><br>Algorithm:<br><br>
2082 <font face="Fixedsys">
2083 <ul>
2084 if SF &lt;&gt; OF or ZF = 1 then jump
2085 </ul>
2086 </font>
2087 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2089 ORG 100h
2090 MOV AL, -2
2091 CMP AL, 5
2092 JLE label1
2093 PRINT 'AL &gt; 5.'
2094 JMP exit
2095 label1:
2096 PRINT 'AL &lt;= 5.'
2097 exit:
2098 RET</font></pre>
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>
2104 </tbody></table>
2105 </font>
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">&nbsp;</a>
2111 </td>
2112 </tr>
2117 <tr>
2118 <td>
2119 <font face="Fixedsys">
2121 </font>
2122 </td>
2123 <td>
2124 <font face="Fixedsys">
2125 <nobr>
2126 label<br>
2127 4-byte address<br>
2128 </nobr>
2129 </font>
2130 </td>
2131 <td>
2133 Unconditional Jump.
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">
2141 <ul>
2142 always jump
2143 </ul>
2144 </font>
2145 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2147 ORG 100h
2148 MOV AL, 5
2149 JMP label1 ; jump over 2 lines!
2150 PRINT 'Not Jumped!'
2151 MOV AL, 0
2152 label1:
2153 PRINT 'Got Here!'
2154 RET</font></pre>
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>
2160 </tbody></table>
2161 </font>
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">&nbsp;</a>
2167 </td>
2168 </tr>
2173 <tr>
2174 <td>
2175 <font face="Fixedsys">
2177 </font>
2178 </td>
2179 <td>
2180 <font face="Fixedsys">
2181 <nobr>label</nobr>
2182 </font>
2183 </td>
2184 <td>
2186 Short Jump if first operand is Not Above second operand (as set by CMP instruction).
2187 Unsigned.
2188 <br><br>Algorithm:<br><br>
2189 <font face="Fixedsys">
2190 <ul>
2191 if CF = 1 or ZF = 1 then jump
2192 </ul>
2193 </font>
2194 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2196 ORG 100h
2197 MOV AL, 2
2198 CMP AL, 5
2199 JNA label1
2200 PRINT 'AL is above 5.'
2201 JMP exit
2202 label1:
2203 PRINT 'AL is not above 5.'
2204 exit:
2205 RET</font></pre>
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>
2211 </tbody></table>
2212 </font>
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">&nbsp;</a>
2218 </td>
2219 </tr>
2224 <tr>
2225 <td>
2226 <font face="Fixedsys">
2227 JNAE
2228 </font>
2229 </td>
2230 <td>
2231 <font face="Fixedsys">
2232 <nobr>label</nobr>
2233 </font>
2234 </td>
2235 <td>
2237 Short Jump if first operand is Not Above and Not Equal to second operand (as set by CMP instruction).
2238 Unsigned.
2239 <br><br>Algorithm:<br><br>
2240 <font face="Fixedsys">
2241 <ul>
2242 if CF = 1 then jump
2243 </ul>
2244 </font>
2245 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2247 ORG 100h
2248 MOV AL, 2
2249 CMP AL, 5
2250 JNAE label1
2251 PRINT 'AL &gt;= 5.'
2252 JMP exit
2253 label1:
2254 PRINT 'AL &lt; 5.'
2255 exit:
2256 RET</font></pre>
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>
2262 </tbody></table>
2263 </font>
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">&nbsp;</a>
2269 </td>
2270 </tr>
2275 <tr>
2276 <td>
2277 <font face="Fixedsys">
2279 </font>
2280 </td>
2281 <td>
2282 <font face="Fixedsys">
2283 <nobr>label</nobr>
2284 </font>
2285 </td>
2286 <td>
2288 Short Jump if first operand is Not Below second operand (as set by CMP instruction).
2289 Unsigned.
2290 <br><br>Algorithm:<br><br>
2291 <font face="Fixedsys">
2292 <ul>
2293 if CF = 0 then jump
2294 </ul>
2295 </font>
2296 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2298 ORG 100h
2299 MOV AL, 7
2300 CMP AL, 5
2301 JNB label1
2302 PRINT 'AL &lt; 5.'
2303 JMP exit
2304 label1:
2305 PRINT 'AL &gt;= 5.'
2306 exit:
2307 RET</font></pre>
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>
2313 </tbody></table>
2314 </font>
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">&nbsp;</a>
2320 </td>
2321 </tr>
2326 <tr>
2327 <td>
2328 <font face="Fixedsys">
2329 JNBE
2330 </font>
2331 </td>
2332 <td>
2333 <font face="Fixedsys">
2334 <nobr>label</nobr>
2335 </font>
2336 </td>
2337 <td>
2339 Short Jump if first operand is Not Below and Not Equal to second operand (as set by CMP instruction).
2340 Unsigned.
2341 <br><br>Algorithm:<br><br>
2342 <font face="Fixedsys">
2343 <ul>
2344 if (CF = 0) and (ZF = 0) then jump
2345 </ul>
2346 </font>
2347 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2349 ORG 100h
2350 MOV AL, 7
2351 CMP AL, 5
2352 JNBE label1
2353 PRINT 'AL &lt;= 5.'
2354 JMP exit
2355 label1:
2356 PRINT 'AL &gt; 5.'
2357 exit:
2358 RET</font></pre>
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>
2364 </tbody></table>
2365 </font>
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">&nbsp;</a>
2371 </td>
2372 </tr>
2377 <tr>
2378 <td>
2379 <font face="Fixedsys">
2381 </font>
2382 </td>
2383 <td>
2384 <font face="Fixedsys">
2385 <nobr>label</nobr>
2386 </font>
2387 </td>
2388 <td>
2390 Short Jump if Carry flag is set to 0.
2391 <br><br>Algorithm:<br><br>
2392 <font face="Fixedsys">
2393 <ul>
2394 if CF = 0 then jump
2395 </ul>
2396 </font>
2397 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2399 ORG 100h
2400 MOV AL, 2
2401 ADD AL, 3
2402 JNC label1
2403 PRINT 'has carry.'
2404 JMP exit
2405 label1:
2406 PRINT 'no carry.'
2407 exit:
2408 RET</font></pre>
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>
2414 </tbody></table>
2415 </font>
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">&nbsp;</a>
2421 </td>
2422 </tr>
2427 <tr>
2428 <td>
2429 <font face="Fixedsys">
2431 </font>
2432 </td>
2433 <td>
2434 <font face="Fixedsys">
2435 <nobr>label</nobr>
2436 </font>
2437 </td>
2438 <td>
2440 Short Jump if first operand is Not Equal to second operand (as set by CMP instruction).
2441 Signed/Unsigned.
2442 <br><br>Algorithm:<br><br>
2443 <font face="Fixedsys">
2444 <ul>
2445 if ZF = 0 then jump
2446 </ul>
2447 </font>
2448 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2450 ORG 100h
2451 MOV AL, 2
2452 CMP AL, 3
2453 JNE label1
2454 PRINT 'AL = 3.'
2455 JMP exit
2456 label1:
2457 PRINT 'Al &lt;&gt; 3.'
2458 exit:
2459 RET</font></pre>
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>
2465 </tbody></table>
2466 </font>
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">&nbsp;</a>
2472 </td>
2473 </tr>
2478 <tr>
2479 <td>
2480 <font face="Fixedsys">
2482 </font>
2483 </td>
2484 <td>
2485 <font face="Fixedsys">
2486 <nobr>label</nobr>
2487 </font>
2488 </td>
2489 <td>
2491 Short Jump if first operand is Not Greater then second operand (as set by CMP instruction).
2492 Signed.
2493 <br><br>Algorithm:<br><br>
2494 <font face="Fixedsys">
2495 <ul>
2496 if (ZF = 1) and (SF &lt;&gt; OF) then jump
2497 </ul>
2498 </font>
2499 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2501 ORG 100h
2502 MOV AL, 2
2503 CMP AL, 3
2504 JNG label1
2505 PRINT 'AL &gt; 3.'
2506 JMP exit
2507 label1:
2508 PRINT 'Al &lt;= 3.'
2509 exit:
2510 RET</font></pre>
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>
2516 </tbody></table>
2517 </font>
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">&nbsp;</a>
2523 </td>
2524 </tr>
2529 <tr>
2530 <td>
2531 <font face="Fixedsys">
2532 JNGE
2533 </font>
2534 </td>
2535 <td>
2536 <font face="Fixedsys">
2537 <nobr>label</nobr>
2538 </font>
2539 </td>
2540 <td>
2542 Short Jump if first operand is Not Greater and Not Equal to second operand (as set by CMP instruction).
2543 Signed.
2544 <br><br>Algorithm:<br><br>
2545 <font face="Fixedsys">
2546 <ul>
2547 if SF &lt;&gt; OF then jump
2548 </ul>
2549 </font>
2550 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2552 ORG 100h
2553 MOV AL, 2
2554 CMP AL, 3
2555 JNGE label1
2556 PRINT 'AL &gt;= 3.'
2557 JMP exit
2558 label1:
2559 PRINT 'Al &lt; 3.'
2560 exit:
2561 RET</font></pre>
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>
2567 </tbody></table>
2568 </font>
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">&nbsp;</a>
2574 </td>
2575 </tr>
2580 <tr>
2581 <td>
2582 <font face="Fixedsys">
2584 </font>
2585 </td>
2586 <td>
2587 <font face="Fixedsys">
2588 <nobr>label</nobr>
2589 </font>
2590 </td>
2591 <td>
2593 Short Jump if first operand is Not Less then second operand (as set by CMP instruction).
2594 Signed.
2595 <br><br>Algorithm:<br><br>
2596 <font face="Fixedsys">
2597 <ul>
2598 if SF = OF then jump
2599 </ul>
2600 </font>
2601 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2603 ORG 100h
2604 MOV AL, 2
2605 CMP AL, -3
2606 JNL label1
2607 PRINT 'AL &lt; -3.'
2608 JMP exit
2609 label1:
2610 PRINT 'Al &gt;= -3.'
2611 exit:
2612 RET</font></pre>
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>
2618 </tbody></table>
2619 </font>
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">&nbsp;</a>
2625 </td>
2626 </tr>
2631 <tr>
2632 <td>
2633 <font face="Fixedsys">
2634 JNLE
2635 </font>
2636 </td>
2637 <td>
2638 <font face="Fixedsys">
2639 <nobr>label</nobr>
2640 </font>
2641 </td>
2642 <td>
2644 Short Jump if first operand is Not Less and Not Equal to second operand (as set by CMP instruction).
2645 Signed.
2646 <br><br>Algorithm:<br><br>
2647 <font face="Fixedsys">
2648 <ul>
2649 if (SF = OF) and (ZF = 0) then jump
2650 </ul>
2651 </font>
2652 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2654 ORG 100h
2655 MOV AL, 2
2656 CMP AL, -3
2657 JNLE label1
2658 PRINT 'AL &lt;= -3.'
2659 JMP exit
2660 label1:
2661 PRINT 'Al &gt; -3.'
2662 exit:
2663 RET</font></pre>
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>
2669 </tbody></table>
2670 </font>
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">&nbsp;</a>
2676 </td>
2677 </tr>
2682 <tr>
2683 <td>
2684 <font face="Fixedsys">
2686 </font>
2687 </td>
2688 <td>
2689 <font face="Fixedsys">
2690 <nobr>label</nobr>
2691 </font>
2692 </td>
2693 <td>
2695 Short Jump if Not Overflow.
2696 <br><br>Algorithm:<br><br>
2697 <font face="Fixedsys">
2698 <ul>
2699 if OF = 0 then jump
2700 </ul>
2701 </font>
2702 Example:<pre><font face="Fixedsys">; -5 - 2 = -7 (inside -128..127)
2703 ; the result of SUB is correct,
2704 ; so OF = 0:
2706 include 'emu8086.inc'
2708 ORG 100h
2709 MOV AL, -5
2710 SUB AL, 2 ; AL = 0F9h (-7)
2711 JNO label1
2712 PRINT 'overflow!'
2713 JMP exit
2714 label1:
2715 PRINT 'no overflow.'
2716 exit:
2717 RET</font></pre>
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>
2723 </tbody></table>
2724 </font>
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">&nbsp;</a>
2730 </td>
2731 </tr>
2736 <tr>
2737 <td>
2738 <font face="Fixedsys">
2740 </font>
2741 </td>
2742 <td>
2743 <font face="Fixedsys">
2744 <nobr>label</nobr>
2745 </font>
2746 </td>
2747 <td>
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">
2753 <ul>
2754 if PF = 0 then jump
2755 </ul>
2756 </font>
2757 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2759 ORG 100h
2760 MOV AL, 00000111b ; AL = 7
2761 OR AL, 0 ; just set flags.
2762 JNP label1
2763 PRINT 'parity even.'
2764 JMP exit
2765 label1:
2766 PRINT 'parity odd.'
2767 exit:
2768 RET</font></pre>
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>
2774 </tbody></table>
2775 </font>
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">&nbsp;</a>
2781 </td>
2782 </tr>
2787 <tr>
2788 <td>
2789 <font face="Fixedsys">
2791 </font>
2792 </td>
2793 <td>
2794 <font face="Fixedsys">
2795 <nobr>label</nobr>
2796 </font>
2797 </td>
2798 <td>
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">
2804 <ul>
2805 if SF = 0 then jump
2806 </ul>
2807 </font>
2808 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2810 ORG 100h
2811 MOV AL, 00000111b ; AL = 7
2812 OR AL, 0 ; just set flags.
2813 JNS label1
2814 PRINT 'signed.'
2815 JMP exit
2816 label1:
2817 PRINT 'not signed.'
2818 exit:
2819 RET</font></pre>
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>
2825 </tbody></table>
2826 </font>
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">&nbsp;</a>
2832 </td>
2833 </tr>
2838 <tr>
2839 <td>
2840 <font face="Fixedsys">
2842 </font>
2843 </td>
2844 <td>
2845 <font face="Fixedsys">
2846 <nobr>label</nobr>
2847 </font>
2848 </td>
2849 <td>
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">
2855 <ul>
2856 if ZF = 0 then jump
2857 </ul>
2858 </font>
2859 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2861 ORG 100h
2862 MOV AL, 00000111b ; AL = 7
2863 OR AL, 0 ; just set flags.
2864 JNZ label1
2865 PRINT 'zero.'
2866 JMP exit
2867 label1:
2868 PRINT 'not zero.'
2869 exit:
2870 RET</font></pre>
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>
2876 </tbody></table>
2877 </font>
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">&nbsp;</a>
2883 </td>
2884 </tr>
2889 <tr>
2890 <td>
2891 <font face="Fixedsys">
2893 </font>
2894 </td>
2895 <td>
2896 <font face="Fixedsys">
2897 <nobr>label</nobr>
2898 </font>
2899 </td>
2900 <td>
2902 Short Jump if Overflow.
2903 <br><br>Algorithm:<br><br>
2904 <font face="Fixedsys">
2905 <ul>
2906 if OF = 1 then jump
2907 </ul>
2908 </font>
2909 Example:<pre><font face="Fixedsys">; -5 - 127 = -132 (not in -128..127)
2910 ; the result of SUB is wrong (124),
2911 ; so OF = 1 is set:
2913 include 'emu8086.inc'
2915 org 100h
2916 MOV AL, -5
2917 SUB AL, 127 ; AL = 7Ch (124)
2918 JO label1
2919 PRINT 'no overflow.'
2920 JMP exit
2921 label1:
2922 PRINT 'overflow!'
2923 exit:
2924 RET</font></pre>
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>
2930 </tbody></table>
2931 </font>
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">&nbsp;</a>
2937 </td>
2938 </tr>
2943 <tr>
2944 <td>
2945 <font face="Fixedsys">
2947 </font>
2948 </td>
2949 <td>
2950 <font face="Fixedsys">
2951 <nobr>label</nobr>
2952 </font>
2953 </td>
2954 <td>
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">
2960 <ul>
2961 if PF = 1 then jump
2962 </ul>
2963 </font>
2964 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
2966 ORG 100h
2967 MOV AL, 00000101b ; AL = 5
2968 OR AL, 0 ; just set flags.
2969 JP label1
2970 PRINT 'parity odd.'
2971 JMP exit
2972 label1:
2973 PRINT 'parity even.'
2974 exit:
2975 RET</font></pre>
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>
2981 </tbody></table>
2982 </font>
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">&nbsp;</a>
2988 </td>
2989 </tr>
2994 <tr>
2995 <td>
2996 <font face="Fixedsys">
2998 </font>
2999 </td>
3000 <td>
3001 <font face="Fixedsys">
3002 <nobr>label</nobr>
3003 </font>
3004 </td>
3005 <td>
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">
3011 <ul>
3012 if PF = 1 then jump
3013 </ul>
3014 </font>
3015 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
3017 ORG 100h
3018 MOV AL, 00000101b ; AL = 5
3019 OR AL, 0 ; just set flags.
3020 JPE label1
3021 PRINT 'parity odd.'
3022 JMP exit
3023 label1:
3024 PRINT 'parity even.'
3025 exit:
3026 RET</font></pre>
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>
3032 </tbody></table>
3033 </font>
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">&nbsp;</a>
3039 </td>
3040 </tr>
3045 <tr>
3046 <td>
3047 <font face="Fixedsys">
3049 </font>
3050 </td>
3051 <td>
3052 <font face="Fixedsys">
3053 <nobr>label</nobr>
3054 </font>
3055 </td>
3056 <td>
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">
3062 <ul>
3063 if PF = 0 then jump
3064 </ul>
3065 </font>
3066 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
3068 ORG 100h
3069 MOV AL, 00000111b ; AL = 7
3070 OR AL, 0 ; just set flags.
3071 JPO label1
3072 PRINT 'parity even.'
3073 JMP exit
3074 label1:
3075 PRINT 'parity odd.'
3076 exit:
3077 RET</font></pre>
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>
3083 </tbody></table>
3084 </font>
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">&nbsp;</a>
3090 </td>
3091 </tr>
3096 <tr>
3097 <td>
3098 <font face="Fixedsys">
3100 </font>
3101 </td>
3102 <td>
3103 <font face="Fixedsys">
3104 <nobr>label</nobr>
3105 </font>
3106 </td>
3107 <td>
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">
3113 <ul>
3114 if SF = 1 then jump
3115 </ul>
3116 </font>
3117 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
3119 ORG 100h
3120 MOV AL, 10000000b ; AL = -128
3121 OR AL, 0 ; just set flags.
3122 JS label1
3123 PRINT 'not signed.'
3124 JMP exit
3125 label1:
3126 PRINT 'signed.'
3127 exit:
3128 RET</font></pre>
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>
3134 </tbody></table>
3135 </font>
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">&nbsp;</a>
3141 </td>
3142 </tr>
3147 <tr>
3148 <td>
3149 <font face="Fixedsys">
3151 </font>
3152 </td>
3153 <td>
3154 <font face="Fixedsys">
3155 <nobr>label</nobr>
3156 </font>
3157 </td>
3158 <td>
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">
3164 <ul>
3165 if ZF = 1 then jump
3166 </ul>
3167 </font>
3168 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
3170 ORG 100h
3171 MOV AL, 5
3172 CMP AL, 5
3173 JZ label1
3174 PRINT 'AL is not equal to 5.'
3175 JMP exit
3176 label1:
3177 PRINT 'AL is equal to 5.'
3178 exit:
3179 RET</font></pre>
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>
3185 </tbody></table>
3186 </font>
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">&nbsp;</a>
3192 </td>
3193 </tr>
3198 <tr>
3199 <td>
3200 <font face="Fixedsys">
3201 LAHF
3202 </font>
3203 </td>
3204 <td>No operands</td>
3205 <td>
3207 Load AH from 8 low bits of Flags register.
3208 <br><br>Algorithm:<br><br>
3209 <font face="Fixedsys">
3210 </font><ul>
3211 <font face="Fixedsys"> AH = flags register<br>
3212 </font></ul>
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>
3216 </font></pre>
3217 <font face="Fixedsys">bits 1, 3, 5 are reserved.
3218 </font>
3220 <br><br>
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>
3226 </tbody></table>
3227 </font>
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">&nbsp;</a>
3233 </td>
3234 </tr>
3239 <tr>
3240 <td>
3241 <font face="Fixedsys">
3243 </font>
3244 </td>
3245 <td>
3246 <font face="Fixedsys">
3247 <nobr>
3248 REG, memory
3249 </nobr>
3250 </font>
3251 </td>
3252 <td>
3254 Load memory double word into word register and DS.
3255 <br><br>Algorithm:<br><br>
3256 <font face="Fixedsys">
3257 <ul>
3258 <li>REG = first word</li>
3259 <li>DS = second word</li>
3260 </ul>
3261 </font>
3262 <br>
3263 Example:
3264 <pre><font face="Fixedsys">
3266 ORG 100h
3268 LDS AX, m
3272 m DW 1234h
3273 DW 5678h
3276 </font>
3277 </pre>
3278 AX is set to 1234h, DS is set to 5678h.
3279 <br><br>
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>
3285 </tbody></table>
3286 </font>
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">&nbsp;</a>
3292 </td>
3293 </tr>
3309 <tr>
3310 <td>
3311 <font face="Fixedsys">
3313 </font>
3314 </td>
3315 <td>
3316 <font face="Fixedsys">
3317 <nobr>
3318 REG, memory
3319 </nobr>
3320 </font>
3321 </td>
3322 <td>
3324 Load Effective Address.
3325 <br><br>Algorithm:<br><br>
3326 <font face="Fixedsys">
3327 <ul>
3328 <li>REG = address of memory (offset)</li>
3329 </ul>
3330 </font>
3331 <br>
3332 Example:
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>
3338 </font></pre>
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.
3344 For example:
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>
3352 </font></pre>
3353 <!-- emu8086 version 4.00-Beta-19 -->
3354 <!-- STOP AUTOMATIC ASM TO HTML EXPORT -->
3355 <br><br>
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>
3361 </tbody></table>
3362 </font>
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">&nbsp;</a>
3368 </td>
3369 </tr>
3388 <tr>
3389 <td>
3390 <font face="Fixedsys">
3392 </font>
3393 </td>
3394 <td>
3395 <font face="Fixedsys">
3396 <nobr>
3397 REG, memory
3398 </nobr>
3399 </font>
3400 </td>
3401 <td>
3403 Load memory double word into word register and ES.
3404 <br><br>Algorithm:<br><br>
3405 <font face="Fixedsys">
3406 <ul>
3407 <li>REG = first word</li>
3408 <li>ES = second word</li>
3409 </ul>
3410 </font>
3411 <br>
3412 Example:
3413 <pre><font face="Fixedsys">
3415 ORG 100h
3417 LES AX, m
3421 m DW 1234h
3422 DW 5678h
3425 </font>
3426 </pre>
3427 AX is set to 1234h, ES is set to 5678h.
3429 <br><br>
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>
3435 </tbody></table>
3436 </font>
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">&nbsp;</a>
3443 </td>
3444 </tr>
3449 <tr>
3450 <td>
3451 <font face="Fixedsys">
3452 LODSB
3453 </font>
3454 </td>
3455 <td>No operands</td>
3456 <td>
3458 Load byte at DS:[SI] into AL. Update SI.<br><br>Algorithm:
3459 <br><br>
3460 <font face="Fixedsys">
3461 <ul>
3462 <li>AL = DS:[SI]<br></li>
3463 <li>if DF = 0 then
3464 <ul>
3465 <li>SI = SI + 1</li>
3466 </ul>
3467 else
3468 <ul>
3469 <li>SI = SI - 1</li>
3470 </ul>
3471 </li>
3472 </ul>
3473 </font>
3474 Example:
3475 <pre><font face="Fixedsys">
3476 ORG 100h
3478 LEA SI, a1
3479 MOV CX, 5
3480 MOV AH, 0Eh
3482 m: LODSB
3483 INT 10h
3484 LOOP m
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>
3494 </tbody></table>
3495 </font>
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">&nbsp;</a>
3501 </td>
3502 </tr>
3507 <tr>
3508 <td>
3509 <font face="Fixedsys">
3510 LODSW
3511 </font>
3512 </td>
3513 <td>No operands</td>
3514 <td>
3516 Load word at DS:[SI] into AX. Update SI.<br><br>Algorithm:
3517 <br><br>
3518 <font face="Fixedsys">
3519 <ul>
3520 <li>AX = DS:[SI]<br></li>
3521 <li>if DF = 0 then
3522 <ul>
3523 <li>SI = SI + 2</li>
3524 </ul>
3525 else
3526 <ul>
3527 <li>SI = SI - 2</li>
3528 </ul>
3529 </li>
3530 </ul>
3531 </font>
3532 Example:
3533 <pre><font face="Fixedsys">
3534 ORG 100h
3536 LEA SI, a1
3537 MOV CX, 5
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>
3549 </tbody></table>
3550 </font>
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">&nbsp;</a>
3556 </td>
3557 </tr>
3562 <tr>
3563 <td>
3564 <font face="Fixedsys">
3565 LOOP
3566 </font>
3567 </td>
3568 <td>
3569 <font face="Fixedsys">
3570 <nobr>label</nobr>
3571 </font>
3572 </td>
3573 <td>
3575 Decrease CX, jump to label if CX not zero. <br><br>Algorithm:
3576 <br><br>
3577 <font face="Fixedsys">
3578 <ul>
3579 <li>CX = CX - 1<br></li>
3580 <li>if CX &lt;&gt; 0 then
3581 <ul>
3582 <li>jump</li>
3583 </ul>
3584 else
3585 <ul>
3586 <li>no jump, continue</li>
3587 </ul>
3588 </li>
3589 </ul>
3590 </font>
3591 Example:<pre><font face="Fixedsys"> include 'emu8086.inc'
3593 ORG 100h
3594 MOV CX, 5
3595 label1:
3596 PRINTN 'loop!'
3597 LOOP label1
3598 RET</font></pre>
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>
3604 </tbody></table>
3605 </font>
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">&nbsp;</a>
3611 </td>
3612 </tr>
3617 <tr>
3618 <td>
3619 <font face="Fixedsys">
3620 LOOPE
3621 </font>
3622 </td>
3623 <td>
3624 <font face="Fixedsys">
3625 <nobr>label</nobr>
3626 </font>
3627 </td>
3628 <td>
3630 Decrease CX, jump to label if CX not zero and Equal (ZF = 1). <br><br>Algorithm:
3631 <br><br>
3632 <font face="Fixedsys">
3633 <ul>
3634 <li>CX = CX - 1<br></li>
3635 <li>if (CX &lt;&gt; 0) and (ZF = 1) then
3636 <ul>
3637 <li>jump</li>
3638 </ul>
3639 else
3640 <ul>
3641 <li>no jump, continue</li>
3642 </ul>
3643 </li>
3644 </ul>
3645 </font>
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'
3653 ORG 100h
3654 MOV AX, 0
3655 MOV CX, 5
3656 label1:
3657 PUTC '*'
3658 ADD AX, 100
3659 CMP AH, 0
3660 LOOPE label1
3661 RET</font></pre>
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>
3667 </tbody></table>
3668 </font>
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">&nbsp;</a>
3674 </td>
3675 </tr>
3680 <tr>
3681 <td>
3682 <font face="Fixedsys">
3683 LOOPNE
3684 </font>
3685 </td>
3686 <td>
3687 <font face="Fixedsys">
3688 <nobr>label</nobr>
3689 </font>
3690 </td>
3691 <td>
3693 Decrease CX, jump to label if CX not zero and Not Equal (ZF = 0). <br><br>Algorithm:
3694 <br><br>
3695 <font face="Fixedsys">
3696 <ul>
3697 <li>CX = CX - 1<br></li>
3698 <li>if (CX &lt;&gt; 0) and (ZF = 0) then
3699 <ul>
3700 <li>jump</li>
3701 </ul>
3702 else
3703 <ul>
3704 <li>no jump, continue</li>
3705 </ul>
3706 </li>
3707 </ul>
3708 </font>
3709 Example:<pre><font face="Fixedsys">; Loop until '7' is found,
3710 ; or 5 times.
3712 include 'emu8086.inc'
3714 ORG 100h
3715 MOV SI, 0
3716 MOV CX, 5
3717 label1:
3718 PUTC '*'
3719 MOV AL, v1[SI]
3720 INC SI ; next byte (SI=SI+1).
3721 CMP AL, 7
3722 LOOPNE label1
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>
3730 </tbody></table>
3731 </font>
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">&nbsp;</a>
3737 </td>
3738 </tr>
3743 <tr>
3744 <td>
3745 <font face="Fixedsys">
3746 LOOPNZ
3747 </font>
3748 </td>
3749 <td>
3750 <font face="Fixedsys">
3751 <nobr>label</nobr>
3752 </font>
3753 </td>
3754 <td>
3756 Decrease CX, jump to label if CX not zero and ZF = 0. <br><br>Algorithm:
3757 <br><br>
3758 <font face="Fixedsys">
3759 <ul>
3760 <li>CX = CX - 1<br></li>
3761 <li>if (CX &lt;&gt; 0) and (ZF = 0) then
3762 <ul>
3763 <li>jump</li>
3764 </ul>
3765 else
3766 <ul>
3767 <li>no jump, continue</li>
3768 </ul>
3769 </li>
3770 </ul>
3771 </font>
3772 Example:<pre><font face="Fixedsys">; Loop until '7' is found,
3773 ; or 5 times.
3775 include 'emu8086.inc'
3777 ORG 100h
3778 MOV SI, 0
3779 MOV CX, 5
3780 label1:
3781 PUTC '*'
3782 MOV AL, v1[SI]
3783 INC SI ; next byte (SI=SI+1).
3784 CMP AL, 7
3785 LOOPNZ label1
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>
3793 </tbody></table>
3794 </font>
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">&nbsp;</a>
3800 </td>
3801 </tr>
3806 <tr>
3807 <td>
3808 <font face="Fixedsys">
3809 LOOPZ
3810 </font>
3811 </td>
3812 <td>
3813 <font face="Fixedsys">
3814 <nobr>label</nobr>
3815 </font>
3817 </td>
3818 <td>
3820 Decrease CX, jump to label if CX not zero and ZF = 1. <br><br>Algorithm:
3821 <br><br>
3822 <font face="Fixedsys">
3823 <ul>
3824 <li>CX = CX - 1<br></li>
3825 <li>if (CX &lt;&gt; 0) and (ZF = 1) then
3826 <ul>
3827 <li>jump</li>
3828 </ul>
3829 else
3830 <ul>
3831 <li>no jump, continue</li>
3832 </ul>
3833 </li>
3834 </ul>
3835 </font>
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'
3843 ORG 100h
3844 MOV AX, 0
3845 MOV CX, 5
3846 label1:
3847 PUTC '*'
3848 ADD AX, 100
3849 CMP AH, 0
3850 LOOPZ label1
3851 RET</font></pre>
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>
3857 </tbody></table>
3858 </font>
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">&nbsp;</a>
3864 </td>
3865 </tr>
3870 <tr>
3871 <td>
3872 <font face="Fixedsys">
3874 </font>
3875 </td>
3876 <td>
3877 <font face="Fixedsys">
3878 <nobr>
3879 REG, memory<br>
3880 memory, REG<br>
3881 REG, REG<br>
3882 memory, immediate<br>
3883 REG, immediate<br><br>
3885 SREG, memory<br>
3886 memory, SREG<br>
3887 REG, SREG<br>
3888 SREG, REG
3889 </nobr>
3890 </font>
3891 </td>
3892 <td>
3894 Copy operand2 to operand1.<br><br>
3895 The MOV instruction <u>cannot</u>:
3896 <ul>
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>
3900 </ul>
3901 <br>Algorithm:<br><br>
3902 <font face="Fixedsys">
3903 <blockquote>
3904 operand1 = operand2
3905 </blockquote>
3906 </font>
3907 Example:<pre><font face="Fixedsys">
3908 ORG 100h
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.
3916 </font></pre>
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>
3922 </tbody></table>
3923 </font>
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">&nbsp;</a>
3929 </td>
3930 </tr>
3935 <tr>
3936 <td>
3937 <font face="Fixedsys">
3938 MOVSB
3939 </font>
3940 </td>
3941 <td>No operands</td>
3942 <td>
3944 Copy byte at DS:[SI] to ES:[DI].
3945 Update SI and DI.<br><br>Algorithm:
3946 <br><br>
3947 <font face="Fixedsys">
3948 <ul>
3949 <li>ES:[DI] = DS:[SI]<br></li>
3950 <li>if DF = 0 then
3951 <ul>
3952 <li>SI = SI + 1</li>
3953 <li>DI = DI + 1</li>
3954 </ul>
3955 else
3956 <ul>
3957 <li>SI = SI - 1</li>
3958 <li>DI = DI - 1</li>
3959 </ul>
3960 </li>
3961 </ul>
3962 </font>
3963 Example:<pre><font face="Fixedsys">
3964 ORG 100h
3967 LEA SI, a1
3968 LEA DI, a2
3969 MOV CX, 5
3970 REP MOVSB
3974 a1 DB 1,2,3,4,5
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>
3981 </tbody></table>
3982 </font>
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">&nbsp;</a>
3988 </td>
3989 </tr>
3994 <tr>
3995 <td>
3996 <font face="Fixedsys">
3997 MOVSW
3998 </font>
3999 </td>
4000 <td>No operands</td>
4001 <td>
4003 Copy <b>word</b> at DS:[SI] to ES:[DI].
4004 Update SI and DI.<br><br>Algorithm:
4005 <br><br>
4006 <font face="Fixedsys">
4007 <ul>
4008 <li>ES:[DI] = DS:[SI]<br></li>
4009 <li>if DF = 0 then
4010 <ul>
4011 <li>SI = SI + 2</li>
4012 <li>DI = DI + 2</li>
4013 </ul>
4014 else
4015 <ul>
4016 <li>SI = SI - 2</li>
4017 <li>DI = DI - 2</li>
4018 </ul>
4019 </li>
4020 </ul>
4021 </font>
4022 Example:<pre><font face="Fixedsys">
4023 ORG 100h
4026 LEA SI, a1
4027 LEA DI, a2
4028 MOV CX, 5
4029 REP MOVSW
4033 a1 DW 1,2,3,4,5
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>
4040 </tbody></table>
4041 </font>
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">&nbsp;</a>
4047 </td>
4048 </tr>
4053 <tr>
4054 <td>
4055 <font face="Fixedsys">
4057 </font>
4058 </td>
4059 <td>
4060 <font face="Fixedsys">
4061 <nobr>
4062 REG<br>
4063 memory<br>
4064 </nobr>
4065 </font>
4066 </td>
4067 <td>
4069 Unsigned multiply.
4070 <br><br>Algorithm:<br><br>
4071 <blockquote>
4072 when operand is a <b>byte</b>:<br>
4073 <font face="Fixedsys">AX = AL * operand</font>.
4074 </blockquote>
4076 <blockquote>
4077 when operand is a <b>word</b>:<br>
4078 <font face="Fixedsys">(DX AX) = AX * operand</font>.
4079 </blockquote>
4080 Example:<pre><font face="Fixedsys">MOV AL, 200 ; AL = 0C8h
4081 MOV BL, 4
4082 MUL BL ; AX = 0320h (800)
4083 RET</font></pre>
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>
4089 </tbody></table>
4090 CF=OF=0 when high section of the result is zero.
4091 </font>
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">&nbsp;</a>
4097 </td>
4098 </tr>
4103 <tr>
4104 <td>
4105 <font face="Fixedsys">
4107 </font>
4108 </td>
4109 <td>
4110 <font face="Fixedsys">
4111 <nobr>
4112 REG<br>
4113 memory<br>
4114 </nobr>
4115 </font>
4116 </td>
4117 <td>
4119 Negate. Makes operand negative (two's complement).
4120 <br><br>Algorithm:<br><br>
4121 <font face="Fixedsys">
4122 <ul>
4123 <li>Invert all bits of the operand</li>
4124 <li>Add 1 to inverted operand</li>
4125 </ul>
4126 </font>
4127 Example:<pre><font face="Fixedsys">MOV AL, 5 ; AL = 05h
4128 NEG AL ; AL = 0FBh (-5)
4129 NEG AL ; AL = 05h (5)
4130 RET</font></pre>
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>
4136 </tbody></table>
4137 </font>
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">&nbsp;</a>
4143 </td>
4144 </tr>
4149 <tr>
4150 <td>
4151 <font face="Fixedsys">
4153 </font>
4154 </td>
4155 <td>No operands</td>
4156 <td>
4158 No Operation.<br><br>Algorithm:
4159 <br><br>
4160 <font face="Fixedsys">
4161 </font><ul>
4162 <font face="Fixedsys"><li>Do nothing<br></li>
4163 </font></ul>
4164 <font face="Fixedsys"></font>
4165 Example:<pre><font face="Fixedsys">; do nothing, 3 times:
4169 RET</font></pre>
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>
4175 </tbody></table>
4176 </font>
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">&nbsp;</a>
4182 </td>
4183 </tr>
4188 <tr>
4189 <td>
4190 <font face="Fixedsys">
4192 </font>
4193 </td>
4194 <td>
4195 <font face="Fixedsys">
4196 <nobr>
4197 REG<br>
4198 memory<br>
4199 </nobr>
4200 </font>
4201 </td>
4202 <td>
4204 Invert each bit of the operand.<br><br>Algorithm:
4205 <br><br>
4206 <font face="Fixedsys">
4207 <ul>
4208 <li>if bit is 1 turn it to 0.<br></li>
4209 <li>if bit is 0 turn it to 1.<br></li>
4210 </ul>
4211 </font>
4212 Example:<pre><font face="Fixedsys">MOV AL, 00011011b
4213 NOT AL ; AL = 11100100b
4214 RET</font></pre>
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>
4220 </tbody></table>
4221 </font>
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">&nbsp;</a>
4227 </td>
4228 </tr>
4232 <tr>
4233 <td>
4234 <font face="Fixedsys">
4236 </font>
4237 </td>
4238 <td>
4239 <font face="Fixedsys">
4240 <nobr>
4241 REG, memory<br>
4242 memory, REG<br>
4243 REG, REG<br>
4244 memory, immediate<br>
4245 REG, immediate
4246 </nobr>
4247 </font>
4248 </td>
4249 <td>
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">
4255 1 OR 1 = 1<br>
4256 1 OR 0 = 1<br>
4257 0 OR 1 = 1<br>
4258 0 OR 0 = 0<br>
4259 </font>
4260 <br><br>Example:<pre><font face="Fixedsys">MOV AL, 'A' ; AL = 01000001b
4261 OR AL, 00100000b ; AL = 01100001b ('a')
4262 RET</font></pre>
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>
4268 </tbody></table>
4269 </font>
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">&nbsp;</a>
4275 </td>
4276 </tr>
4278 <tr>
4279 <td>
4280 <font face="Fixedsys">
4282 </font>
4283 </td>
4284 <td>
4285 <font face="Fixedsys">
4286 <nobr>
4287 im.byte, AL<br>
4288 im.byte, AX<br>
4289 DX, AL<br>
4290 DX, AX
4291 </nobr>
4292 </font>
4293 </td>
4294 <td>
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>
4310 </tbody></table>
4311 </font>
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">&nbsp;</a>
4317 </td>
4318 </tr>
4321 <tr>
4322 <td>
4323 <font face="Fixedsys">
4325 </font>
4326 </td>
4327 <td>
4328 <font face="Fixedsys">
4329 <nobr>
4330 REG<br>
4331 SREG<br>
4332 memory
4333 </nobr>
4334 </font>
4335 </td>
4336 <td>
4338 Get 16 bit value from the stack.
4339 <br><br>Algorithm:<br><br>
4340 <font face="Fixedsys">
4341 <ul>
4342 <li>operand = SS:[SP] (top of the stack)</li>
4343 <li>SP = SP + 2</li>
4344 </ul>
4345 </font>
4346 <br>Example:<pre><font face="Fixedsys">MOV AX, 1234h
4347 PUSH AX
4348 POP DX ; DX = 1234h
4349 RET</font></pre>
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>
4355 </tbody></table>
4356 </font>
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">&nbsp;</a>
4362 </td>
4363 </tr>
4368 <tr>
4369 <td>
4370 <font face="Fixedsys">
4371 POPA
4372 </font>
4373 </td>
4374 <td>No operands</td>
4375 <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">
4382 <ul>
4383 <li>POP DI</li>
4384 <li>POP SI</li>
4385 <li>POP BP</li>
4386 <li>POP xx (SP value ignored)</li>
4387 <li>POP BX</li>
4388 <li>POP DX</li>
4389 <li>POP CX</li>
4390 <li>POP AX</li>
4391 </ul>
4392 </font>
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>
4398 </tbody></table>
4399 </font>
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">&nbsp;</a>
4405 </td>
4406 </tr>
4411 <tr>
4412 <td>
4413 <font face="Fixedsys">
4414 POPF
4415 </font>
4416 </td>
4417 <td>No operands</td>
4418 <td>
4420 Get flags register from the stack.
4421 <br><br>Algorithm:<br><br>
4422 <font face="Fixedsys">
4423 <ul>
4424 <li>flags = SS:[SP] (top of the stack)</li>
4425 <li>SP = SP + 2</li>
4426 </ul>
4427 </font>
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>
4433 </tbody></table>
4434 </font>
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">&nbsp;</a>
4440 </td>
4441 </tr>
4446 <tr>
4447 <td>
4448 <font face="Fixedsys">
4449 PUSH
4450 </font>
4451 </td>
4452 <td>
4453 <font face="Fixedsys">
4454 <nobr>
4455 REG<br>
4456 SREG<br>
4457 memory<br>
4458 immediate
4459 </nobr>
4460 </font>
4461 </td>
4462 <td>
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">
4469 <ul>
4470 <li>SP = SP - 2</li>
4471 <li>SS:[SP] (top of the stack) = operand</li>
4472 </ul>
4473 </font>
4474 <br>Example:<pre><font face="Fixedsys">MOV AX, 1234h
4475 PUSH AX
4476 POP DX ; DX = 1234h
4477 RET</font></pre>
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>
4483 </tbody></table>
4484 </font>
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">&nbsp;</a>
4490 </td>
4491 </tr>
4496 <tr>
4497 <td>
4498 <font face="Fixedsys">
4499 PUSHA
4500 </font>
4501 </td>
4502 <td>No operands</td>
4503 <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">
4510 <ul>
4511 <li>PUSH AX</li>
4512 <li>PUSH CX</li>
4513 <li>PUSH DX</li>
4514 <li>PUSH BX</li>
4515 <li>PUSH SP</li>
4516 <li>PUSH BP</li>
4517 <li>PUSH SI</li>
4518 <li>PUSH DI</li>
4519 </ul>
4520 </font>
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>
4526 </tbody></table>
4527 </font>
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">&nbsp;</a>
4533 </td>
4534 </tr>
4539 <tr>
4540 <td>
4541 <font face="Fixedsys">
4542 PUSHF
4543 </font>
4544 </td>
4545 <td>No operands</td>
4546 <td>
4548 Store flags register in the stack.
4549 <br><br>Algorithm:<br><br>
4550 <font face="Fixedsys">
4551 </font><ul>
4552 <font face="Fixedsys"> <li>SP = SP - 2</li>
4553 <li>SS:[SP] (top of the stack) = flags</li>
4554 </font></ul>
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>
4561 </tbody></table>
4562 </font>
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">&nbsp;</a>
4568 </td>
4569 </tr>
4574 <tr>
4575 <td>
4576 <font face="Fixedsys">
4578 </font>
4579 </td>
4580 <td>
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>
4586 </font>
4587 </td>
4588 <td>
4590 Rotate operand1 left through Carry Flag. The number of rotates is set by operand2.
4591 <br>
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">
4598 <ul>
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.
4601 </ul>
4602 </font>
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.
4606 RET</font></pre>
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>
4612 </tbody></table>
4613 OF=0 if first operand keeps original sign.
4614 </font>
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">&nbsp;</a>
4620 </td>
4621 </tr>
4626 <tr>
4627 <td>
4628 <font face="Fixedsys">
4630 </font>
4631 </td>
4632 <td>
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>
4638 </font>
4639 </td>
4640 <td>
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">
4646 <ul>
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.
4649 </ul>
4650 </font>
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.
4654 RET</font></pre>
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>
4660 </tbody></table>
4661 OF=0 if first operand keeps original sign.
4662 </font>
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">&nbsp;</a>
4668 </td>
4669 </tr>
4674 <tr>
4675 <td>
4676 <font face="Fixedsys">
4678 </font>
4679 </td>
4680 <td>
4681 <font face="Fixedsys">
4682 <nobr>chain instruction</nobr><br>
4683 </font>
4684 </td>
4685 <td>
4687 Repeat following MOVSB, MOVSW, LODSB, LODSW, STOSB, STOSW instructions
4688 CX times.
4689 <br><br>Algorithm:<br><br>
4690 <font face="Fixedsys">
4691 check_cx:<br><br>
4692 if CX &lt;&gt; 0 then
4693 <ul>
4694 <li>do following <u>chain instruction</u></li>
4695 <li>CX = CX - 1</li>
4696 <li>go back to check_cx</li>
4697 </ul>
4698 else
4699 <ul>
4700 <li>exit from REP cycle</li>
4701 </ul>
4702 </font>
4704 <font face="Fixedsys">
4705 <table noshade="" border="1">
4706 <tbody><tr> <td>Z</td> </tr>
4707 <tr> <td>r</td> </tr>
4708 </tbody></table>
4709 </font>
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">&nbsp;</a>
4715 </td>
4716 </tr>
4722 <tr>
4723 <td>
4724 <font face="Fixedsys">
4725 REPE
4726 </font>
4727 </td>
4728 <td>
4729 <font face="Fixedsys">
4730 <nobr>chain instruction</nobr><br>
4731 </font>
4732 </td>
4733 <td>
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">
4739 check_cx:<br><br>
4740 if CX &lt;&gt; 0 then
4741 <ul>
4742 <li>do following <u>chain instruction</u></li>
4743 <li>CX = CX - 1</li>
4744 <li>if ZF = 1 then:
4745 <ul>
4746 <li>go back to check_cx</li>
4747 </ul>
4748 else
4749 <ul>
4750 <li>exit from REPE cycle</li>
4751 </ul>
4752 </li>
4753 </ul>
4754 else
4755 <ul>
4756 <li>exit from REPE cycle</li>
4757 </ul>
4758 </font>
4759 Example:<br>
4760 see <b>cmpsb.asm</b> in c:\emu8086\examples\.
4762 <br><br>
4764 <font face="Fixedsys">
4765 <table noshade="" border="1">
4766 <tbody><tr> <td>Z</td> </tr>
4767 <tr> <td>r</td> </tr>
4768 </tbody></table>
4769 </font>
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">&nbsp;</a>
4775 </td>
4776 </tr>
4782 <tr>
4783 <td>
4784 <font face="Fixedsys">
4785 REPNE
4786 </font>
4787 </td>
4788 <td>
4789 <font face="Fixedsys">
4790 <nobr>chain instruction</nobr><br>
4791 </font>
4792 </td>
4793 <td>
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">
4799 check_cx:<br><br>
4800 if CX &lt;&gt; 0 then
4801 <ul>
4802 <li>do following <u>chain instruction</u></li>
4803 <li>CX = CX - 1</li>
4804 <li>if ZF = 0 then:
4805 <ul>
4806 <li>go back to check_cx</li>
4807 </ul>
4808 else
4809 <ul>
4810 <li>exit from REPNE cycle</li>
4811 </ul>
4812 </li>
4813 </ul>
4814 else
4815 <ul>
4816 <li>exit from REPNE cycle</li>
4817 </ul>
4818 </font>
4820 <font face="Fixedsys">
4821 <table noshade="" border="1">
4822 <tbody><tr> <td>Z</td> </tr>
4823 <tr> <td>r</td> </tr>
4824 </tbody></table>
4825 </font>
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">&nbsp;</a>
4831 </td>
4832 </tr>
4838 <tr>
4839 <td>
4840 <font face="Fixedsys">
4841 REPNZ
4842 </font>
4843 </td>
4844 <td>
4845 <font face="Fixedsys">
4846 <nobr>chain instruction</nobr><br>
4847 </font>
4848 </td>
4849 <td>
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">
4855 check_cx:<br><br>
4856 if CX &lt;&gt; 0 then
4857 </font><ul>
4858 <font face="Fixedsys"> <li>do following <u>chain instruction</u></li>
4859 <li>CX = CX - 1</li>
4860 <li>if ZF = 0 then:
4861 <ul>
4862 <li>go back to check_cx</li>
4863 </ul>
4864 else
4865 <ul>
4866 <li>exit from REPNZ cycle</li>
4867 </ul>
4868 </li>
4869 </font></ul>
4870 <font face="Fixedsys">else
4871 </font><ul>
4872 <font face="Fixedsys"> <li>exit from REPNZ cycle</li>
4873 </font></ul>
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>
4880 </tbody></table>
4881 </font>
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">&nbsp;</a>
4887 </td>
4888 </tr>
4894 <tr>
4895 <td>
4896 <font face="Fixedsys">
4897 REPZ
4898 </font>
4899 </td>
4900 <td>
4901 <font face="Fixedsys">
4902 <nobr>chain instruction</nobr><br>
4903 </font>
4904 </td>
4905 <td>
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">
4911 check_cx:<br><br>
4912 if CX &lt;&gt; 0 then
4913 <ul>
4914 <li>do following <u>chain instruction</u></li>
4915 <li>CX = CX - 1</li>
4916 <li>if ZF = 1 then:
4917 <ul>
4918 <li>go back to check_cx</li>
4919 </ul>
4920 else
4921 <ul>
4922 <li>exit from REPZ cycle</li>
4923 </ul>
4924 </li>
4925 </ul>
4926 else
4927 <ul>
4928 <li>exit from REPZ cycle</li>
4929 </ul>
4930 </font>
4932 <font face="Fixedsys">
4933 <table noshade="" border="1">
4934 <tbody><tr> <td>Z</td> </tr>
4935 <tr> <td>r</td> </tr>
4936 </tbody></table>
4937 </font>
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">&nbsp;</a>
4943 </td>
4944 </tr>
4949 <tr>
4950 <td>
4951 <font face="Fixedsys">
4953 </font>
4954 </td>
4955 <td>No operands<br>
4956 or even immediate</td>
4957 <td>
4959 Return from near procedure.
4960 <br><br>Algorithm:<br><br>
4961 <font face="Fixedsys">
4962 </font><ul>
4963 <font face="Fixedsys"> <li>
4964 Pop from stack:
4965 <ul>
4966 <li>IP</li>
4967 </ul>
4968 </li>
4969 <li>
4970 if <u>immediate</u> operand is present:
4971 <nobr>SP = SP + operand</nobr>
4972 </li>
4973 </font></ul>
4974 <font face="Fixedsys"></font>
4975 Example:<pre><font face="Fixedsys">
4976 ORG 100h ; for COM file.
4978 CALL p1
4980 ADD AX, 1
4982 RET ; return to OS.
4984 p1 PROC ; procedure declaration.
4985 MOV AX, 1234h
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>
4993 </tbody></table>
4994 </font>
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">&nbsp;</a>
5000 </td>
5001 </tr>
5006 <tr>
5007 <td>
5008 <font face="Fixedsys">
5009 RETF
5010 </font>
5011 </td>
5012 <td>No operands<br>
5013 or even immediate</td>
5014 <td>
5016 Return from Far procedure.
5017 <br><br>Algorithm:<br><br>
5018 <font face="Fixedsys">
5019 <ul>
5020 <li>
5021 Pop from stack:
5022 <ul>
5023 <li>IP</li>
5024 <li>CS</li>
5025 </ul>
5026 </li>
5027 <li>
5028 if <u>immediate</u> operand is present:
5029 <nobr>SP = SP + operand</nobr>
5030 </li>
5031 </ul>
5032 </font>
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>
5038 </tbody></table>
5039 </font>
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">&nbsp;</a>
5045 </td>
5046 </tr>
5051 <tr>
5052 <td>
5053 <font face="Fixedsys">
5055 </font>
5056 </td>
5057 <td>
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>
5063 </font>
5064 </td>
5065 <td>
5067 Rotate operand1 left. The number of rotates is set by operand2.
5069 <br><br>Algorithm:<br><br>
5070 <font face="Fixedsys">
5071 <ul>
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.
5074 </ul>
5075 </font>
5076 Example:<pre><font face="Fixedsys">MOV AL, 1Ch ; AL = 00011100b
5077 ROL AL, 1 ; AL = 00111000b, CF=0.
5078 RET</font></pre>
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>
5084 </tbody></table>
5085 OF=0 if first operand keeps original sign.
5086 </font>
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">&nbsp;</a>
5092 </td>
5093 </tr>
5098 <tr>
5099 <td>
5100 <font face="Fixedsys">
5102 </font>
5103 </td>
5104 <td>
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>
5110 </font>
5111 </td>
5112 <td>
5114 Rotate operand1 right. The number of rotates is set by operand2.
5116 <br><br>Algorithm:<br><br>
5117 <font face="Fixedsys">
5118 <ul>
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.
5121 </ul>
5122 </font>
5123 Example:<pre><font face="Fixedsys">MOV AL, 1Ch ; AL = 00011100b
5124 ROR AL, 1 ; AL = 00001110b, CF=0.
5125 RET</font></pre>
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>
5131 </tbody></table>
5132 OF=0 if first operand keeps original sign.
5133 </font>
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">&nbsp;</a>
5139 </td>
5140 </tr>
5145 <tr>
5146 <td>
5147 <font face="Fixedsys">
5148 SAHF
5149 </font>
5150 </td>
5151 <td>No operands</td>
5152 <td>
5154 Store AH register into low 8 bits of Flags register.
5155 <br><br>Algorithm:<br><br>
5156 <font face="Fixedsys">
5157 <ul>
5158 flags register = AH<br>
5159 </ul>
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>
5163 </pre>
5164 bits 1, 3, 5 are reserved.
5165 </font>
5167 <br><br>
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>
5174 </tbody></table>
5175 </font>
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">&nbsp;</a>
5182 </td>
5183 </tr>
5189 <tr>
5190 <td>
5191 <font face="Fixedsys">
5193 </font>
5194 </td>
5195 <td>
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>
5201 </font>
5202 </td>
5203 <td>
5205 Shift Arithmetic operand1 Left. The number of shifts is set by operand2.
5207 <br><br>Algorithm:<br><br>
5208 <font face="Fixedsys">
5209 </font><ul>
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>
5212 </font></ul>
5213 <font face="Fixedsys"></font>
5214 Example:<pre><font face="Fixedsys">MOV AL, 0E0h ; AL = 11100000b
5215 SAL AL, 1 ; AL = 11000000b, CF=1.
5216 RET</font></pre>
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>
5222 </tbody></table>
5223 OF=0 if first operand keeps original sign.
5224 </font>
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">&nbsp;</a>
5230 </td>
5231 </tr>
5237 <tr>
5238 <td>
5239 <font face="Fixedsys">
5241 </font>
5242 </td>
5243 <td>
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>
5249 </font>
5250 </td>
5251 <td>
5253 Shift Arithmetic operand1 Right. The number of shifts is set by operand2.
5255 <br><br>Algorithm:<br><br>
5256 <font face="Fixedsys">
5257 <ul>
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>
5261 </ul>
5262 </font>
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.
5269 RET</font></pre>
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>
5275 </tbody></table>
5276 OF=0 if first operand keeps original sign.
5277 </font>
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">&nbsp;</a>
5283 </td>
5284 </tr>
5289 <tr>
5290 <td>
5291 <font face="Fixedsys">
5293 </font>
5294 </td>
5295 <td>
5296 <font face="Fixedsys">
5297 <nobr>
5298 REG, memory<br>
5299 memory, REG<br>
5300 REG, REG<br>
5301 memory, immediate<br>
5302 REG, immediate
5303 </nobr>
5304 </font>
5305 </td>
5306 <td>
5308 Subtract with Borrow.
5309 <br><br>Algorithm:<br><br>
5310 <font face="Fixedsys">
5311 operand1 = operand1 - operand2 - CF
5312 </font>
5313 <br><br>
5314 Example:<pre><font face="Fixedsys">STC
5315 MOV AL, 5
5316 SBB AL, 3 ; AL = 5 - 3 - 1 = 1
5318 RET</font></pre>
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>
5324 </tbody></table>
5325 </font>
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">&nbsp;</a>
5331 </td>
5332 </tr>
5338 <tr>
5339 <td>
5340 <font face="Fixedsys">
5341 SCASB
5342 </font>
5343 </td>
5344 <td>No operands</td>
5345 <td>
5347 Compare bytes: <nobr>AL from ES:[DI].</nobr> <br><br>Algorithm:
5348 <br><br>
5349 <font face="Fixedsys">
5350 </font><ul>
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>
5353 <li>if DF = 0 then
5354 <ul>
5355 <li>DI = DI + 1</li>
5356 </ul>
5357 else
5358 <ul>
5359 <li>DI = DI - 1</li>
5360 </ul>
5361 </li>
5362 </font></ul>
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>
5369 </tbody></table>
5370 </font>
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">&nbsp;</a>
5376 </td>
5377 </tr>
5382 <tr>
5383 <td>
5384 <font face="Fixedsys">
5385 SCASW
5386 </font>
5387 </td>
5388 <td>No operands</td>
5389 <td>
5391 Compare words: <nobr>AX from ES:[DI].</nobr> <br><br>Algorithm:
5392 <br><br>
5393 <font face="Fixedsys">
5394 <ul>
5395 <li>ES:[DI] - AX<br></li>
5396 <li>set flags according to result:<br> OF, SF, ZF, AF, PF, CF<br></li>
5397 <li>if DF = 0 then
5398 <ul>
5399 <li>DI = DI + 2</li>
5400 </ul>
5401 else
5402 <ul>
5403 <li>DI = DI - 2</li>
5404 </ul>
5405 </li>
5406 </ul>
5407 </font>
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>
5413 </tbody></table>
5414 </font>
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">&nbsp;</a>
5420 </td>
5421 </tr>
5427 <tr>
5428 <td>
5429 <font face="Fixedsys">
5431 </font>
5432 </td>
5433 <td>
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>
5439 </font>
5440 </td>
5441 <td>
5443 Shift operand1 Left. The number of shifts is set by operand2.
5445 <br><br>Algorithm:<br><br>
5446 <font face="Fixedsys">
5447 <ul>
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>
5450 </ul>
5451 </font>
5452 Example:<pre><font face="Fixedsys">MOV AL, 11100000b
5453 SHL AL, 1 ; AL = 11000000b, CF=1.
5455 RET</font></pre>
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>
5461 </tbody></table>
5462 OF=0 if first operand keeps original sign.
5463 </font>
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">&nbsp;</a>
5469 </td>
5470 </tr>
5476 <tr>
5477 <td>
5478 <font face="Fixedsys">
5480 </font>
5481 </td>
5482 <td>
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>
5488 </font>
5489 </td>
5490 <td>
5492 Shift operand1 Right. The number of shifts is set by operand2.
5494 <br><br>Algorithm:<br><br>
5495 <font face="Fixedsys">
5496 <ul>
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>
5499 </ul>
5500 </font>
5501 Example:<pre><font face="Fixedsys">MOV AL, 00000111b
5502 SHR AL, 1 ; AL = 00000011b, CF=1.
5504 RET</font></pre>
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>
5510 </tbody></table>
5511 OF=0 if first operand keeps original sign.
5512 </font>
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">&nbsp;</a>
5518 </td>
5519 </tr>
5524 <tr>
5525 <td>
5526 <font face="Fixedsys">
5528 </font>
5529 </td>
5530 <td>No operands</td>
5531 <td>
5533 Set Carry flag. <br><br>Algorithm:
5534 <br><br>
5535 <font face="Fixedsys">
5536 CF = 1
5537 </font>
5539 <br><br>
5541 <font face="Fixedsys">
5542 <table noshade="" border="1">
5543 <tbody><tr> <td>C</td> </tr>
5544 <tr> <td>1</td> </tr>
5545 </tbody></table>
5546 </font>
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">&nbsp;</a>
5552 </td>
5553 </tr>
5558 <tr>
5559 <td>
5560 <font face="Fixedsys">
5562 </font>
5563 </td>
5564 <td>No operands</td>
5565 <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:
5569 <br><br>
5570 <font face="Fixedsys">
5571 DF = 1
5572 </font>
5573 <br><br>
5575 <font face="Fixedsys">
5576 <table noshade="" border="1">
5577 <tbody><tr> <td>D</td> </tr>
5578 <tr> <td>1</td> </tr>
5579 </tbody></table>
5580 </font>
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">&nbsp;</a>
5586 </td>
5587 </tr>
5594 <tr>
5595 <td>
5596 <font face="Fixedsys">
5598 </font>
5599 </td>
5600 <td>No operands</td>
5601 <td>
5603 Set Interrupt enable flag. This enables hardware interrupts. <br><br>Algorithm:
5604 <br><br>
5605 <font face="Fixedsys">
5606 IF = 1
5607 </font>
5608 <br><br>
5610 <font face="Fixedsys">
5611 <table noshade="" border="1">
5612 <tbody><tr> <td>I</td> </tr>
5613 <tr> <td>1</td> </tr>
5614 </tbody></table>
5615 </font>
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">&nbsp;</a>
5621 </td>
5622 </tr>
5627 <tr>
5628 <td>
5629 <font face="Fixedsys">
5630 STOSB
5631 </font>
5632 </td>
5633 <td>No operands</td>
5634 <td>
5636 Store byte in AL into ES:[DI]. Update DI.<br><br>Algorithm:
5637 <br><br>
5638 <font face="Fixedsys">
5639 <ul>
5640 <li>ES:[DI] = AL<br></li>
5641 <li>if DF = 0 then
5642 <ul>
5643 <li>DI = DI + 1</li>
5644 </ul>
5645 else
5646 <ul>
5647 <li>DI = DI - 1</li>
5648 </ul>
5649 </li>
5650 </ul>
5651 </font>
5652 Example:
5653 <pre><font face="Fixedsys">
5654 ORG 100h
5656 LEA DI, a1
5657 MOV AL, 12h
5658 MOV CX, 5
5660 REP STOSB
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>
5670 </tbody></table>
5671 </font>
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">&nbsp;</a>
5677 </td>
5678 </tr>
5684 <tr>
5685 <td>
5686 <font face="Fixedsys">
5687 STOSW
5688 </font>
5689 </td>
5690 <td>No operands</td>
5691 <td>
5693 Store word in AX into ES:[DI]. Update DI.<br><br>Algorithm:
5694 <br><br>
5695 <font face="Fixedsys">
5696 <ul>
5697 <li>ES:[DI] = AX<br></li>
5698 <li>if DF = 0 then
5699 <ul>
5700 <li>DI = DI + 2</li>
5701 </ul>
5702 else
5703 <ul>
5704 <li>DI = DI - 2</li>
5705 </ul>
5706 </li>
5707 </ul>
5708 </font>
5709 Example:
5710 <pre><font face="Fixedsys">
5711 ORG 100h
5713 LEA DI, a1
5714 MOV AX, 1234h
5715 MOV CX, 5
5717 REP STOSW
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>
5727 </tbody></table>
5728 </font>
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">&nbsp;</a>
5734 </td>
5735 </tr>
5742 <tr>
5743 <td>
5744 <font face="Fixedsys">
5746 </font>
5747 </td>
5748 <td>
5749 <font face="Fixedsys">
5750 <nobr>
5751 REG, memory<br>
5752 memory, REG<br>
5753 REG, REG<br>
5754 memory, immediate<br>
5755 REG, immediate
5756 </nobr>
5757 </font>
5758 </td>
5759 <td>
5761 Subtract.
5762 <br><br>Algorithm:<br><br>
5763 <font face="Fixedsys">
5764 operand1 = operand1 - operand2
5765 </font>
5766 <br><br>
5767 Example:<pre><font face="Fixedsys">MOV AL, 5
5768 SUB AL, 1 ; AL = 4
5770 RET</font></pre>
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>
5776 </tbody></table>
5777 </font>
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">&nbsp;</a>
5783 </td>
5784 </tr>
5791 <tr>
5792 <td>
5793 <font face="Fixedsys">
5794 TEST
5795 </font>
5796 </td>
5797 <td>
5798 <font face="Fixedsys">
5799 <nobr>
5800 REG, memory<br>
5801 memory, REG<br>
5802 REG, REG<br>
5803 memory, immediate<br>
5804 REG, immediate
5805 </nobr>
5806 </font>
5807 </td>
5808 <td>
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">
5815 1 AND 1 = 1<br>
5816 1 AND 0 = 0<br>
5817 0 AND 1 = 0<br>
5818 0 AND 0 = 0<br>
5819 </font>
5820 <br><br>
5821 Example:<pre><font face="Fixedsys">MOV AL, 00000101b
5822 TEST AL, 1 ; ZF = 0.
5823 TEST AL, 10b ; ZF = 1.
5824 RET</font></pre>
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>
5830 </tbody></table>
5831 </font>
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">&nbsp;</a>
5837 </td>
5838 </tr>
5845 <tr>
5846 <td>
5847 <font face="Fixedsys">
5848 XCHG
5849 </font>
5850 </td>
5851 <td>
5852 <font face="Fixedsys">
5853 <nobr>
5854 REG, memory<br>
5855 memory, REG<br>
5856 REG, REG
5857 </nobr>
5858 </font>
5859 </td>
5860 <td>
5862 Exchange values of two operands.
5863 <br><br>Algorithm:<br><br>
5864 <font face="Fixedsys">
5865 operand1 &lt; - &gt; operand2
5866 </font>
5867 <br><br>
5868 Example:<pre><font face="Fixedsys">MOV AL, 5
5869 MOV AH, 2
5870 XCHG AL, AH ; AL = 2, AH = 5
5871 XCHG AL, AH ; AL = 5, AH = 2
5872 RET</font></pre>
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>
5878 </tbody></table>
5879 </font>
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">&nbsp;</a>
5885 </td>
5886 </tr>
5893 <tr>
5894 <td>
5895 <font face="Fixedsys">
5896 XLATB
5897 </font>
5898 </td>
5899 <td>No operands</td>
5900 <td>
5902 Translate byte from table.<br>
5903 Copy value of memory byte at <nobr>DS:[BX + unsigned AL]</nobr> to
5904 AL register.
5905 <br><br>Algorithm:<br><br>
5906 <font face="Fixedsys">
5907 AL = DS:[BX + unsigned AL]
5908 </font>
5909 <br><br>
5910 Example:<pre><font face="Fixedsys">
5911 ORG 100h
5912 LEA BX, dat
5913 MOV AL, 2
5914 XLATB ; AL = 33h
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>
5924 </tbody></table>
5925 </font>
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">&nbsp;</a>
5931 </td>
5932 </tr>
5940 <tr>
5941 <td>
5942 <font face="Fixedsys">
5944 </font>
5945 </td>
5946 <td>
5947 <font face="Fixedsys">
5948 <nobr>
5949 REG, memory<br>
5950 memory, REG<br>
5951 REG, REG<br>
5952 memory, immediate<br>
5953 REG, immediate
5954 </nobr>
5955 </font>
5956 </td>
5957 <td>
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">
5963 1 XOR 1 = 0<br>
5964 1 XOR 0 = 1<br>
5965 0 XOR 1 = 1<br>
5966 0 XOR 0 = 0<br>
5967 </font>
5968 <br><br>
5969 Example:<pre><font face="Fixedsys">MOV AL, 00000111b
5970 XOR AL, 00000010b ; AL = 00000101b
5971 RET</font></pre>
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>
5978 </tbody></table>
5979 </font>
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>
5985 </td>
5986 </tr>
5992 </tbody></table>
5994 <br><br>
5996 </font><hr>
5998 <font size="3" face="Verdana"><br><br><br>
5999 </font><center>
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>
6004 </font>
6005 </font></center>
6007 <font size="3" face="Verdana"></font>
6010 <br>
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>
6014 </body></html>