Sei sulla pagina 1di 25
tulisnota.blogspot.com A SSEMBLY LANGUAGE PROGRAMMING Data Transfer Instruction, Logic Instruction, Arithmetic Instruction
tulisnota.blogspot.com A SSEMBLY LANGUAGE PROGRAMMING Data Transfer Instruction, Logic Instruction, Arithmetic Instruction

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

provide to move data either between its internal register or between an internal register and a

tulisnota.blogspot.com

DATA TRANSFER INSTRUCTION (CONT.)

1. Move byte / word (MOV)

Example: MOV DX, CS – move the contents of CS into DX

2. Exchange byte / word (XCHG)

Example: XCHG AX, DX – exchange the contents of the AX and DX

3. Translate byte (XLAT)

Exchange byte / word (XCHG)  Example: XCHG AX, DX – exchange the contents of the

tulisnota.blogspot.com

DATA TRANSFER INSTRUCTION (CONT.)

4. Load effective address (LEA)

Example: LEA SI, EA – load SI register with an offset address value

5. Load data segment (LDS)

Example: LDS SI, [200H]

6. Load extra segment (LES)

with an offset address value 5. Load data segment (LDS)  Example: LDS SI, [200H] 6.

LOGIC INSTRUCTION

tulisnota.blogspot.com

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

AND AX, BX – causes the contents of BX to be ANDed with the contents of

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

contains 000FH, the results is  1234H · 000FH = 0004H  The result is stored
 

tulisnota.blogspot.com

 

LOGIC INSTRUCTION (CONT.)

 

Table of logic instruction

 

Mnemonic

Meaning

Format

Operation

 

AND

Logical AND

AND D, S

(S)· (D) = (D)

OR

Logical OR

OR D, S

(S) + (D) = (D)

XOR

Logical Exclusive-OR

XOR D, S

(S)

XOR Logical Exclusive-OR XOR D, S (S) (D) = (D)

(D) = (D)

NOT

Logical NOT

NOT D

(D) = (D)

 
 

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

Example:  MOV AL, 0101 0101 B  AND AL, 0001 1111 B  OR AL,
 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION

 

1.

Addition

Register addition

 

Instruction

Comment

ADD AL, BX

AL

becomes the sum of AL + BL

ADD CX, DI

CX

becomes the sum of CX + DI

Immediate addition

Instruction

Comment

ADD BL, 44

BL become sum of BL + 44H

ADD BX, 35AF

BX becomes the sum of BX + 35AFH

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

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

1. Addition (cont.)

Instruction

Comment

ADD [BX], AL

The data segment memory byte addressed by BX becomes the sum of the data segment memory byte addressed by BX + AL

ADD CL, [BP]

CL becomes the sum of the stack segment byte addressed by BP + CL

ADD BX, [SI + 2]

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

by BP + CL ADD BX, [SI + 2] BX becomes the sum of the data

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

1. Addition (cont.)

Instruction

Comment

ADD CL, TEMP

CL becomes the sum of CL plus the data segment byte TEMP

ADD BX, TEMP[DI]

BX becomes the sum of BX plus the contents of the data segment array TEMP plus offset

DI

ADD [BX + DI], DL

The data segment memory byte addressed by BX + DI becomes the sum of that byte plus DL

DI ADD [BX + DI], DL The data segment memory byte addressed by BX + DI

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

1. Addition (cont.)

Example:

MOV DL, 12

ADD DL, 33

A RITHMETIC INSTRUCTION ( CONT .) 1. Addition (cont.)  Example:  MOV DL, 12 
 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

 

2.

Subtraction

 
 

Register subtraction

 

Instruction

Comment

   

ADD CL, BL

CL

becomes the difference of CL – BL

ADD AX, SP

AX

becomes the difference of AX – SP

Immediate subtraction

 

Instruction

 

Comment

 

ADD DH, 6F

 

DH become difference of DH – 6FH

ADD AX, CCCC

BX becomes the difference of AX - CCCCH

ADD AX, CCCC BX becomes the difference of AX - CCCCH
 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

2. Subtraction (cont.)

Subtraction with borrow

Instruction

Comment

SBB AH, AL

AH becomes the difference of AH – Al – carry

SBB AX, BX

AX becomes the difference of AX – BX – carry

SBB CL, 3

CL becomes the difference of CL – 3 – carry

SBB [DI], AL

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

DI becomes the difference of the stack segment word addressed by BP + 2 and the

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

2. Subtraction (cont.)

Subtraction (others)

Instruction

Comment

SUB [DI], CH

The data segment memory byte addressed by DI becomes the difference of the data segment memory byte addressed by DI – CH.

SUB CH, [BP]

CH becomes the difference of the stack segment memory byte by BP – CH.

byte addressed by DI – CH. SUB CH, [BP] CH becomes the difference of the stack

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

2. Subtraction (cont.)

Subtraction (others)

Instruction

Comment

SUB AH, TEMP

AH becomes the difference of AH minus the contents of memory byte TEMP located in the data segment

SUB DI, TEMP[BX]

DI becomes the difference of DI minus the contents of data segments array TEMP plus offset BX

SUB DI, TEMP[BX] DI becomes the difference of DI minus the contents of data segments array

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

2. Subtraction (cont.)

Example:

MOV CH, 22

SUB CH, 44

A RITHMETIC INSTRUCTION ( CONT .) 2. Subtraction (cont.)  Example:  MOV CH, 22 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

3.

Multiplication

8 bit multiplication

Instruction

Comment

MUL CL

The unsigned number in AL is multiplied by CL; the product is found in AX

IMUL DH

The signed number in AL is multiplied by DH; the product is found in AX

MUL BYTE PTR[BX]

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

MUL TEMP

The unsigned number in AL is multiplied by 8-bit number at memory location TEMP; the product is found in AX.

MUL TEMP The unsigned number in AL is multiplied by 8-bit number at memory location TEMP;
 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

 

3.

Multiplication (cont.)

 
 

16 bit multiplication

Instruction

Comment

 

MUL CX

The unsigned number in AX is multiplied by CX; the product is found in DX and AX

IMUL DI

The signed number in AX is multiplied by DH; the product is found in DX and AX

MUL WORD PTR [SI]

The unsigned number in AX multiplied by the 16 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

3. Multiplication (cont.)  Example 8 bit:  MOV BL, 5  MOV CL, 10 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

3. Multiplication (cont.)

Example 16 bit:

MOV BX, 0805

MOV AX, BX

MOV CX, 0604

MUL CX

( CONT .) 3. Multiplication (cont.)  Example 16 bit:  MOV BX, 0805  MOV

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

4.

Division

8 bit multiplication

Instruction

Comment

DIV

CL

The unsigned number in AX is divided by CX; the quotient is in AL, and the remainder is in AH

IDIV BL

The signed number in AX is divided by BL; the quotient is in AL, and the remainder is in AH

DIV

BYTE

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

PTR[BP]

byte in stack segment stored at the address located by BP; the quotient is in AL,

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

4.

Division

16 bit multiplication

Instruction

Comment

DIV

CX

The unsigned number in DX and AX is divided by

 

CX; the quotient is in AX, and the remainder is in

DX

IDIV SI

The signed number in DX and AX is divided by SI; the quotient is in AX, and the remainder is in DX

DIV

BYTE

The unsigned number in DX and AX divided by the word stored in data segment at memory location DATA (a word of information)

PTR[BP]

number in DX and AX divided by the word stored in data segment at memory location

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

4.

Division

Example 8 bit:

MOV AL, 12

MOV CL, 3

MOV AH, 0

DIV CL

RITHMETIC INSTRUCTION ( CONT .) 4. Division  Example 8 bit:  MOV AL, 12 

tulisnota.blogspot.com

ARITHMETIC INSTRUCTION (CONT.)

4.

Division

Example 16 bit:

MOV AX, 3E14

MOV DX, 0030

MOV BX, 0805

DIV BX

INSTRUCTION ( CONT .) 4. Division  Example 16 bit:  MOV AX, 3E14  MOV