Главная » Просмотр файлов » Volume 1 Basic Architecture

Volume 1 Basic Architecture (794100), страница 44

Файл №794100 Volume 1 Basic Architecture (Intel and AMD manuals) 44 страницаVolume 1 Basic Architecture (794100) страница 442019-04-28СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

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

Operation of the POPA Instruction7.3.1.5Stack Manipulation Instructions in 64-Bit ModeIn 64-bit mode, the stack pointer size is 64 bits and cannot be overridden by aninstruction prefix. In implicit stack references, address-size overrides are ignored.Pushes and pops of 32-bit values on the stack are not possible in 64-bit mode. 16-bitVol. 1 7-9PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONSpushes and pops are supported by using the 66H operand-size prefix.

PUSHA,PUSHAD, POPA, and POPAD are not supported.7.3.1.6Type Conversion InstructionsThe type conversion instructions convert bytes into words, words into doublewords,and doublewords into quadwords. These instructions are especially useful forconverting integers to larger integer formats, because they perform sign extension(see Figure 7-5).Two kinds of type conversion instructions are provided: simple conversion and moveand convert.7-10 Vol. 1PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS150S N N N N N N N N N N N N N N N3115Before SignExtension0S S S S S S S S S S S S S S S S S N N N N N N N N N N N N N N NAfter SignExtensionFigure 7-5.

Sign ExtensionSimple conversion — The CBW (convert byte to word), CWDE (convert word todoubleword extended), CWD (convert word to doubleword), and CDQ (convertdoubleword to quadword) instructions perform sign extension to double the size ofthe source operand.The CBW instruction copies the sign (bit 7) of the byte in the AL register into every bitposition of the upper byte of the AX register. The CWDE instruction copies the sign(bit 15) of the word in the AX register into every bit position of the high word of theEAX register.The CWD instruction copies the sign (bit 15) of the word in the AX register into everybit position in the DX register. The CDQ instruction copies the sign (bit 31) of thedoubleword in the EAX register into every bit position in the EDX register.

The CWDinstruction can be used to produce a doubleword dividend from a word before a worddivision, and the CDQ instruction can be used to produce a quadword dividend froma doubleword before doubleword division.Move with sign or zero extension — The MOVSX (move with sign extension) andMOVZX (move with zero extension) instructions move the source operand into aregister then perform the sign extension.The MOVSX instruction extends an 8-bit value to a 16-bit value or an 8-bit or 16-bitvalue to a 32-bit value by sign extending the source operand, as shown in Figure 7-5.The MOVZX instruction extends an 8-bit value to a 16-bit value or an 8-bit or 16-bitvalue to a 32-bit value by zero extending the source operand.7.3.1.7Type Conversion Instructions in 64-Bit ModeThe MOVSXD instruction operates on 64-bit data.

It sign-extends a 32-bit value to 64bits. This instruction is not encodable in non-64-bit modes.Vol. 1 7-11PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS7.3.2Binary Arithmetic InstructionsBinary arithmetic instructions operate on 8-, 16-, and 32-bit numeric data encodedas signed or unsigned binary integers. The binary arithmetic instructions may also beused in algorithms that operate on decimal (BCD) values.For the purpose of this discussion, these instructions are divided subordinatesubgroups of instructions that:••••Add and subtractIncrement and decrementCompare and change signsMultiply and divide7.3.2.1Addition and Subtraction InstructionsThe ADD (add integers), ADC (add integers with carry), SUB (subtract integers), andSBB (subtract integers with borrow) instructions perform addition and subtractionoperations on signed or unsigned integer operands.The ADD instruction computes the sum of two integer operands.The ADC instruction computes the sum of two integer operands, plus 1 if the CF flagis set.

This instruction is used to propagate a carry when adding numbers in stages.The SUB instruction computes the difference of two integer operands.The SBB instruction computes the difference of two integer operands, minus 1 if theCF flag is set. This instruction is used to propagate a borrow when subtractingnumbers in stages.7.3.2.2Increment and Decrement InstructionsThe INC (increment) and DEC (decrement) instructions add 1 to or subtract 1 froman unsigned integer operand, respectively. A primary use of these instructions is forimplementing counters.7.3.2.3Increment and Decrement Instructions in 64-Bit ModeThe INC and DEC instructions are supported in 64-bit mode.

However, some forms ofINC and DEC (the register operand being encoded using register extension field inthe MOD R/M byte) are not encodable in 64-bit mode because the opcodes aretreated as REX prefixes.7.3.2.4Comparison and Sign Change InstructionThe CMP (compare) instruction computes the difference between two integer operands and updates the OF, SF, ZF, AF, PF, and CF flags according to the result. The7-12 Vol.

1PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONSsource operands are not modified, nor is the result saved. The CMP instruction iscommonly used in conjunction with a Jcc (jump) or SETcc (byte set on condition)instruction, with the latter instructions performing an action based on the result of aCMP instruction.The NEG (negate) instruction subtracts a signed integer operand from zero. Theeffect of the NEG instruction is to change the sign of a two's complement operandwhile keeping its magnitude.7.3.2.5Multiplication and Divide InstructionsThe processor provides two multiply instructions, MUL (unsigned multiply) and IMULsigned multiply), and two divide instructions, DIV (unsigned divide) and IDIV (signeddivide).The MUL instruction multiplies two unsigned integer operands.

The result iscomputed to twice the size of the source operands (for example, if word operands arebeing multiplied, the result is a doubleword).The IMUL instruction multiplies two signed integer operands. The result is computedto twice the size of the source operands; however, in some cases the result is truncated to the size of the source operands (see “IMUL—Signed Multiply” in Chapter 3,“Instruction Set Reference, A-M,” of the Intel® 64 and IA-32 Architectures SoftwareDeveloper’s Manual, Volume 3A).The DIV instruction divides one unsigned operand by another unsigned operand andreturns a quotient and a remainder.The IDIV instruction is identical to the DIV instruction, except that IDIV performs asigned division.7.3.3Decimal Arithmetic InstructionsDecimal arithmetic can be performed by combining the binary arithmetic instructionsADD, SUB, MUL, and DIV (discussed in Section 7.3.2, “Binary Arithmetic Instructions”) with the decimal arithmetic instructions.

The decimal arithmetic instructionsare provided to carry out the following operations:•To adjust the results of a previous binary arithmetic operation to produce a validBCD result.•To adjust the operands of a subsequent binary arithmetic operation so that theoperation will produce a valid BCD result.These instructions operate on both packed and unpacked BCD values. For thepurpose of this discussion, the decimal arithmetic instructions are divided subordinate subgroups of instructions that provide:••Packed BCD adjustmentsUnpacked BCD adjustmentsVol.

1 7-13PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS7.3.3.1Packed BCD Adjustment InstructionsThe DAA (decimal adjust after addition) and DAS (decimal adjust after subtraction)instructions adjust the results of operations performed on packed BCD integers(see Section 4.7, “BCD and Packed BCD Integers”).

Adding two packed BCD valuesrequires two instructions: an ADD instruction followed by a DAA instruction. The ADDinstruction adds (binary addition) the two values and stores the result in the ALregister. The DAA instruction then adjusts the value in the AL register to obtain avalid, 2-digit, packed BCD value and sets the CF flag if a decimal carry occurred asthe result of the addition.Likewise, subtracting one packed BCD value from another requires a SUB instructionfollowed by a DAS instruction. The SUB instruction subtracts (binary subtraction) oneBCD value from another and stores the result in the AL register.

The DAS instructionthen adjusts the value in the AL register to obtain a valid, 2-digit, packed BCD valueand sets the CF flag if a decimal borrow occurred as the result of the subtraction.7.3.3.2Unpacked BCD Adjustment InstructionsThe AAA (ASCII adjust after addition), AAS (ASCII adjust after subtraction), AAM(ASCII adjust after multiplication), and AAD (ASCII adjust before division) instructions adjust the results of arithmetic operations performed in unpacked BCDvalues (see Section 4.7, “BCD and Packed BCD Integers”). All these instructionsassume that the value to be adjusted is stored in the AL register or, in one instance,the AL and AH registers.The AAA instruction adjusts the contents of the AL register following the addition oftwo unpacked BCD values. It converts the binary value in the AL register into adecimal value and stores the result in the AL register in unpacked BCD format (thedecimal number is stored in the lower 4 bits of the register and the upper 4 bits arecleared).

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

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

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

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