You are on page 1of 25

tulisnota.blogspot.

com

ASSEMBLY LANGUAGE
PROGRAMMING
Data Transfer Instruction, Logic Instruction, Arithmetic Instruction

tulisnota.blogspot.com

DATA TRANSFER INSTRUCTION


It

provide to move data either between its internal register or between an internal register and a storage location in memory

tulisnota.blogspot.com

DATA TRANSFER INSTRUCTION (CONT.)


1.

2.

3.

Move byte / word (MOV) Example: MOV DX, CS move the contents of CS into DX Exchange byte / word (XCHG) Example: XCHG AX, DX exchange the contents of the AX and DX Translate byte (XLAT)

tulisnota.blogspot.com

DATA TRANSFER INSTRUCTION (CONT.)


4.

5.

6.

Load effective address (LEA) Example: LEA SI, EA load SI register with an offset address value Load data segment (LDS) Example: LDS SI, [200H] Load extra segment (LES)

tulisnota.blogspot.com

LOGIC INSTRUCTION

It has instruction for performing the logic

operation AND, OR, Exclusive-OR and NOT Example: AND AX, BX causes the contents of BX to be ANDed with the contents of AX. The result is reflected by new content of AX

tulisnota.blogspot.com

LOGIC INSTRUCTION (CONT.)


For

instant, if AX contains 1234H and BX contains 000FH, the results is 1234H 000FH = 0004H The result is stored in destination operand AX = 0004H

tulisnota.blogspot.com

LOGIC INSTRUCTION (CONT.)


Table

of logic instruction
Meaning Logical AND Logical OR Logical NOT Format AND D, S OR D, S NOT D Operation (S) (D) = (D) (S) + (D) = (D) (S) (D) = (D) (D) = (D)

Mnemonic AND OR XOR NOT

Logical Exclusive-OR XOR D, S

tulisnota.blogspot.com

LOGIC INSTRUCTION (CONT.)


Example:

MOV AL, 0101 0101 B AND AL, 0001 1111 B OR AL, 1100 0000 B XOR AL, 0000 1111 B NOT AL

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION
1.

Addition Register addition


Instruction ADD AL, BX ADD CX, DI Comment AL becomes the sum of AL + BL CX becomes the sum of CX + DI

Immediate addition
Comment BL become sum of BL + 44H

Instruction ADD BL, 44

ADD BX, 35AF BX becomes the sum of BX + 35AFH

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


1.

Addition (cont.)
Comment The data segment memory byte addressed by BX becomes the sum of the data segment memory byte addressed by BX + AL CL becomes the sum of the stack segment byte addressed by BP + CL

Instruction ADD [BX], AL

ADD CL, [BP]

ADD BX, [SI + 2] BX becomes the sum of the data segment word addressed by SI + 2, plus contents of BX

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


1.

Addition (cont.)
Comment CL becomes the sum of CL plus the data segment byte TEMP BX becomes the sum of BX plus the contents of the data segment array TEMP plus offset DI The data segment memory byte addressed by BX + DI becomes the sum of that byte plus DL

Instruction ADD CL, TEMP ADD BX, TEMP[DI]

ADD [BX + DI], DL

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


1.

Addition (cont.) Example: MOV DL, 12 ADD DL, 33

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


2.

Subtraction Register subtraction


Instruction ADD CL, BL ADD AX, SP Comment CL becomes the difference of CL BL AX becomes the difference of AX SP

Immediate subtraction
Comment

Instruction

ADD DH, 6F ADD AX, CCCC

DH become difference of DH 6FH BX becomes the difference of AX - CCCCH

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


2.

Subtraction (cont.) Subtraction with borrow


Instruction SBB AH, AL SBB AX, BX SBB CL, 3 SBB [DI], AL Comment AH becomes the difference of AH Al carry AX becomes the difference of AX BX carry CL becomes the difference of CL 3 carry The data segment byte addressed by DI becomes the difference of that byte minus Al carry

SBB DI, [BP + 2] DI becomes the difference of the stack segment word addressed by BP + 2 and the contents of both the DI register and carry

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


2.

Subtraction (cont.) Subtraction (others)


Instruction SUB [DI], CH Comment The data segment memory byte addressed by DI becomes the difference of the data segment memory byte addressed by DI CH. CH becomes the difference of the stack segment memory byte by BP CH.

SUB CH, [BP]

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


2.

Subtraction (cont.) Subtraction (others)


Instruction SUB AH, TEMP Comment AH becomes the difference of AH minus the contents of memory byte TEMP located in the data segment DI becomes the difference of DI minus the contents of data segments array TEMP plus offset BX

SUB DI, TEMP[BX]

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


2.

Subtraction (cont.) Example: MOV CH, 22 SUB CH, 44

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


3.

Multiplication 8 bit multiplication


Instruction MUL CL IMUL DH MUL BYTE PTR[BX] MUL TEMP Comment The unsigned number in AL is multiplied by CL; the product is found in AX The signed number in AL is multiplied by DH; the product is found in AX The signed number in AL multiplied by the byte stored in data segment at the address indexed by BX; the product is found in AX The unsigned number in AL is multiplied by 8-bit number at memory location TEMP; the product is found in AX.

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


3.

Multiplication (cont.) 16 bit multiplication


Instruction MUL CX IMUL DI Comment The unsigned number in AX is multiplied by CX; the product is found in DX and AX The signed number in AX is multiplied by DH; the product is found in DX and AX

MUL WORD The unsigned number in AX multiplied by the 16 PTR [SI] bit number in data segment at the address pointed to by SI; the product is found in DX and AX

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


3.

Multiplication (cont.) Example 8 bit: MOV BL, 5 MOV CL, 10 MOV AL, CL MUL BL MOV DX, AX

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


3.

Multiplication (cont.) Example 16 bit: MOV BX, 0805 MOV AX, BX MOV CX, 0604 MUL CX

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


4.

Division 8 bit multiplication


Instruction DIV CL IDIV BL DIV BYTE PTR[BP] Comment The unsigned number in AX is divided by CX; the quotient is in AL, and the remainder is in AH The signed number in AX is divided by BL; the quotient is in AL, and the remainder is in AH The unsigned number in AX divided by the byte in stack segment stored at the address located by BP; the quotient is in AL, and the remainder is in AH

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


4.

Division 16 bit multiplication


Instruction DIV CX Comment The unsigned number in DX and AX is divided by CX; the quotient is in AX, and the remainder is in DX The signed number in DX and AX is divided by SI; the quotient is in AX, and the remainder is in DX The unsigned number in DX and AX divided by the word stored in data segment at memory location DATA (a word of information)

IDIV SI DIV BYTE PTR[BP]

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


4.

Division Example 8 bit: MOV AL, 12 MOV CL, 3 MOV AH, 0 DIV CL

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)


4.

Division Example 16 bit: MOV AX, 3E14 MOV DX, 0030 MOV BX, 0805 DIV BX

You might also like