Daily Lesson (3/75) arithmetic operation instruction

Source: Internet
Author: User
Arithmetic Operation commands are commands that reflect the computing power of the CPU. They are also the most commonly used commands in programming, including addition, subtraction, multiplication, division, and other auxiliary commands.

The operand of this group of commands can be 8-bit, 16-bit, 32-bit (80386 +). When the storage unit is the operand of this class of commands, the addressing method of this operand can be the addressing method of any storage unit.

1. Addition command

Add REG/MEM, Reg/MEM/Imm-addition command
Affected flag: af cf of PF SF ZF
Function: adds the value of the source operand to the target operand.

Inc reg/MEM
Affected signs: AF, of, PF, SF, and ZF, without affecting cf
Function: adds the operand value to 1.

Adc reg/MEM, Reg/MEM/Imm-incoming bit addition command (Rarely used)
Affected flag: af cf of PF SF ZF
Function: adds the source operand and the CF value of the incoming flag to the destination operand.

Xadd REG/MEM Reg (rarely used)
Affected flag: af cf of PF SF ZF
Function: exchanges two operands and then performs addition operations.

The ADC and xadd of the preceding commands are compiled in standard VC ++.Code.

2. subtraction commands

Sub REG/MEM/IMM
Affected flag: af cf of PF SF ZF
Function: subtract the value of the source operand from the destination operand.

Dec REG/MEM
Affected signs: AF, of, PF, SF, and ZF, without affecting cf
Function: returns the operand value-1.

Sbb reg/MEM/IMM
Affected flag: af cf of PF SF ZF
Function: subtract the CF value of the source operand and the inbound flag from the destination operand.

Neg REG/MEM
Affected flag: af cf of PF SF ZF
Function: operand = 0-operand, which changes the positive and negative numbers of the operand.

3. Multiplication command

Computer multiplication commands can be divided into two types: Unsigned commands and signed commands. The difference is that the highest bit of a value is used as a "value" for calculation or as a "symbol" for calculation.

The multiplier of the multiplication command is usedImplicit operand, The multiplier is displayed in the command. The CPU will automatically select the multiplier based on the 8-bit, 16-bit, and 32-bit multiplier:Al, ax or eax.The function of a command is to multiply the display operand and the hidden operand, and store the product to Al, ax, or eax. (Currently, more than 80386 use eax as the multiplier)

Mul/fmul REG/mem-unsigned integer/floating point multiplication command
Affected signs: CF and
Function: multiply the displayed and hidden operands as unsigned numbers. For example, mul 5 is eax = eax * 5.

Imul/fimul REG/mem-signed integer/floating point multiplication command
Imul/fimul Reg, Imm
Imul/fimul Reg, Mem
Function: multiply two operands by a signed number.

4. Division commands

Div, division command of the unsigned number, same as 8086,
The command returns an operand, which is the default value. If the operand given in the instruction is 32-bit, the divisor will be edX: eax, and the final operator will be stored in eax,
The remainder is stored in EDX. If the number of operations provided by the command is 16 bits, the divisor is eax, and the resulting operator is placed in ax, and the remainder is placed in 16 bits of eax. If the operand given in the instruction is 8
If the divisor is 16 bits, the final operator will be placed in Al, and the remainder will be placed in AH.

Idiv, a division command with a symbolic number. Its usage is the same as that of 8086, but 32-bit operations are supported.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.