Move and exchange instructions
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Move and Exchange Instructions PowerPoint PPT Presentation


  • 45 Views
  • Uploaded on
  • Presentation posted in: General

Move and Exchange Instructions. Module M16.1 Section 10.2. MOV Move Instruction. Can move immediate data to a register or memory (but not a segment register). Can move data from a register to a register. Can move data from a register to memory. Can move data from memory to a register.

Download Presentation

Move and Exchange Instructions

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Move and exchange instructions

Move and ExchangeInstructions

Module M16.1

Section 10.2


Mov move instruction

MOV Move Instruction

  • Can move immediate data to a register or memory (but not a segment register).

  • Can move data from a register to a register.

  • Can move data from a register to memory.

  • Can move data from memory to a register.

  • Can NOT use MOV instruction to move data directly from one memory location to another. But can use MOVS instruction.


Some mov instructions

Some MOV Instructions


Move and exchange instructions

8

9

A

B

C

D

E

F

OR b

OR w

OR b

OR w

OR b

OR w

PUSH

0

AL,imm

AX,imm

r/m,reg

r/m,reg

reg,r/m

CS

reg,r/m

POP

PUSH

SBB b

SBB w

SBB b

SBB w

SBB b

SBB w

1

DS

DS

AL,imm

AX,imm

reg,r/m

r/m,reg

reg,r/m

r/m,reg

SUB w

SUB b

SUB w

SUB b

SUB b

SUB w

SEGMENT

DAS

2

AL,imm

AX,imm

reg,r/m

reg,r/m

CS

r/m,reg

r/m,reg

CMP b

CMP w

CMP b

CMP w

CMP b

CMP w

SEGMENT

AAS

3

AL,imm

AX,imm

reg,r/m

r/m,reg

DS

r/m,reg

reg,r/m

DEC

DEC

DEC

DEC

DEC

DEC

DEC

DEC

4

DX

BX

SP

BP

SI

DI

AX

CX

POP

POP

POP

POP

POP

POP

POP

POP

5

AX

CX

DX

BX

SP

BP

SI

DI

6

7

JS

JNS

JNLE/JG

JP/JPE

JNP/JPO

JL/JNGE

JNL/JGE

JLE/JNG

POP

MOV b

MOV

LEA

MOV

MOV W

MOV b

MOV W

8

r/m

r/m,reg

r/m,seg

reg,r/m

seg,r/m

r/m,reg

reg,r/m

reg,r/m

CALL

CBW

SAHF

LAHF

CWD

PUSHF

POPF

WAIT

9

inter

TEST b

TEST w

SCAS w

STOS b

STOS w

LODS b

LODS w

SCAS b

A

AL,imm

AL,imm

MOV

MOV

MOV

MOV

MOV

MOV

MOV

MOV

B

AX,imm

CX,imm

DX,imm

BX,imm

SP,imm

BP,imm

SI,imm

DI,imm

RET

INT

RET

INT

INTO

IRET

C

inter+

type

inter

ESC

ESC

ESC

ESC

ESC

ESC

ESC

ESC

D

0

1

2

3

4

5

6

7

CALL

JMP

JMP

JMP

IN b

IN w

OUT b

OUT w

E

intra

intra

inter

short

AL,DX

AX,DX

DX,AL

DX,AX

CLC

CLD

STC

CLI

STI

STD

*

*

F

Table A2.a

Opcode Map

mov bx,ax

8B D8


Move and exchange instructions

Table A.3

Table A.4

Fields

mod,r/m

Postbyte

Postbyte

Field

reg

mod

= 11

reg

byte (b)

word (w)

000

AL

AX

r/m

byte

word

mod

= 00

mod

= 01

mod

= 10

001

CL

CX

000

AL

AX

BX + SI

BX + SI + disp8

BX + SI + disp16

001

CL

CX

BX + DI

BX + DI + disp8

BX + DI + disp16

010

DL

DX

010

DL

DX

BP + SI

BP + SI + disp8

BP + SI + disp16

011

BL

BX

011

BL

BX

BP + DI

BP + DI + disp8

BP + DI + disp16

100

AH

SP

100

AH

SP

SI

SI + disp8

SI + disp16

101

CH

BP

101

CH

BP

DI

DI + disp8

DI + disp16

110

DH

SI

110

DH

SI

Direct

BP + disp8

BP + disp16

111

BH

DI

111

BH

DI

BX

BX + disp8

BX + disp16

Postbyte

1 1

0 1 1

0 0 0

= D8

mod

reg

r/m

mov bx,ax

8B D8

mov bx,ax

8B mov w reg,r/m

reg = bx = 011

mod = 11

r/m = ax = 0 0 0


Move and exchange instructions

8

9

A

B

C

D

E

F

OR b

OR w

OR b

OR w

OR b

OR w

PUSH

0

AL,imm

AX,imm

r/m,reg

r/m,reg

reg,r/m

CS

reg,r/m

POP

PUSH

SBB b

SBB w

SBB b

SBB w

SBB b

SBB w

1

DS

DS

AL,imm

AX,imm

reg,r/m

r/m,reg

reg,r/m

r/m,reg

SUB w

SUB b

SUB w

SUB b

SUB b

SUB w

SEGMENT

DAS

2

AL,imm

AX,imm

reg,r/m

reg,r/m

CS

r/m,reg

r/m,reg

CMP b

CMP w

CMP b

CMP w

CMP b

CMP w

SEGMENT

AAS

3

AL,imm

AX,imm

reg,r/m

r/m,reg

DS

r/m,reg

reg,r/m

DEC

DEC

DEC

DEC

DEC

DEC

DEC

DEC

4

DX

BX

SP

BP

SI

DI

AX

CX

POP

POP

POP

POP

POP

POP

POP

POP

5

AX

CX

DX

BX

SP

BP

SI

DI

6

7

JS

JNS

JNLE/JG

JP/JPE

JNP/JPO

JL/JNGE

JNL/JGE

JLE/JNG

POP

MOV b

MOV

LEA

MOV

MOV W

MOV b

MOV W

8

r/m

r/m,reg

r/m,seg

reg,r/m

seg,r/m

r/m,reg

reg,r/m

reg,r/m

CALL

mov bx,ax

CBW

SAHF

LAHF

CWD

PUSHF

POPF

WAIT

9

inter

TEST b

TEST w

SCAS w

STOS b

STOS w

LODS b

LODS w

SCAS b

A

AL,imm

AL,imm

89 C3

MOV

MOV

MOV

MOV

MOV

MOV

MOV

MOV

B

AX,imm

CX,imm

DX,imm

BX,imm

SP,imm

BP,imm

SI,imm

DI,imm

RET

INT

RET

INT

INTO

IRET

C

inter+

type

inter

ESC

ESC

ESC

ESC

ESC

ESC

ESC

ESC

D

0

1

2

3

4

5

6

7

CALL

JMP

JMP

JMP

IN b

IN w

OUT b

OUT w

E

intra

intra

inter

short

AL,DX

AX,DX

DX,AL

DX,AX

CLC

CLD

STC

CLI

STI

STD

*

*

F

Table A2.a

Opcode Map

mov bx,ax

8B D8


Move and exchange instructions

Table A.3

Table A.4

Fields

mod,r/m

Postbyte

Postbyte

Field

reg

mod

= 11

reg

byte (b)

word (w)

000

AL

AX

r/m

byte

word

mod

= 00

mod

= 01

mod

= 10

001

CL

CX

000

AL

AX

BX + SI

BX + SI + disp8

BX + SI + disp16

001

CL

CX

BX + DI

BX + DI + disp8

BX + DI + disp16

010

DL

DX

010

DL

DX

BP + SI

BP + SI + disp8

BP + SI + disp16

011

BL

BX

011

BL

BX

BP + DI

BP + DI + disp8

BP + DI + disp16

100

AH

SP

100

AH

SP

SI

SI + disp8

SI + disp16

101

CH

BP

101

CH

BP

DI

DI + disp8

DI + disp16

110

DH

SI

110

DH

SI

Direct

BP + disp8

BP + disp16

111

BH

DI

111

BH

DI

BX

BX + disp8

BX + disp16

Postbyte

1 1

0 0 0

0 1 1

= C3

mod

reg

r/m

mov bx,ax

89 C3

mov bx,ax

89 mov w r/m, reg

reg = ax = 000

mod = 11

r/m = bx = 0 11


Move and exchange instructions

Table A.3

Table A.4

Fields

mod,r/m

Postbyte

Postbyte

Field

reg

mod

= 11

reg

byte (b)

word (w)

000

AL

AX

r/m

byte

word

mod

= 00

mod

= 01

mod

= 10

001

CL

CX

000

AL

AX

BX + SI

BX + SI + disp8

BX + SI + disp16

001

CL

CX

BX + DI

BX + DI + disp8

BX + DI + disp16

010

DL

DX

010

DL

DX

BP + SI

BP + SI + disp8

BP + SI + disp16

011

BL

BX

011

BL

BX

BP + DI

BP + DI + disp8

BP + DI + disp16

100

AH

SP

100

AH

SP

SI

SI + disp8

SI + disp16

101

CH

BP

101

CH

BP

DI

DI + disp8

DI + disp16

110

DH

SI

110

DH

SI

Direct

BP + disp8

BP + disp16

111

BH

DI

111

BH

DI

BX

BX + disp8

BX + disp16

Postbyte

= 1C

0 0

0 1 1

1 0 0

mod

reg

r/m

Move byte pointed to by si into BL

mov bl,[si]

8A 1C

mov bl,[si]

8A mov b reg, r/m

reg = bl = 011

mod = 00

r/m = si = 100


Xchg exchange instruction

XCHG Exchange Instruction

  • Can exchange AX with a 16-bit register.

  • Can exchange an 8-bit register with another 8-bit register or an 8-bit byte in memory.

  • Can exchange a 16-bit register with another 16-bit register or a 16-bit word in memory.


Xchg instruction

XCHG Instruction

Machine

Assembly Language

Code

Instruction

Operation

9X

XCHG reg16

Exchange AX and reg16

86 PB

XCHG b r/m,reg

Exchange r/m and reg bytes

87 PB

XCHG w r/m,reg

Exchange r/m and reg words


Move and exchange instructions

0

1

2

3

4

5

6

7

ADD b

PUSH

POP

ADD w

ADD b

ADD w

ADD b

ADD w

0

ES

r/m,reg

ES

r/m,reg

AL,imm

AX,imm

reg,r/m

reg,r/m

ADC b

ADC b

ADC w

ADC w

ADC b

ADC w

PUSH

POP

1

reg,r/m

r/m,reg

reg,r/m

AL,imm

AX,imm

r/m,reg

SS

SS

AND b

AND w

AND b

AND w

AND b

AND w

SEGMENT

DAA

2

reg,r/m

reg,r/m

AL,imm

AX,imm

r/m,reg

r/m,reg

ES

XOR b

XOR w

XOR b

XOR w

XOR b

XOR w

SEGMENT

AAA

3

reg,r/m

r/m,reg

r/m,reg

reg,r/m

AL,imm

AX,imm

SS

INC

INC

INC

INC

INC

INC

INC

INC

4

DX

BX

SP

SI

DI

AX

CX

BP

PUSH

PUSH

PUSH

PUSH

PUSH

PUSH

PUSH

PUSH

5

AX

SI

DI

CX

DX

BX

SP

BP

6

JO

JNO

JB/JNAE

JNB/JAE

JE/JZ

JNE/JNZ

JNBE/JA

JBE/JNA

7

JC

JNC

XCHG w

TEST b

TEST w

XCHG b

8

*

*

*

*

r/m,reg

r/m,reg

r/m,reg

r/m,reg

XCHG

XCHG

XCHG

XCHG

XCHG

XCHG

XCHG

NOP

9

CX,AX

DX,AX

BX,AX

SP,AX

BP,AX

SI,AX

DI,AX

MOV b

MOV w

MOV b

MOV w

MOVS b

MOVS w

CMPS b

CMPS w

A

AL,mem

AX,mem

mem,AL

mem,AX

MOV

MOV

MOV

MOV

MOV

MOV

MOV

MOV

B

AL,imm

CL,imm

DL,imm

BL,imm

AH,imm

CH,imm

DH,imm

BH,imm

RET

LES

LDS

RET

MOV b

MOV w

C

reg.r/m

intra+

reg.r/m

intra

r/m,imm

r/m,imm

XLAT

*

AAD

*

*

*

AAM

D

LOOPZ/

LOOP

OUT b

OUT w

LOOPNZ/

JCXZ

IN b

IN w

E

LOOPE

port,AL

port,AX

LOOPNE

AL,port

AX,port

REP/REPNE

REPE/

*

LOCK

HLT

CMC

*

F

REPNZ

REPZ

Table A2.a

Opcode Map


Move and exchange instructions

Table A.3

Table A.4

Fields

mod,r/m

Postbyte

Postbyte

Field

reg

mod

= 11

reg

byte (b)

word (w)

000

AL

AX

r/m

byte

word

mod

= 00

mod

= 01

mod

= 10

001

CL

CX

000

AL

AX

BX + SI

BX + SI + disp8

BX + SI + disp16

001

CL

CX

BX + DI

BX + DI + disp8

BX + DI + disp16

010

DL

DX

010

DL

DX

BP + SI

BP + SI + disp8

BP + SI + disp16

011

BL

BX

011

BL

BX

BP + DI

BP + DI + disp8

BP + DI + disp16

100

AH

SP

100

AH

SP

SI

SI + disp8

SI + disp16

101

CH

BP

101

CH

BP

DI

DI + disp8

DI + disp16

110

DH

SI

110

DH

SI

Direct

BP + disp8

BP + disp16

111

BH

DI

111

BH

DI

BX

BX + disp8

BX + disp16

Postbyte

1 1

0 0 0

1 1 1

= C7

mod

reg

r/m

xchg bh,al

86 C7

xchg bh,al

86 xchg b r/m,reg

reg = al = 000

mod = 11

r/m = bh = 111


  • Login