24
“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide Electronics, Telecommunications and Information Technology Faculty Appendix © Corneliu Burileanu -1- Appendix Intel x86 compatible processors’ instruction set We convene upon the following notations: s: source; d: destination; AL|AX: default accumulator (8 or 16 bits); mem: the content of a memory location or two successive memory locations addressed through one of the permitted addressing modes for data memory (except immediate addressing); mem16: the content of two successive memory locations addressed through one of the permitted addressing modes for data memory (except immediate addressing); mem32: the content of four successive memory locations addressed through one of the permitted addressing modes for data memory (except immediate addressing); r|r i |r j : a common 8 bit or 16 bit register (except segment registers); r8: an 8 bit register (except segment registers); r16: a 16 bit register (except segment registers); rs: a segment register; data: an 8 or 16 bit operand coded in the instruction format (immediate addressing); data8: an 8 bit operand coded in the instruction format (immediate addressing); data16: a 16 bit operand coded in the instruction format (immediate addressing); disp8: an 8 bit displacement (coded in the instruction format); disp16: a 16 bit displacement (coded in the instruction format); adr: a complete, 16 bit address; adr8: a short, 8 bit address; adr32: a logical, 32 bit address; port: the address (index) of an input/output (8 bit) port tip: an 8 bit operand coded in the instruction format that specifies the type of an interrupt; nrcel: the number of cells that an operand can be shifted or rotated with; AE: effective address; Flags notations: x: the flag’s value changes according to the instruction result; 1: the flag is unconditionally set; 0: the flag is unconditionally reset; ?: the flag’s value changes unpredictably; blank: the flag’s value is not modified by the instruction;

AMP Appendappix1 Eng

Embed Size (px)

DESCRIPTION

app

Citation preview

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 1 -

Appendix

Intel x86 compatible processors’ instruction set

We convene upon the following notations:

s: source;d: destination;AL|AX: default accumulator (8 or 16 bits);mem: the content of a memory location or two successive memory locations addressed through

one of the permitted addressing modes for data memory (except immediate addressing);

mem16: the content of two successive memory locations addressed through one of the permitted addressing modes for data memory (except immediate addressing);

mem32: the content of four successive memory locations addressed through one of the permitted addressing modes for data memory (except immediate addressing);

r|ri|rj: a common 8 bit or 16 bit register (except segment registers);r8: an 8 bit register (except segment registers);r16: a 16 bit register (except segment registers);rs: a segment register;data: an 8 or 16 bit operand coded in the instruction format (immediate addressing);data8: an 8 bit operand coded in the instruction format (immediate addressing);data16: a 16 bit operand coded in the instruction format (immediate addressing);disp8: an 8 bit displacement (coded in the instruction format);disp16: a 16 bit displacement (coded in the instruction format);adr: a complete, 16 bit address;adr8: a short, 8 bit address;adr32: a logical, 32 bit address;port: the address (index) of an input/output (8 bit) porttip: an 8 bit operand coded in the instruction format that specifies the type of an interrupt;nrcel: the number of cells that an operand can be shifted or rotated with;AE: effective address;

Flags notations:

x: the flag’s value changes according to the instruction result;1: the flag is unconditionally set;0: the flag is unconditionally reset;?: the flag’s value changes unpredictably;blank: the flag’s value is not modified by the instruction;

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 2 -

Number of states calculus:

cAE – effective address calculus time (measured in number of states):direct addressing:

AE = disp8|disp16 6 statesindexed addressing:

AE = (SI)|(DI) + disp8|disp16 9 statesindirect implicit addressing:

AE = (SI)|(DI) 5 statesdirect base relative addressing (no displacement):

AE = (BX) 5 statesdirect base relative addressing (with displacement):

AE = (BX) + disp8|disp16 9 statesindexed base relative addressing:

AE = (BX) + (SI)|(DI) + disp8|disp16 12 statesimplicit base relative addressing:

AE = (BX) + (SI)|(DI) 8 statesdirect stack addressing (no displacement):

AE = (BP) 5 statesdirect stack addressing (with displacement):

AE = (BP) + disp8|disp16 9 statesindexed stack addressing:

AE = (BP) + (SI)|(DI) + disp8|disp16 12 statesimplicit stack addressing:

AE = (BP) + (SI)|(DI) 8 states

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 3 -

ASCII adjustment OF DF IF TF SF ZF AF PF CFAAA for addition ? ? ? x ? x

Operands No. of states

Bytes Examples

4 1 AAA

ASCII adjustment OF DF IF TF SF ZF AF PF CFAAD for division ? x x ? x ?

(done before the division)

Operands No. of states

Bytes Examples

60 2 AAD

ASCII adjustment OF DF IF TF SF ZF AF PF CFAAM for multiplication ? x x ? x ?

(done after themultiplication)

Operands No. of states

Bytes Examples

83 1 AAM

ASCII adjustment OF DF IF TF SF ZF AF PF CFAAS for subtraction ? ? ? x ? x

Operands No. of states

Bytes Examples

4 1 AAS

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 4 -

Add with carry OF DF IF TF SF ZF AF PF CFADC d,s x x x x x x

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 ADC AX,9D81Hr, data 4 3-4 ADC CL,36Hmem, data 17+cAE 3-6 ADC [SI],2D31Hr1, r2 3 2 ADC BX,SI

r, mem 9+cAE 2-4 ADC AX,[BX]mem, r 16+cAE 2-4 ADC [BX+SI+64H],DI

OF DF IF TF SF ZF AF PF CFADD d,s Add without carry x x x x x x

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 ADD AX,0F0FHr, data 4 3-4 ADD DX,0F0F0Hmem, data 17+cAE 3-6 ADD [100H],2Hr1, r2 3 2 ADD SI,CXr, mem 9+cAE 2-4 ADD DI,[BX+22H]mem, r 16+cAE 2-4 ADD [BX+SI],CL

OF DF IF TF SF ZF AF PF CFAND d,s Logical AND 0 x x ? x 0

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 AND AL,7FHr, data 4 3-4 AND CX,0F0Hmem, data 17+cAE 3-6 AND [BX],01010000Br1, r2 3 2 AND AL,BLr, mem 9+cAE 2-4 AND DL,[BX+SI]mem, r 16+cAE 2-4 AND [DI+10H],AL

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 5 -

OF DF IF TF SF ZF AF PF CFCALL adr Subprogram call

Operands No. of states

Bytes Examples

adr32 28 5 CALL PROC-ALT-SEGdisp16 28 3 CALL SUMAr16 16 2 CALL BXmem* 21+cAE 2-4 CALL [BX]mem** 37+cAE 2-4 CALL [SI]* subprogram call with indirect addressing defined by the assembler directive as intra-segment call;** subprogram call with indirect addressing defined by the assembler directive as inter-segment call.

Byte to word OF DF IF TF SF ZF AF PF CFCBW conversion

(with sign)Operands No. of

statesBytes Examples

2 1 CBW

OF DF IF TF SF ZF AF PF CFCLC Clear carry flag 0

Operands No. of states

Bytes Examples

2 1 CLC

OF DF IF TF SF ZF AF PF CFCLD Clear direction 0

flagOperands No. of

statesBytes Examples

2 1 CLD

Clear interrupt OF DF IF TF SF ZF AF PF CFCLI enable flag 0

Operands No. of states

Bytes Examples

2 1 CLI

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 6 -

OF DF IF TF SF ZF AF PF CFCMC Complement carry x

flagOperands No. of

statesBytes Examples

2 1 CMC

OF DF IF TF SF ZF AF PF CFCMP s1,s2 Compare operands x x x x x x

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 CMP AL,0DHr, data 4 3-4 CMP SI,200Hmem, data 17+cAE 3-6 CMP [BX+DI+55H],2222Hr1, r2 3 2 CMP CL,DH

r, mem 9+cAE 2-4 CMP DH,[4321H]mem, r 16+cAE 2-4 CMP [BP+2],SI

Compare the current OF DF IF TF SF ZF AF PF CFCMPS elements of two x x x x x x

arraysOperands No. of

statesBytes Examples

22 1 CMPSB ;bytes comparison22 1 CMPSW ;words comparison

Obs.: CMPS can be prefixed by one of the repeatability prefixes: REP, REPE|REPZ orREPNE|REPNZ; these prefixes add 9 more states.

Word to double word OF DF IF TF SF ZF AF PF CFCWD conversion

(with sign)Operands No. of

statesBytes Examples

5 1 CWD

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 7 -

Decimal adjustment OF DF IF TF SF ZF AF PF CFDAA for addition ? x x x x x

Operands No. of states

Bytes Examples

4 1 DAA

Decimal adjustment OF DF IF TF SF ZF AF PF CFDAS for subtraction ? x x x x x

Operands No. of states

Bytes Examples

4 1 DAS

OF DF IF TF SF ZF AF PF CFDEC s Decrement source x x x x x

Operands No. of states

Bytes Examples

r16 2 1 DEC CXr8 3 2 DEC BHmem 15+cAE 2-4 DEC [SI+20H]

OF DF IF TF SF ZF AF PF CFDIV s Division ? ? ? ? ? ?

Operands No. of states

Bytes Examples

r8 80- 90 2 DIV BLr16 144-162 2 DIV CXmem8 86- 96+

cAE2-4 DIV [400H]

mem16 150-168+ cAE

2-4 DIV [SI+10H]

OF DF IF TF SF ZF AF PF CFESC s Escape

Operands No. of states

Bytes Examples

mem 7 + cAE 2-4 ESC [BX+SI]

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 8 -

OF DF IF TF SF ZF AF PF CFHLT Halt processor

Operands No. of states

Bytes Examples

2 1 HLT

Signed integer OF DF IF TF SF ZF AF PF CFIDIV s division ? ? ? ? ? ?

Operands No. of states

Bytes Examples

r8 101-112 2 IDIV CLr16 165-184 2 IDIV BXmem8 107-118+

cAE2-4 IDIV [SI+100H]

mem16 171-190+ cAE

2-4 IDIV [BX+1000H]

Signed integer OF DF IF TF SF ZF AF PF CFIMUL s multiply x ? ? ? ? x

Operands No. of states

Bytes Examples

r8 80- 98 2 IMUL CLr16 128-154 2 IMUL BXmem8 86-104+

cAE2-4 IMUL [BX]

mem16 134-160+ cAE

2-4 IMUL [BP+DI+30H]

Input from port OF DF IF TF SF ZF AF PF CFIN d,s (to accumulator)

Operands No. of states

Bytes Examples

AL|AX, port 10 2 IN AL,1FHAL|AX, DX 8 1 IN AX,DX

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 9 -

OF DF IF TF SF ZF AF PF CFINC s Increment source x x x x x

Operands No. of states

Bytes Examples

r16 2 1 INC SIr8 3 2 INC BLmem 15+cAE 2-4 INC [BX+SI]

OF DF IF TF SF ZF AF PF CFINT [tip] Software interrupt 0 0

requestOperands No. of

statesBytes Examples

52 1 INT ; type 3 interrupttip (tip<>3) 51 2 INT 67

Interrupt on OF DF IF TF SF ZF AF PF CFINTO overflow (type 4) 0 0

Operands No. of states

Bytes Examples

53 or 4 1 INTO

OF DF IF TF SF ZF AF PF CFIRET Interrupt return x x x x x x x x x

Operands No. of states

Bytes Examples

24 1 IRET

Jump if above | OF DF IF TF SF ZF AF PF CFJA | JNBE Jump if not below disp8 or equal (unsigned)

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JA ET1 ;jump if ;(CF) or (ZF) = 0

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 10 -

Jump if above or OF DF IF TF SF ZF AF PF CFJAE|JNB|JNC equal | jump if not disp8 below | jump if not

carry (unsigned)Operands No. of

statesBytes Examples

disp8 16 or 4 2 JAE ET2 ;jump if (CF)=0

jump if below | OF DF IF TF SF ZF AF PF CFJB|JNAE|JC jump if not above disp8 or equal | jump if

carry (unsigned)Operands No. of

statesBytes Examples

disp8 16 or 4 2 JB ET3 ;jump if (CF)=1

OF DF IF TF SF ZF AF PF CFJCXZ disp8 jump if (CX) = 0

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JCXZ GATA

Jump if equal | OF DF IF TF SF ZF AF PF CFJE | JZ jump if zero disp8 (signed)

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JZ ET5 ;jump if (ZF)=1

Jump if below or OF DF IF TF SF ZF AF PF CFJBE | JNA equal | jump if not disp8 above (unsigned)

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JNA ET4 ;jump if;(CF)=1 or (ZF)=1

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 11 -

Jump if greater | OF DF IF TF SF ZF AF PF CFJG | JNLE jump if not lower disp8 or equal (signed)

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JG ET6 ;jump if;((SF)(OF))or(ZF)=0

Jump if greater or OF DF IF TF SF ZF AF PF CFJGE | JNL equal | jump if not disp8 lower (signed)

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JGE ET7 ;jump if;(SF)(OF)=0

Jump if lower OF DF IF TF SF ZF AF PF CFJL | JNGE | jump if not disp8 greater or equal

(signed)Operands No. of

statesBytes Examples

disp8 16 or 4 2 JL ET8 ;jump if;(SF)(OF)=1

Jump if lower or OF DF IF TF SF ZF AF PF CFJLE | JNG equal | jump if disp8 not greater

(signed)Operands No. of

statesBytes Examples

disp8 16 or 4 2 JNG ET9 ;jump if;((SF)(OF))or(ZF)=1

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 12 -

OF DF IF TF SF ZF AF PF CFJMP adr Jump

(unconditioned)Operands No. of

statesBytes Examples

adr32 15 5 JMP OTHER_SEGMENT_LABELdisp16 15 3 JMP IN_SEGMENT_LABELdisp8 15 2 JMP SHORT_JUMP_LABELr16 11 2 JMP CXmem* 18+cAE 2-4 JMP [BX+100H]mem** 24+cAE 2-4 JMP [DI]* jump with indirect addressing defined by the assembler directive as intra-segment jump;** jump with indirect addressing defined by the assembler directive as inter-segment jump;

Jump if not equal | OF DF IF TF SF ZF AF PF CFJNE | JNZ jump if not zero disp8 (signed)

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JNE ET10 ;jump if (ZF)=0

Jump if not OF DF IF TF SF ZF AF PF CFJNO disp8 overflow

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JNO ET11 ;jump if (OF)=0

Jump if not parity OF DF IF TF SF ZF AF PF CFJNP | JPO | jump if parity

disp8 oddOperands No. of

statesBytes Examples

disp8 16 or 4 2 JPO ET12 ;jump if (PF)=0

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 13 -

Jump if not sign OF DF IF TF SF ZF AF PF CFJNS disp8

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JNS ET13 ;jump if (SF)=0

OF DF IF TF SF ZF AF PF CFJO disp8 Jump if overflow

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JO ET14 ;jump if (OF)=1

Jump if parity | OF DF IF TF SF ZF AF PF CFJP | JPE jump if parity even

disp8Operands No. of

statesBytes Examples

disp8 16 or 4 2 JPO ET15 ;jump if (PF)=1

OF DF IF TF SF ZF AF PF CFJS disp8 Jump if sign

Operands No. of states

Bytes Examples

disp8 16 or 4 2 JS ET16 ;jump if (SF)=1

OF DF IF TF SF ZF AF PF CFLAHF Load flags into AH

Operands No. of states

Bytes Examples

4 1 LAHF

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 14 -

Load register OF DF IF TF SF ZF AF PF CFLDS d,s (destination) and

data segment (DS)Operands No. of

statesBytes Examples

r16, mem32 16+cAE 2-4 LDS SI,[10H]

Load register OF DF IF TF SF ZF AF PF CFLEA d,s (destination) with

effective addressOperands No. of

statesBytes Examples

r16, mem16 2+cAE 2-4 LEA BX,[BX+SI+0FFFH]

Load register OF DF IF TF SF ZF AF PF CFLES d,s (destination) and

extended data segment (ES)

Operands No. of states

Bytes Examples

r16, mem32 16+cAE 2-4 LES DI,[BX]

OF DF IF TF SF ZF AF PF CFLOCK Lock the system bus

Operands No. of states

Bytes Examples

mem 2 1 LOCK XCHG CL,BL

Load string OF DF IF TF SF ZF AF PF CFLODS Loads the current

string component into the accumulator

Operands No. of states

Bytes Examples

12 1 LODSB ; loads one byte12 1 LODSW ; loads one word

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 15 -

OF DF IF TF SF ZF AF PF CFLOOP disp8 Unconditioned loop

Operands No. of states

Bytes Examples

disp8 9 or 5 2 LOOP CICLU_1

Loop if equal | OF DF IF TF SF ZF AF PF CFLOOPE|LOOPZ loop if zero

disp8Operands No. of

statesBytes Examples

disp8 11 or 5 2 LOOPE CICLU_2

LOOPNE | Loop if not equal | OF DF IF TF SF ZF AF PF CFLOOPNZ loop if not zero

disp8Operands No. of

statesBytes Examples

disp8 11 or 5 2 LOOPNE CICLU_3

Copies a byte or OF DF IF TF SF ZF AF PF CFMOV d,s word from source to

destinationOperands No. of

statesBytes Examples

r, data 4 2-3 MOV CX,3168H, data 10+cAE 3-6 MOV [BX],491FHAL|AX, mem 10 3 MOV AL,[1064H]mem, AL|AX 10 3 MOV [1064H],AXr1, r2 2 2 MOV AX,CXr, mem 8+cAE 2-4 MOV BP,[BX+DELTA]mem, r 9+cAE 2-4 MOV [DI+100H],CXrs*, r16 2 2 MOV SS,DXrs*, mem16 8+cAE 2-4 MOV DS,[1000H]r16, rs 2 2 MOV BP,SSmem16, rs 9+cAE 2-4 MOV [2000H],CS* any segment register except CS

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 16 -

Copies the current OF DF IF TF SF ZF AF PF CFMOVS component of the

source string into the current component of the destination string

Operands No. of states

Bytes Examples

18 1 MOVSB ; moves one byte18 1 MOVSW ; moves one word

Obs.: MOVS can be prefixed by the repeatability prefix REP; this prefix adds 9 more states.

OF DF IF TF SF ZF AF PF CFMUL s Unsigned integer x ? ? ? ? x

multiplicationOperands No. of

statesBytes Examples

r8 70- 77 2 MUL BLr16 118-133 2 MUL CXmem8 76- 83+

cAE2-4 MUL [SI+300H]

mem16 124-139+ cAE

2-4 MUL [200H]

Negate source OF DF IF TF SF ZF AF PF CFNEG s (2’s complement) x x x x x 1*

Operands No. of states

Bytes Examples

r 3 2 NEG ALmem 16+cAE 2-4 NEG [BX]* (CF) = 0 if (s) = 0H

Logical NOT OF DF IF TF SF ZF AF PF CFNOT s (1’s complement)

Operands No. of states

Bytes Examples

r 3 2 NOT BLmem 16+cAE 2-4 NOT [1000H]

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 17 -

OF DF IF TF SF ZF AF PF CFOR d,s Logical OR 0 x x ? x 0

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 OR AX,3030Hr, data 4 3-4 OR CX,001FHmem, data 17+cAE 3-6 OR [BX+DI],1F1FHr1, r2 3 2 OR AH,BH

r, mem 9+cAE 2-4 OR DX,[DI]mem, r 16+cAE 2-4 OR [BX],AX

Output to port OF DF IF TF SF ZF AF PF CFOUT d,s (from accumulator)

Operands No. of states

Bytes Examples

port, AL|AX 10 2 OUT 44,AXDX, AL|AX 8 1 OUT DX,AL

Pop from stack OF DF IF TF SF ZF AF PF CFPOP d (to destination)

Operands No. of states

Bytes Examples

r16 8 1 POP BXmem16 17+cAE 2-4 POP [SI]rs (nu CS) 8 1 POP ES

Pop from stack to OF DF IF TF SF ZF AF PF CFPOPF flags register x x x x x x x x x

Operands No. of states

Bytes Examples

8 1 POPF

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 18 -

Push (source) on OF DF IF TF SF ZF AF PF CFPUSH s stack

Operands No. of states

Bytes Examples

r16 11 1 PUSH SImem16 16+cAE 2-4 PUSH [BX]rs 10 1 PUSH DS

Push the flags OF DF IF TF SF ZF AF PF CFPUSHF register on stack

Operands No. of states

Bytes Examples

10 1 PUSHF

OF DF IF TF SF ZF AF PF CFRCL s, nrcel Rotate carry left x x

Operands No. of states

Bytes Examples

r, 1 2 2 RCL AX,1r, CL 8

+4/bit2 RCL BL,CL

mem, 1 15+cAE 2-4 RCL ALFA,1mem, CL 20+cAE

+4/bit2-4 RCL [DI+ALFA],CL

OF DF IF TF SF ZF AF PF CFRCR s, nrcel Rotate carry right x x

Operands No. of states

Bytes Examples

r, 1 2 2 RCR BX,1r, CL 8

+4/bit2 RCR CX,CL

mem, 1 15+cAE 2-4 RCR [BX+20],1mem, CL 20+cAE

+4/bit2-4 RCR [SI],CL

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 19 -

Repeat OF DF IF TF SF ZF AF PF CFREP (unconditionally)

string operationOperands No. of

statesBytes Examples

9 1 REP MOVSB

Repeat while equal OF DF IF TF SF ZF AF PF CFREPE | REPZ | while zero the

CMPS or SCAS instruction

Operands No. of states

Bytes Examples

9 1 REPE CMPSB

Repeat while not OF DF IF TF SF ZF AF PF CFREPNE|REPNZ equal | while not

zero the CMPS or SCAS instruction

Operands No. of states

Bytes Examples

9 1 REPNE SCASW

Return from OF DF IF TF SF ZF AF PF CFRET [data16] subprogram

Operands No. of states

Bytes Examples

8 1 RET ;intra-segmentdata16 12 3 RET 4 ;intra-segment

18 1 RET ;inter-segmentdata16 17 3 RET 2 ;inter-segment

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 20 -

OF DF IF TF SF ZF AF PF CFROL s, nrcel Rotate left x x

Operands No. of states

Bytes Examples

r, 1 2 2 ROL DI,1r, CL 8

+4/bit2 ROL BX,CL

mem, 1 15+cAE 2-4 ROL [DI+DELTA],1mem, CL 20+cAE

+4/bit2-4 ROL [BX+DI],CL

OF DF IF TF SF ZF AF PF CFROR s, nrcel Rotate right x x

Operands No. of states

Bytes Examples

r, 1 2 2 ROR CX,1r, CL 8

+4/bit2 ROR BX,CL

mem, 1 15+cAE 2-4 ROR [SI],1mem, CL 20+cAE

+4/bit2-4 ROR BETA,CL

Store AH in the OF DF IF TF SF ZF AF PF CFSAHF flags register (F) x x x x x

Operands No. of states

Bytes Examples

4 1 SAHF

Shift right OF DF IF TF SF ZF AF PF CFSAL | SHL arithmetic | x x x ? x x s,nrcel logical

Operands No. of states

Bytes Examples

r, 1 2 2 SHL AL,1r, CL 8

+4/bit2 SAL SI,CL

mem, 1 15+cAE 2-4 SHL [DI+100H],1mem, CL 20+cAE

+4/bit2-4 SHL [BP+SI],CL

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 21 -

Shift arithmetic OF DF IF TF SF ZF AF PF CFSAR s, nrcel right x x x ? x x

Operands No. of states

Bytes Examples

r, 1 2 2 SAR AH,1r, CL 8

+4/bit2 SAR DI,CL

mem, 1 15+cAE 2-4 SAR [BP],1mem, CL 20+cAE

+4/bit2-4 SAR [DI],CL

OF DF IF TF SF ZF AF PF CFSBB d,s Subtract with x x x x x x

borrowOperands No. of

statesBytes Examples

AL|AX, data 4 2-3 SBB AX,4D2CHr, data 4 3-4 SBB CL,1mem, data 17+cAE 3-6 SBB [BP+SI],3F8Hr1, r2 3 2 SBB BL,DL

r, mem 9+cAE 2-4 SBB DI,[BX+ALFA]mem, r 16+cAE 2-4 SBB [SI+100],AX

Scan string OF DF IF TF SF ZF AF PF CFSCAS (compares the x x x x x x

current string element with the accumulator)

Operands No. of states

Bytes Examples

15 1 SCASB ; compares one byte15 1 SCASW ; compares one word

Obs.: CMPS can be prefixed by one of the repeatability prefixes: REP, REPE|REPZ orREPNE|REPNZ; these prefixes add 9 more states.

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 22 -

Shift right OF DF IF TF SF ZF AF PF CFSHR s, nrcel (logical) x x x ? x x

Operands No. of states

Bytes Examples

r, 1 2 2 SHR BL,1r, CL 8

+4/bit2 SHR SI,CL

mem, 1 15+cAE 2-4 SHR [BP+SI],1mem, CL 20+cAE

+4/bit2-4 SHR [BX+DI+BETA],CL

OF DF IF TF SF ZF AF PF CFSTC Set carry flag 1

Operands No. of states

Bytes Examples

2 1 STC

OF DF IF TF SF ZF AF PF CFSTD Set direction flag 1

Operands No. of states

Bytes Examples

2 1 STDOF DF IF TF SF ZF AF PF CF

STI Set interrupt flag 1

Operands No. of states

Bytes Examples

2 1 STI

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 23 -

Store string OF DF IF TF SF ZF AF PF CFSTOS (stores the current

component of the string in the accumulator)

Operands No. of states

Bytes Examples

11 1 STOSB ; store one byte11 1 STOSW ; store one word

Obs.: STOS can be prefixed by the repeatability prefix REP; this prefix adds 9 more states.

OF DF IF TF SF ZF AF PF CFSUB d,s Subtract x x x x x x

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 SUB AL,65Hr, data 4 3-4 SUB SI,5280mem, data 17+cAE 3-6 SUB [SI+14H],136Hr1, r2 3 2 SUB CX,BXr, mem 9+cAE 2-4 SUB DH,[BP+4]mem, r 16+cAE 2-4 SUB [BP+10],CL

Test OF DF IF TF SF ZF AF PF CFTEST s1,s2 (compares the two 0 x x ? x 0

values without storing the result)

Operands No. of states

Bytes Examples

AL|AX, data 4 2-3 TEST AX,0040Hr, data 5 3-4 TEST SI,0050mem, data 11+cAE 3-6 TEST [BP],00100000Br1, r2 3 2 TEST SI,DIr, mem 9+cAE 2-4 TEST AL,[55H]

OF DF IF TF SF ZF AF PF CFWAIT Wait for

coprocessorOperands No. of

statesBytes Examples

1 WAIT

“Politehnica” University of Bucharest Microprocessors’ Architecture – Lab guide

Electronics, Telecommunications and Information Technology Faculty Appendix

© Corneliu Burileanu

- 24 -

OF DF IF TF SF ZF AF PF CFXCHG d,s Exchange values

Operands No. of states

Bytes Examples

r16 3 1 XCHG BX ;exchanges AX and BXr1, r2 4 2 XCHG AL,BLr, mem 17 + cAE 2-4 XCHG BX,[BP+SI]

OF DF IF TF SF ZF AF PF CFXLAT Translate byte

Operands No. of states

Bytes Examples

11 1 XLAT

OF DF IF TF SF ZF AF PF CFXOR d,s Logical Exclusive 0 x x ? x 0

OROperands No. of

statesBytes Examples

AL|AX, data 4 2-3 XOR AX,5522Hr, data 4 3-4 XOR SI,00C2Hmem, data 17+cAE 3-6 XOR [BX+DI],2244Hr1, r2 3 2 XOR CX,BXr, mem 9+cAE 2-4 XOR AX,[SI]mem, r 16+cAE 2-4 XOR [SI+ALFA],DX