Arithmetic Instructions ICS312 Set 5 Arithmetic Instructions
Data Transfer Instructions MOV MOV destination, source destination operand can be register or memory operand. source operand can be register, memory, or immediate operand. source and destination operands cannot BOTH be memory operands. Examples: mov cx, ax mov account, 3
Arithmetic Instructions (ADD, SUB, INC, and DEC) ADD and SUB Instructions ADD destination, source SUB destination, source destination operand can be register or memory operand. source operand can be register, memory operand, or immediate source and destination operands cannot BOTH be memory operands. INC and DEC Instructions INC destination DEC destination Examples: inc ah dec ebx add number, 2
NEG Instruction NEG destination destination operand can be register or memory operand. Examples: neg di Note: Type Agreement of Operands The operands of two-operand instructions must be of the same type; that is both operands must be bytes, words, or double words
Translation of High-Level Language to Assembly Language Examples: Translate the following high-level language statements to assembly language: 1. B = A MOV AX, A MOV B, AX 2. A = 5 - A First method: MOV CX, 5 SUB CX, A MOV A, CX Second method: NEG A ADD A, 5 3. A = B - 2 * A MOV DX, A ADD DX, DX NEG DX ADD DX,B MOV A,DX
Textbook Reading (Jones): Section 4.1 Addition and Subtraction