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

Volume 1 Application Programming (794095), страница 62

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

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

For example, FADDP (floating-point add and pop) behaves exactly likeFADD (floating-point add), except that it pops the stack after completion. Programs that use the x87registers as a flat register file rather than as a stack would use non-popping versions of instructions toensure that the TOP remains unchanged.

However, loads (pushes) without corresponding pops cancause the stack to overflow, which occurs when a value is pushed or loaded into an x87 register that is240x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 Technologynot empty (as indicated by the register’s tag bits). To prevent overflow, the FXCH (floating-pointexchange) instruction can be used to access stack registers, giving the appearance of a flat register file,but all x87 programs must be aware of the register file’s stack organization.The FINCSTP and FDECSTP instructions can be used to increment and decrement, respectively, theTOP, modulo-8, allowing the stack top to wrap around to the bottom of the eight-register file whenincremented beyond the top of the file, or to wrap around to the top of the register file whendecremented beyond the bottom of the file.

Neither the x87 tag word nor the contents of the floatingpoint stack itself is updated when these instructions are used.6.2.2 x87 Status Word Register (FSW)The 16-bit x87 status word register contains information about the state of the floating-point unit,including the top-of-stack pointer (TOP), four condition-code bits, exception-summary flag, stackfault flag, and six x87 floating-point exception flags. Figure 6-3 on page 242 shows the format of thisregister. All bits can be read and written, however values written to the B and ES bits (bits 15 and 7) areignored.The FRSTOR and FXRSTOR instructions load the status word from memory.

The FSTSW, FNSTSW,FSAVE, FNSAVE, FXSAVE, FSTENV, and FNSTENV instructions store the status word to memory.The FCLEX and FNCLEX instructions clear the exception flags. The FINIT and FNINIT instructionsclear all bits in the status-word.x87 Floating-Point Programming241AMD64 Technology24592—Rev. 3.13—July 200715 14 13 12 11 10 9C3BTOP765C C C E2 1 0 SSFP U O Z D IE E E E E EBitsMnemonic1514BC3TOP13–111098765C2C1C0ESSF1PEUEOEZEDE0IE432843210Descriptionx87 Floating-Point Unit BusyCondition CodeTop of Stack Pointer000 = FPR0111 = FPR7Condition CodeCondition CodeCondition CodeException StatusStack FaultException FlagsPrecision ExceptionUnderflow ExceptionOverflow ExceptionZero-Divide ExceptionDenormalized-OperandExceptionInvalid-Operation ExceptionFigure 6-3.

x87 Status Word Register (FSW)The bits in the x87 status word are defined immediately below, starting with bit 0. The six exceptionflags (IE, DE, ZE, OE, UE, PE) plus the stack fault (SF) flag are sticky bits. Once set by the processor,such a bit remains set until software clears it. For details about the causes of x87 exceptions indicatedby bits 6–0, see “x87 Floating-Point Exception Causes” on page 280.

For details about the masking ofx87 exceptions, see “x87 Floating-Point Exception Masking” on page 284.Invalid-Operation Exception (IE). Bit 0. The processor sets this bit to 1 when an invalid-operationexception occurs. These exceptions are caused by many types of errors, such as an invalid operand orby stack faults. When a stack fault causes an IE exception, the stack fault (SF) exception bit is also set.Denormalized-Operand Exception (DE). Bit 1.

The processor sets this bit to 1 when one of thesource operands of an instruction is in denormalized form. (See “Denormalized (Tiny) Numbers” onpage 255.)Zero-Divide Exception (ZE). Bit 2. The processor sets this bit to 1 when a non-zero number isdivided by zero.242x87 Floating-Point Programming24592—Rev. 3.13—July 2007AMD64 TechnologyOverflow Exception (OE). Bit 3. The processor sets this bit to 1 when the absolute value of arounded result is larger than the largest representable normalized floating-point number for thedestination format. (See “Normalized Numbers” on page 255.)Underflow Exception (UE). Bit 4. The processor sets this bit to 1 when the absolute value of arounded non-zero result is too small to be represented as a normalized floating-point number for thedestination format.

(See “Normalized Numbers” on page 255.)The underflow exception has an unusual behavior. When masked by the UM bit (bit 4 of the x87control word), the processor only reports a UE exception if the UE occurs together with a precisionexception (PE).Precision Exception (PE). Bit 5. The processor sets this bit to 1 when a floating-point result, afterrounding, differs from the infinitely precise result and thus cannot be represented exactly in thespecified destination format.

The PE exception is also called the inexact-result exception.Stack Fault (SF). Bit 6. The processor sets this bit to 1 when a stack overflow (due to a push or loadinto a non-empty stack register) or stack underflow (due to referencing an empty stack register) occursin the x87 stack-register file.

When either of these conditions occur, the processor also sets the invalidoperation exception (IE) flag, and the processor distinguishes overflow from underflow by writing thecondition-code 1 (C1) bit (C1 = 1 for overflow, C1 = 0 for underflow). Unlike the flags for the otherx87 exceptions, the SF flag does not have a corresponding mask bit in the x87 control word.If, subsequent to the instruction that caused the SF bit to be set, a second invalid-operation exception(IE) occurs due to an invalid operand in an arithmetic instruction (i.e., not a stack fault), and if softwarehas not cleared the SF bit between the two instructions, the SF bit will remain set.Exception Status (ES). Bit 7.

The processor calculates the value of this bit at each instructionboundary and sets the bit to 1 when one or more unmasked floating-point exceptions occur. If the ESbit has already been set by the action of some prior instruction, the processor invokes the #MFexception handler when the next non-control x87 or 64-bit media instruction is executed. (See“Control” on page 274 for a definition of control instructions).The ES bit can be written, but the written value is ignored. Like the SF bit, the ES bit does not have acorresponding mask bit in the x87 control word.Top-of-Stack Pointer (TOP). Bits 13–11.

The TOP contains the physical register index of thelocation of the top of stack, ST(0). It thus specifies the mapping of the x87 stack registers,ST(0)–ST(7), onto the x87 physical registers, FPR0–FPR7. The processor changes the TOP during anyinstructions that pushes or pops the stack. For details on how the stack works, see “StackOrganization” on page 240.Condition Codes (C3–C0).

Bits 14 and 10–8. The processor sets these bits according to the result ofarithmetic, compare, and other instructions. In certain cases, other status-word flags can be usedtogether with the condition codes to determine the result of an operation, including stack overflow,stack underflow, sign, least-significant quotient bits, last-rounding direction, and out-of-rangex87 Floating-Point Programming243AMD64 Technology24592—Rev.

3.13—July 2007operand. For details on how each instruction sets the condition codes, see “x87 Floating-PointInstruction Reference” in Volume 5.x87 Floating-Point Unit Busy (B). Bit 15. The processor sets the value of this bit equal to thecalculated value of the ES bit, bit 7. This bit can be written, but the written value is ignored. The bit isincluded only for backward-compatibility with the 8087 coprocessor, in which it indicates that thecoprocessor is busy.For further details about the x87 floating-point exceptions, see “x87 Floating-Point Exception Causes”on page 280.6.2.3 x87 Control Word Register (FCW)The 16-bit x87 control word register allows software to manage certain x87 processing options,including rounding, precision, and masking of the six x87 floating-point exceptions (any of which isreported as an #MF exception).

Figure 6-4 shows the format of the control word. All bits, exceptreserved bits, can be read and written.The FLDCW, FRSTOR, and FXRSTOR instructions load the control word from memory. TheFSTCW, FNSTCW, FSAVE, FNSAVE, and FXSAVE instructions store the control word to memory.The FINIT and FNINIT instructions initialize the control word with the value 037Fh, which specifiesround-to-nearest, all exceptions masked, and double-extended precision (64-bit).15 14 13 12 11 10 9YBitsMnemonic12YRCPCESSF11–109–876543210PMUMOMZMDMIMFigure 6-4.244RC8PC76res543210P U O Z D IM M M M M MDescriptionInfinity Bit (80287 compatibility)Rounding ControlPrecision ControlException StatusStack Fault#MF Exception MasksPrecision Exception MaskUnderflow Exception MaskOverflow Exception MaskZero-Divide Exception MaskDenormalized-Operand Exception MaskInvalid-Operation Exception Maskx87 Control Word Register (FCW)x87 Floating-Point Programming24592—Rev.

3.13—July 2007AMD64 TechnologyStarting from bit 0, the bits are:Exception Masks (PM, UM, OM, ZM, DM, IM). Bits 5–0. Software can set these bits to mask, orclear these bits to unmask, the corresponding six types of x87 floating-point exceptions (PE, UE, OE,ZE, DE, IE), which are reported in the x87 status word as described in “x87 Status Word Register(FSW)” on page 241. A bit masks its exception type when set to 1, and unmasks it when cleared to 0.Masking a type of exception causes the processor to handle all subsequent instances of the exceptiontype in a default way.

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

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

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

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