Arithmetic Instructions
Introduction
This article defines arithmetic instructions as executed by x86 processors. It goes on to describe in brief, four key classifications of arithmetic instructions: addition, subtraction, multiplication and division.
This article is designed for students and professionals who want to gain detailed understanding of arithmetic instructions, their classifications and how they’re used. Through the use of an 8086-emulator, this article will give you a better understanding of arithmetic instructions, its syntax and in some cases memory flow during execution.
Arithmetic instructions in x86
The arithmetic instructions define the set of operations performed by the processor Arithmetic Logic Unit (ALU). This article will discuss only the four key operations of arithmetic instructions.
Integers in x86
Integers used during arithmetic operations in x86 may be represented in two modes: unsigned and signed. Unsigned integers are always positive or zero. Signed integers can be either positive or negative.
ADD
The add instruction sums up the contents of the source operand (second operand) and the destination operand (first operand) and then places the results in the source operand.
Basic format
ADD destination,source
destination := destination + source
Example 1
- ADD AX, 0120H ; Add the hex value 120 to value in the accumulator and keep the sum in the accumulator
- ADD AX, CX ; Add the values in registers CX and AX. Keep the sum in the accumulator
- ADD AX, [DI] ; Add the value at address given by the destination index DI to the register AX. Keep the value in the accumulator
- ADD AX, [5777H] ; Add the value at address 5777 to the accumulator. Keep the sum in the accumulator
- ADD [5777H], 0100H ; Add the hex value 100 to the value at address given by 5777. Keep the sum in the address 5777
Figure 1: Contents of (Read more...)
*** This is a Security Bloggers Network syndicated blog from Infosec Resources authored by Richard Azu. Read the original post at: http://feedproxy.google.com/~r/infosecResources/~3/mro6lUFwGhM/