Главная » Просмотр файлов » Volume 3 General-Purpose and System Instructions

Volume 3 General-Purpose and System Instructions (794097), страница 22

Файл №794097 Volume 3 General-Purpose and System Instructions (Intel and AMD manuals) 22 страницаVolume 3 General-Purpose and System Instructions (794097) страница 222019-04-28СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 22)

3.13—July 2007MnemonicAMD64 TechnologyOpcodeDescriptionCMP reg8, reg/mem83A /rCompare the contents of an 8-bit register with thecontents of an 8-bit register or memory operand.CMP reg16, reg/mem163B /rCompare the contents of a 16-bit register with thecontents of a 16-bit register or memory operand.CMP reg32, reg/mem323B /rCompare the contents of a 32-bit register with thecontents of a 32-bit register or memory operand.CMP reg64, reg/mem643B /rCompare the contents of a 64-bit register with thecontents of a 64-bit register or memory operand.When interpreting operands as unsigned, flag settings are as follows:OperandsCFZFdest > source00dest = source01dest < source10When interpreting operands as signed, flag settings are as follows:OperandsOFZFdest > sourceSF0dest = source01dest < sourceNOT SF0Related InstructionsSUB, CMPSx, SCASxInstruction ReferenceCMP95AMD64 Technology24594—Rev.

3.13—July 2007rFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFM2120191817161413–12111098SFZFAFPFCFMMMMM76420Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags areblank. Undefined flags are U.ExceptionsExceptionVirtualReal 8086 ProtectedCause of ExceptionStack, #SSXXXA memory address exceeded the stack segment limit or wasnon-canonical.General protection,#GPXXXA memory address exceeded a data segment limit or was noncanonical.XA null data segment was used to reference memory.Page fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.96CMPInstruction Reference24594—Rev.

3.13—July 2007AMD64 TechnologyCMPSCMPSBCMPSWCMPSDCMPSQCompare StringsCompares the bytes, words, doublewords, or quadwords pointed to by the rSI and rDI registers, sets orclears the status flags of the rFLAGS register to reflect the results, and then increments or decrementsthe rSI and rDI registers according to the state of the DF flag in the rFLAGS register. To perform thecomparison, the instruction subtracts the second operand from the first operand and sets the statusflags in the same manner as the SUB instruction, but does not alter the first operand.

The two operandsmust be the same size.If the DF flag is 0, the instruction increments rSI and rDI; otherwise, it decrements the pointers. Itincrements or decrements the pointers by 1, 2, 4, or 8, depending on the size of the operands.The forms of the CMPSx instruction with explicit operands address the first operand at seg:[rSI]. Thevalue of seg defaults to the DS segment, but may be overridden by a segment prefix. These instructionsalways address the second operand at ES:[rDI]. ES may not be overridden. The explicit operands serveonly to specify the type (size) of the values being compared and the segment used by the first operand.The no-operands forms of the instruction use the DS:[rSI] and ES:[rDI] registers to point to the valuesto be compared. The mnemonic determines the size of the operands.Do not confuse this CMPSD instruction with the same-mnemonic CMPSD (compare scalar doubleprecision floating-point) instruction in the 128-bit media instruction set.

Assemblers can distinguishthe instructions by the number and type of operands.For block comparisons, the CMPS instruction supports the REPE or REPZ prefixes (they aresynonyms) and the REPNE or REPNZ prefixes (they are synonyms). For details about the REPprefixes, see “Repeat Prefixes” on page 9. If a conditional jump instruction like JL follows a CMPSxinstruction, the jump occurs if the value of the seg:[rSI] operand is less than the ES:[rDI] operand.

Thisaction allows lexicographical comparisons of string or array elements. A CMPSx instruction can alsooperate inside a loop controlled by the LOOPcc instruction.MnemonicOpcodeDescriptionCMPS mem8, mem8A6Compare the byte at DS:rSI with the byte at ES:rDI andthen increment or decrement rSI and rDI.CMPS mem16, mem16A7Compare the word at DS:rSI with the word at ES:rDI andthen increment or decrement rSI and rDI.CMPS mem32, mem32A7Compare the doubleword at DS:rSI with the doublewordat ES:rDI and then increment or decrement rSI and rDI.CMPS mem64, mem64A7Compare the quadword at DS:rSI with the quadword atES:rDI and then increment or decrement rSI and rDI.Instruction ReferenceCMPSx97AMD64 Technology24594—Rev. 3.13—July 2007MnemonicOpcodeDescriptionCMPSBA6Compare the byte at DS:rSI with the byte at ES:rDI andthen increment or decrement rSI and rDI.CMPSWA7Compare the word at DS:rSI with the word at ES:rDI andthen increment or decrement rSI and rDI.CMPSDA7Compare the doubleword at DS:rSI with the doublewordat ES:rDI and then increment or decrement rSI and rDI.CMPSQA7Compare the quadword at DS:rSI with the quadword atES:rDI and then increment or decrement rSI and rDI.Related InstructionsCMP, SCASxrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFM2120191817161413–12111098SFZFAFPFCFMMMMM76420Note: Bits 31–22, 15, 5, 3, and 1 are reserved.

A flag set to 1 or cleared to 0 is M (modified). Unaffected flags are blank.Undefined flags are U.ExceptionsExceptionVirtualReal 8086 ProtectedCause of ExceptionStack, #SSXXXA memory address exceeded the stack segment limit or wasnon-canonical.General protection,#GPXXXA memory address exceeded a data segment limit or was noncanonical.XA null data segment was used to reference memory.Page fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.98CMPSxInstruction Reference24594—Rev.

3.13—July 2007AMD64 TechnologyCMPXCHGCompare and ExchangeCompares the value in the AL, AX, EAX, or RAX register with the value in a register or a memorylocation (first operand). If the two values are equal, the instruction copies the value in the secondoperand to the first operand and sets the ZF flag in the rFLAGS register to 1. Otherwise, it copies thevalue in the first operand to the AL, AX, EAX, or RAX register and clears the ZF flag to 0.The OF, SF, AF, PF, and CF flags are set to reflect the results of the compare.When the first operand is a memory operand, CMPXCHG always does a read-modify-write on thememory operand.

If the compared operands were unequal, CMPXCHG writes the same value to thememory operand that was read.The forms of the CMPXCHG instruction that write to memory support the LOCK prefix. For detailsabout the LOCK prefix, see “Lock Prefix” on page 8.MnemonicOpcodeDescriptionCMPXCHG reg/mem8, reg80F B0 /rCompare AL register with an 8-bit register or memorylocation.

If equal, copy the second operand to the firstoperand. Otherwise, copy the first operand to AL.CMPXCHG reg/mem16, reg160F B1 /rCompare AX register with a 16-bit register or memorylocation. If equal, copy the second operand to the firstoperand. Otherwise, copy the first operand to AX.CMPXCHG reg/mem32, reg320F B1 /rCompare EAX register with a 32-bit register or memorylocation. If equal, copy the second operand to the firstoperand. Otherwise, copy the first operand to EAX.CMPXCHG reg/mem64, reg640F B1 /rCompare RAX register with a 64-bit register or memorylocation.

If equal, copy the second operand to the firstoperand. Otherwise, copy the first operand to RAX.Related InstructionsCMPXCHG8B, CMPXCHG16BInstruction ReferenceCMPXCHG99AMD64 Technology24594—Rev. 3.13—July 2007rFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFM2120191817161413–12111098SFZFAFPFCFMMMMM76420Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified).

Unaffected flags areblank. Undefined flags are U.ExceptionsExceptionStack, #SSVirtualReal 8086 ProtectedCause of ExceptionXXXA memory address exceeded the stack segment limit or wasnon-canonical.XXXA memory address exceeded a data segment limit or was noncanonical.XThe destination operand was in a non-writable segment.XA null data segment was used to reference memory.General protection,#GPPage fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.100CMPXCHGInstruction Reference24594—Rev.

3.13—July 2007AMD64 TechnologyCMPXCHG8BCMPXCHG16BCompare and Exchange Eight BytesCompare and Exchange Sixteen BytesCompares the value in the rDX:rAX registers with a 64-bit or 128-bit value in the specified memorylocation. If the values are equal, the instruction copies the value in the rCX:rBX registers to thememory location and sets the zero flag (ZF) of the rFLAGS register to 1. Otherwise, it copies the valuein memory to the rDX:rAX registers and clears ZF to 0.If the effective operand size is 16-bit or 32-bit, the CMPXCHG8B instruction is used.

This instructionuses the EDX:EAX and ECX:EBX register operands and a 64-bit memory operand. If the effectiveoperand size is 64-bit, the CMPXCHG16B instruction is used; this instruction uses RDX:RAX andRCX:RBX register operands and a 128-bit memory operand.The CMPXCHG8B and CMPXCHG16B instructions always do a read-modify-write on the memoryoperand. If the compared operands were unequal, the instructions write the same value to the memoryoperand that was read.The CMPXCHG8B and CMPXCHG16B instructions support the LOCK prefix.

For details about theLOCK prefix, see “Lock Prefix” on page 8.Support for the CMPXCHG8B and CMPXCHG16B instructions depends on the processorimplementation. To find out if a processor can execute the CMPXCHG8B instruction, use the CPUIDinstruction to determine whether EDX bit 8 of CPUID function 0000_0001h or function 8000_0001his set to 1. To find out if a processor can execute the CMPXCHG16B instruction, use the CPUIDinstruction to determine whether ECX bit 13 of CPUID function 0000_0001h is set to 1.The memory operand used by CMPXCHG16B must be 16-byte aligned or else a general-protectionexception is generated.MnemonicCMPXCHG8B mem64CMPXCHG16B mem128OpcodeDescription0F C7 /1 m64Compare EDX:EAX register to 64-bit memory location.If equal, set the zero flag (ZF) to 1 and copy theECX:EBX register to the memory location.

Характеристики

Тип файла
PDF-файл
Размер
1,98 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Почему делать на заказ в разы дороже, чем купить готовую учебную работу на СтудИзбе? Наши учебные работы продаются каждый год, тогда как большинство заказов выполняются с нуля. Найдите подходящий учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6392
Авторов
на СтудИзбе
307
Средний доход
с одного платного файла
Обучение Подробнее