Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Assembly Language Step by Step Programming with DOS and Linux 2nd Ed 2000.pdf
Скачиваний:
156
Добавлен:
17.08.2013
Размер:
4.44 Mб
Скачать

SHL Shift Left

Flags affected:

O

D

I

T

S

Z

A

P

C

OF:

Overflow flag TF:

Trap

flag

AF:

Aux carry

F

F

F

F

F

F

F

F

F

DF:

Direction flag SF:

Sign

flag

PF:

Parity flag

** * * * * IF: Interrupt flag ZF: Zero flag CF: Carry flag

Legal forms:

SHL r8,1

 

SHL m8,1

 

SHL r16,1

 

SHL m16,1

386+

SHL r32,1

SHL m32,1

386+

SHL r8,CL

 

SHL m8,CL

 

SHL r16,CL

 

SHL m16,CL

386+

SHL r32,CL

SHL m32,CL

386+

SHL r8,i8

286+

SHL m8,i8

286+

SHL r16,i8

286+

SHL m16,i8

286+

SHL r32,i8

386+

SHL m32,i8

386+

Examples:

SHL AL,1

SHL WORD [BX+SI],CL

SHL BP,1

SHL EAX,9

SHL BP,CL

Notes:

SHL shifts the bits within the destination operand to the left, where left is toward the most significant bit (MSB). The number of bit positions shifted may be specified either as an 8-bit immediate value, or by the value in CL- not CX or ECX. (The 8086 and 8088 are limited to the immediate value 1.) Note that while CL may accept a value up to 255, it is meaningless to shift by any value larger than 16-or 32 in 32-bit mode-even though the shifts are actually performed on the 8086 and 8088. (The 286 and later limit the number of shift operations performed to the native word size except when running in Virtual 86 mode.) The leftmost bit of the operand is shifted into the Carry flag; the rightmost bit is cleared to 0. The Auxiliary carry flag (AF) becomes undefined after this instruction. OF is modified only by the shift-by-one forms of SHL; after shift-by-CL forms, OF becomes undefined.

SHL is a synonym for SAL (Shift Arithmetic Left). Except for the direction the shift operation takes, SHL is identical to SHR.

r8

= AL

AH

BL BH

CL

CH DL DH

r16

= AX BX CX DX

BP SP SI DI

sr = CS

DS SS ES

FS GS

r32

= EAX EBX ECX

EDX EBP ESP ESI E

m8

= 8-bit

memory data

m16

= 16-bit memory data

m32 = 32-bit memory

data

i8 = 8-bit immediate data

i16

= 16-bit

immediate data

i32

=

32-bit

immediate data

d8 = 8-bit signed displacement

d16

=

16-bit

signed displacement

d32

= 32-bit

unsigned displacement

 

 

 

 

SHR Shift Right

Flags affected:

O

D

I

T

S

Z

A

P

C

OF:

Overflow flag TF:

Trap

flag

AF:

Aux carry

F

F

F

F

F

F

F

F

F

DF:

Direction flag SF:

Sign

flag

PF:

Parity flag

** * * * * IF: Interrupt flag ZF: Zero flag CF: Carry flag

Legal forms:

SHR r8,1

 

SHR m8,1

 

SHR r16,1

 

SHR m16,1

386+

SHR r32,1

SHR m32,1

386+

SHR r8,CL

 

SHR m8,CL

 

SHR r16,CL

 

SHR m16,CL

386+

SHR r32,CL

SHR m32,CL

386+

SHR r8,i8

286+

SHR m8,i8

286+

SHR r16,i8

286+

SHR m16,i8

286+

SHR r32,i8

386+

SHR m32,i8

386+

Examples:

SHR AL,1

SHR WORD [BX+SI],CL

SHR BP,1

SHR EAX,9

SHR BP,CL

Notes:

SHR shifts the bits within the destination operand to the right, where right is toward the least-significant bit (LSB). The number of bit positions shifted may be specified either as an 8-bit immediate value, or by the value in CL—not CX or ECX. (The 8086 and 8088 are limited to the immediate value 1.) Note that while CL may accept a value up to 255, it is meaningless to shift by any value larger than 16—or 32 in 32-bit mode—even though the shifts are actually performed on the 8086 and 8088. (The 286 and later limit the number of shift operations performed to the native word size except when running in Virtual 86 mode.) The rightmost bit of the operand is shifted into the Carry flag; the leftmost bit is cleared to 0. The Auxiliary carry flag (AF) becomes undefined after this instruction. OF is modified only by the shift-by-one forms of SHL; after shift-by-CL forms, OF becomes undefined.

SHR is a synonym for SAR (Shift Arithmetic Right). Except for the direction the shift operation takes, SHR is identical to SHL.

r8

= AL

AH

BL BH

CL

CH DL DH

r16

= AX BX CX DX

BP SP SI DI

sr = CS

DS SS ES

FS GS

r32

= EAX EBX ECX

EDX EBP ESP ESI E

m8

= 8-bit

memory data

m16

= 16-bit memory data

m32 = 32-bit memory

data

i8 = 8-bit immediate data

i16

= 16-bit

immediate data

i32

=

32-bit

immediate data

d8 = 8-bit signed displacement

d16

=

16-bit

signed displacement

d32

= 32-bit

unsigned displacement