12.5 Intel x86 and ARM Operation Types
COS2621 - Computer Organisation · 12. Instruction Sets: Characteristics and Functions
Intel x86 and ARM Operation Types
Overview of Operation Types
Operation types in computer architecture define how instructions manipulate data. The Intel x86 and ARM architectures support various operation types, including arithmetic, logical, data transfer, and control operations. Understanding these operations is crucial for effective programming and system design.
Arithmetic Operations
Arithmetic operations perform mathematical calculations on operands. Common operations include addition, subtraction, multiplication, and division. For example, consider the instruction for multiplication in Intel x86:
MUL AL, 6This instruction multiplies the value in the AL register by 6. If AL contains the value 4, the multiplication results in:
AL = 4
Product = 4 × 6 = 24, stored in AXRemember: The product of the MUL instruction is stored in AX when multiplying AL by an 8-bit source operand.
Logical Operations
Logical operations manipulate binary data. These include AND, OR, NOT, and XOR operations. For instance, the following instruction demonstrates a logical AND operation:
AND AL, 0AhThis instruction performs a logical AND on the value in AL with 0Ah. If AL originally contains 00001100, after the AND operation, it will contain 00001100.
Watch out: Ensure you understand the difference between logical and arithmetic operations. Confusing these can lead to incorrect program behaviour.
Data Transfer Operations
Data transfer operations move data between registers, memory, and I/O devices. Common instructions include MOV, PUSH, and POP. For example, the MOV instruction is used to transfer data:
MOV AX, 3BhThis instruction moves the hexadecimal value 3B into the AX register.
Control Operations
Control operations manage the flow of execution in programs. They include jumps, calls, and returns. For example:
JMP labelThis instruction causes the execution to jump to the specified label.
Comparison Operations
Comparison operations assess the relative values of operands. For example:
CMP AX, BXThis instruction compares the values in AX and BX, setting the flags accordingly for subsequent conditional operations.
Flags and Their Effects
Various instructions affect the processor flags. For instance, the STC instruction sets the carry flag (CF) to 1:
STCThis indicates a carry in arithmetic operations. Similarly, the STD instruction sets the direction flag (DF) to 1, which causes string operations to process strings from right to left:
STDTip: The STD instruction sets the DF flag to 1, causing string operations to process strings from right to left.
Example: Combining Operations
Consider a simple program that adds two numbers and checks if the result is greater than a threshold:
MOV AX, 8
MOV BX, 7
ADD AX, BX
CMP AX, 15
JG greater_thanThis program adds 8 and 7, compares the result (15) with 15, and jumps to the label greater_than if the result is greater.
Bitwise Rotation and Shifting
Operations such as ROL (rotate left) and ROR (rotate right) are crucial for manipulating data at the bit level. For example:
ROL AL, 1This instruction rotates the bits in AL to the left by one position. If AL starts as 1101 0110, after ROL, it becomes 1010 1101.
Watch out: The ROR instruction affects the Carry Flag (CF), which is important for understanding how data flows in arithmetic operations.
Conclusion
Understanding operation types and their effects on processor flags is essential for effective assembly language programming. Mastery of these concepts will aid in debugging and optimising code.
Check your understanding
- What is the result of the ROL instruction when the destination operand is 1101 0110 and the source operand specifies a single rotation?
- Which flag is affected by the ROR instruction?
- What happens to the most significant bit during a SAR operation?
- In the SBB instruction, what is subtracted from the destination operand?
Test yourself
5 quick questions on this lesson. Pick an answer to see if you're right.
1. What is the effect of the STC instruction?
2. What does the MOV instruction do in Intel x86 architecture?
3. What is the effect of the STD instruction on string operations?
4. Which instruction would you use to compare the values in two registers in Intel x86?
5. What does the NOT instruction do to an operand?