⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s03_08.htm

📁 Programmer s Reference Manual is an improtant book on Intel processor architecture and programming.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>80386 Programmer's Reference Manual -- Section 3.8</TITLE></HEAD><BODY><B>up:</B> <A HREF="c03.htm">Chapter 3 -- Applications Instruction Set</A><BR><B>prev:</B> <A HREF="s03_07.htm">3.7  Instructions for Block-Structured Languages</A><BR><B>next:</B> <A HREF="s03_09.htm">3.9  Coprocessor Interface Instructions</A><P><HR><P><H1>3.8  Flag Control Instructions</H1>The flag control instructions provide a method for directly changing thestate of bits in the flag register.<H2>3.8.1  Carry and Direction Flag Control Instructions</H2>The carry flag instructions are useful in conjunction withrotate-with-carry instructions <A HREF="RCL.htm">RCL</A> and <A HREF="RCL.htm">RCR</A>. They can initialize the carryflag, CF, to a known state before execution of a rotate that moves the carrybit into one end of the rotated operand.<P>The direction flag control instructions are specifically included to set orclear the direction flag, DF, which controls the left-to-right orright-to-left direction of string processing. If DF=0, the processorautomatically increments the string index registers, ESI and EDI, after eachexecution of a string primitive. If DF=1, the processor decrements theseindex registers. Programmers should use one of these instructions before anyprocedure that uses string instructions to insure that DF is set properly.<PRE>Flag Control Instruction                  Effect<A HREF="STC.htm">STC</A> (Set Carry Flag)                      CF := 1<A HREF="CLC.htm">CLC</A> (Clear Carry Flag)                    CF := 0<A HREF="CMC.htm">CMC</A> (Complement Carry Flag)               CF := NOT (CF)<A HREF="CLD.htm">CLD</A> (Clear Direction Flag)                DF := 0<A HREF="STD.htm">STD</A> (Set Direction Flag)                  DF := 1</PRE><H2>3.8.2  Flag Transfer Instructions</H2>Though specific instructions exist to alter CF and DF, there is no directmethod of altering the other applications-oriented flags. The flag transferinstructions allow a program to alter the other flag bits with the bitmanipulation instructions after transferring these flags to the stack or theAH register.<P>The instructions <A HREF="LAHF.htm">LAHF</A> and <A HREF="SAHF.htm">SAHF</A> deal with five of the status flags, whichare used primarily by the arithmetic and logical instructions.<P><A HREF="LAHF.htm">LAHF</A> (Load AH from Flags) copies SF, ZF, AF, PF, and CF to AH bits 7, 6, 4,2, and 0, respectively (see <A HREF="#fig3-22">Figure 3-22</A>). The contents of the remaining bits(5, 3, and 1) are undefined. The flags remain unaffected.<P><A HREF="SAHF.htm">SAHF</A> (Store AH into Flags) transfers bits 7, 6, 4, 2, and 0 from AH intoSF, ZF, AF, PF, and CF, respectively (see <A HREF="#fig3-22">Figure 3-22</A>).<P>The <A HREF="PUSHF.htm">PUSHF</A> and <A HREF="POPF.htm">POPF</A> instructions are not only useful for storing the flagsin memory where they can be examined and modified but are also useful forpreserving the state of the flags register while executing a procedure.<P><A HREF="PUSHF.htm">PUSHF</A> (Push Flags) decrements ESP by two and then transfers the low-orderword of the flags register to the word at the top of stack pointed to by ESP(see <A HREF="s03_09.htm#fig3-23">Figure 3-23</A>). The variant <A HREF="PUSHF.htm">PUSHFD</A> decrements ESP by four, thentransfers both words of the extended flags register to the top of the stackpointed to by ESP (the VM and RF flags are not moved, however).<P><A HREF="POPF.htm">POPF</A> (Pop Flags) transfers specific bits from the word at the top of stackinto the low-order byte of the flag register (see <A HREF="s03_09.htm#fig3-23">Figure 3-23</A>), thenincrements ESP by two. The variant <A HREF="POPF.htm">POPFD</A> transfers specific bits from thedoubleword at the top of the stack into the extended flags register (the RFand VM flags are not changed, however), then increments ESP by four.<P><A NAME="fig3-22"><IMG align=center SRC="fig3-22.gif" border=0><P><HR><P><B>up:</B> <A HREF="c03.htm">Chapter 3 -- Applications Instruction Set</A><BR><B>prev:</B> <A HREF="s03_07.htm">3.7  Instructions for Block-Structured Languages</A><BR><B>next:</B> <A HREF="s03_09.htm">3.9  Coprocessor Interface Instructions</A></BODY>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -