Unformatted text preview: bit value to a 16bit value or an 8bit or 16bit value to a 32bit value by sign extending the source operand, as shown in Figure 75. The MOVZX instruction extends an 8bit value to a 16bit value or an 8bit or 16bit value to a 32bit value by zero extending the source operand. 7.3.1.7 Type Conversion Instructions in 64Bit Mode The MOVSXD instruction operates on 64bit data. It signextends a 32bit value to 64 bits. This instruction is not encodable in non64bit modes. 7.3.2 Binary Arithmetic Instructions Binary arithmetic instructions operate on 8, 16, and 32bit numeric data encoded as signed or unsigned binary integers. The binary arithmetic instructions may also be used in algorithms that operate on decimal (BCD) values.
710 Vol. 1 PROGRAMMING WITH GENERALPURPOSE INSTRUCTIONS For the purpose of this discussion, these instructions are divided subordinate subgroups of instructions that: Add and subtract Increment and decrement Compare and change signs Multiply and divide 7.3.2.1 Addition and Subtraction Instructions The ADD (add integers), ADC (add integers with carry), SUB (subtract integers), and SBB (subtract integers with borrow) instructions perform addition and subtraction operations 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 flag is 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 the CF flag is set. This instruction is used to propagate a borrow when subtracting numbers in stages. 7.3.2.2 Increment and Decrement Instructions The INC (increment) and DEC (decrement) instructions add 1 to or subtract 1 from an unsigned integer operand, respectively. A primary use of these instructions is for implementing counters. 7.3.2.3 Increment and Decrement Instructions in 64Bit Mode The INC and DEC instructions are supported in 64bit mode. However, some forms of INC and DEC (the register operand being encoded using register extension field in the MOD R/M byte) are not encodable in 64bit mode because the opcodes are treated as REX prefixes. 7.3.2.4 Comparison and Sign Change Instruction The 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. The source operands are not modified, nor is the result saved. The CMP instruction is commonly 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 a CMP instruction. Vol. 1 711 PROGRAMMING WITH GENERALPURPOSE INSTRUCTIONS The NEG (negate) instruction subtracts a signed integer operand from zero. The effect of the NEG instruction is to change the sign of a two's complement operand whil...
View
Full
Document
This note was uploaded on 10/01/2013 for the course CPE 103 taught by Professor Watlins during the Winter '11 term at Mississippi State.
 Winter '11
 Watlins

Click to edit the document details