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

📄 scas.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 -- Opcode SCAS</TITLE></HEAD><BODY><B>up:</B> <A HREF="c17.htm">Chapter 17 -- 80386 Instruction Set</A><BR><B>prev:</B><A HREF="SBB.htm"> SBB Integer Subtraction with Borrow</A><BR><B>next:</B><A HREF="SETcc.htm"> SETcc Byte Set on Condition</A><P><HR><P><H1>SCAS/SCASB/SCASW/SCASD -- Compare String Data</H1><PRE>Opcode  Instruction  Clocks  DescriptionAE      SCAS m8      7       Compare bytes AL-ES:[DI], update (E)DIAF      SCAS m16     7       Compare words AX-ES:[DI], update (E)DIAF      SCAS m32     7       Compare dwords EAX-ES:[DI], update (E)DIAE      SCASB        7       Compare bytes AL-ES:[DI], update (E)DIAF      SCASW        7       Compare words AX-ES:[DI], update (E)DIAF      SCASD        7       Compare dwords EAX-ES:[DI], update (E)DI</PRE><H2>Operation</H2><PRE>IF AddressSize = 16THEN use DI for dest-index;ELSE (* AddressSize = 32 *) use EDI for dest-index;FI;IF byte type of instructionTHEN   AL - [dest-index]; (* Compare byte in AL and dest *)   IF DF = 0 THEN IndDec := 1 ELSE IncDec := -1; FI;ELSE   IF OperandSize = 16   THEN      AX - [dest-index]; (* compare word in AL and dest *)      IF DF = 0 THEN IncDec := 2 ELSE IncDec := -2; FI;   ELSE (* OperandSize = 32 *)      EAX - [dest-index];(* compare dword in EAX & dest *)      IF DF = 0 THEN IncDec := 4 ELSE IncDec := -4; FI;   FI;FI;dest-index := dest-index + IncDec</PRE><H2>Description</H2>SCAS subtracts the memory byte or word at the destination register fromthe AL, AX or EAX register. The result is discarded; only the flags are set.The operand must be addressable from the ES segment; no segment override ispossible.<P>If the address-size attribute for this instruction is 16 bits, DI is usedas the destination register; otherwise, the address-size attribute is 32bits and EDI is used.<P>The address of the memory data being compared is determined solely by thecontents of the destination register, not by the operand to SCAS. Theoperand validates ES segment addressability and determines the data type.Load the correct index value into DI or EDI before executing SCAS.<P>After the comparison is made, the destination register is automaticallyupdated. If the direction flag is 0 (<A HREF="CLD.htm">CLD</A> was executed), the destinationregister is incremented; if the direction flag is 1 (<A HREF="STD.htm">STD</A> was executed), itis decremented. The increments or decrements are by 1 if bytes are compared,by 2 if words are compared, or by 4 if doublewords are compared.<P>SCASB, SCASW, and SCASD are synonyms for the byte, word anddoubleword SCAS instructions that don't require operands. They aresimpler to code, but provide no type or segment checking.<P>SCAS can be preceded by the <A HREF="REP.htm">REPE</A> or <A HREF="REP.htm">REPNE</A> prefix for a block searchof CX or ECX bytes or words. Refer to the <A HREF="REP.htm">REP</A> instruction for furtherdetails.<H2>Flags Affected</H2>OF, SF, ZF, AF, PF, and CF as described in <A HREF="appc.htm">Appendix C</A><H2>Protected Mode Exceptions</H2>#GP(0) for an illegal memory operand effective address in the CS, DS,ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment;#PF(fault-code) for a page fault<H2>Real Address Mode Exceptions</H2>Interrupt 13 if any part of the operand would lie outside of the effectiveaddress space from 0 to 0FFFFH<H2>Virtual 8086 Mode Exceptions</H2>Same exceptions as in Real Address Mode; #PF(fault-code) for a pagefault<P><HR><P><B>up:</B> <A HREF="c17.htm">Chapter 17 -- 80386 Instruction Set</A><BR><B>prev:</B><A HREF="SBB.htm"> SBB Integer Subtraction with Borrow</A><BR><B>next:</B><A HREF="SETcc.htm"> SETcc Byte Set on Condition</A></BODY>

⌨️ 快捷键说明

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