-1-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Number of states calculus: cAE effective address calculus time (measured in number of states): direct addressing: AE = disp8|disp16 indexed addressing: AE = (SI)|(DI) + disp8|disp16 indirect implicit addressing: AE = (SI)|(DI) direct base relative addressing (no displacement): AE = (BX) direct base relative addressing (with displacement): AE = (BX) + disp8|disp16 indexed base relative addressing: AE = (BX) + (SI)|(DI) + disp8|disp16 implicit base relative addressing: AE = (BX) + (SI)|(DI) direct stack addressing (no displacement): AE = (BP) direct stack addressing (with displacement): AE = (BP) + disp8|disp16 indexed stack addressing: AE = (BP) + (SI)|(DI) + disp8|disp16 implicit stack addressing: AE = (BP) + (SI)|(DI)
6 states 9 states 5 states 5 states 9 states 12 states 8 states 5 states 9 states 12 states 8 states
-2-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
AAA Operands
OF ?
DF
IF ?
TF ?
SF x
ZF ?
AF x
PF
CF
Examples AAA
AAD
Operands
ASCII adjustment OF DF ? for division (done before the division) No. of Bytes states 60 2 AAD
IF
TF
SF x
ZF x
AF ?
PF x
CF ?
Examples
AAM
Operands
ASCII adjustment OF DF ? for multiplication (done after the multiplication) No. of Bytes states 83 1 AAM
IF
TF
SF x
ZF x
AF ?
PF x
CF ?
Examples
AAS Operands
OF ?
DF
IF
TF
SF ?
ZF ?
AF x
PF ?
CF x
Examples AAS
-3-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Add with carry ADC d,s Operands AL|AX, data r, data mem, data r1, r 2 r, mem mem, r No. of states 4 4 17+cAE 3 9+cAE 16+cAE Bytes 2-3 3-4 3-6 2 2-4 2-4
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples ADC ADC ADC ADC ADC ADC AX,9D81H CL,36H [SI],2D31H BX,SI AX,[BX] [BX+SI+64H],DI
ADD
d,s Operands
Add without carry No. of states 4 4 17+cAE 3 9+cAE 16+cAE Bytes 2-3 3-4 3-6 2 2-4 2-4
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples ADD ADD ADD ADD ADD ADD AX,0F0FH DX,0F0F0H [100H],2H SI,CX DI,[BX+22H] [BX+SI],CL
AND
d,s Operands
Logical AND No. of states 4 4 17+cAE 3 9+cAE 16+cAE Bytes 2-3 3-4 3-6 2 2-4 2-4
OF 0
DF
IF
TF
SF x
ZF x
AF ?
PF x
CF 0
Examples AND AND AND AND AND AND AL,7FH CX,0F0H [BX],01010000B AL,BL DL,[BX+SI] [DI+10H],AL
-4-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
DF
IF
TF
SF
ZF
AF
PF
CF
No. of Bytes Examples states adr32 28 5 CALL PROC-ALT-SEG disp16 28 3 CALL SUMA r16 16 2 CALL BX mem* 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.
Operands
CBW Operands
OF
DF
IF
TF
SF
ZF
AF
PF
CF
Bytes 1 CBW
Examples
DF
IF
TF
SF
ZF
AF
PF
CF 0
Examples CLC
DF 0
IF
TF
SF
ZF
AF
PF
CF
Examples CLD
CLI Operands
OF
DF
IF 0
TF
SF
ZF
AF
PF
CF
Examples CLI
-5-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
DF
IF
TF
SF
ZF
AF
PF
CF x
Examples CMC
CMP
s1,s2 Operands
Compare operands No. of states 4 4 17+cAE 3 9+cAE 16+cAE Bytes 2-3 3-4 3-6 2 2-4 2-4
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples CMP CMP CMP CMP CMP CMP AL,0DH SI,200H [BX+DI+55H],2222H CL,DH DH,[4321H] [BP+2],SI
Compare the current OF DF IF TF SF ZF AF PF CF x x x x x x elements of two arrays Operands No. of Bytes Examples states 22 1 CMPSB ;bytes comparison 22 1 CMPSW ;words comparison Obs.: CMPS can be prefixed by one of the repeatability prefixes: REP, REPE|REPZ or REPNE|REPNZ; these prefixes add 9 more states. CMPS
CWD Operands
Word to double word OF DF conversion (with sign) No. of Bytes states 5 1 CWD
IF
TF
SF
ZF
AF
PF
CF
Examples
-6-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
DAA Operands
OF ?
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples DAA
DAS Operands
OF ?
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples DAS
DEC
s Operands
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF
r16 r8 mem
DIV
s Operands
Division No. of states 80- 90 144-162 86- 96+ cAE 150-168+ cAE Bytes 2 2 2-4 2-4
OF ?
DF
IF
TF
SF ?
ZF ?
AF ?
PF ?
CF ?
DF
IF
TF
SF
ZF
AF
PF
CF
Examples ESC
-7-
[BX+SI]
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
DF
IF
TF
SF
ZF
AF
PF
CF
Examples HLT
IDIV
Signed integer division No. of states 101-112 165-184 107-118+ cAE 171-190+ cAE Bytes 2 2 2-4 2-4
OF ?
DF
IF
TF
SF ?
ZF ?
AF ?
PF ?
CF ?
IMUL
Signed integer multiply No. of states 80- 98 128-154 86-104+ cAE 134-160+ cAE Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF ?
ZF ?
AF ?
PF ?
CF x
IN
d,s Operands
OF
DF
IF
TF
SF
ZF
AF
PF
CF
-8-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
INC
s Operands
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF
r16 r8 mem
DF
IF 0
TF 0
SF
ZF
AF
PF
CF
tip (tip<>3)
INTO Operands
OF
DF
IF 0
TF 0
SF
ZF
AF
PF
CF
Examples INTO
IRET Operands
OF x
DF x
IF x
TF x
SF x
ZF x
AF x
PF x
CF x
Examples IRET
Jump if above | OF DF IF Jump if not below or equal (unsigned) No. of Bytes states 16 or 4 2 JA ET1
TF
SF
ZF
AF
PF
CF
-9-
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Jump if above or OF DF IF equal | jump if not below | jump if not carry (unsigned) No. of Bytes states 16 or 4 2 JAE ET2
TF
SF
ZF
AF
PF
CF
jump if below | OF DF IF jump if not above or equal | jump if carry (unsigned) No. of Bytes states 16 or 4 2 JB ET3
TF
SF
ZF
AF
PF
CF
Jump if below or OF DF IF equal | jump if not above (unsigned) No. of Bytes states 16 or 4 2 JNA ET4
TF
SF
ZF
AF
PF
CF
DF
IF
TF
SF
ZF
AF
PF
CF
TF
SF
ZF
AF
PF
CF
- 10 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Jump if greater | OF DF IF TF SF ZF AF PF jump if not lower or equal (signed) No. of Bytes Examples states 16 or 4 2 JG ET6 ;jump if ;((SF)(OF))or(ZF)=0
CF
Jump if greater or OF DF IF equal | jump if not lower (signed) No. of Bytes states 16 or 4 2 JGE ET7
TF
SF
ZF
AF
PF
CF
Jump if lower OF DF IF | jump if not greater or equal (signed) No. of Bytes states 16 or 4 2 JL ET8
TF
SF
ZF
AF
PF
CF
Jump if lower or OF DF IF TF SF ZF AF PF equal | jump if not greater (signed) No. of Bytes Examples states 16 or 4 2 JNG ET9 ;jump if ;((SF)(OF))or(ZF)=1
CF
- 11 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
OF DF IF TF SF ZF AF PF CF Jump (unconditioned) Operands No. of Bytes Examples states adr32 15 5 JMP OTHER_SEGMENT_LABEL disp16 15 3 JMP IN_SEGMENT_LABEL disp8 15 2 JMP SHORT_JUMP_LABEL r16 11 2 JMP CX mem* 18+cAE 2-4 JMP [BX+100H] mem** 24+cAE 2-4 JMP [DI] * jump with indirect addressing defined by the assembler directive as intrasegment jump; ** jump with indirect addressing defined by the assembler directive as intersegment jump; JMP adr
Jump if not equal | OF DF IF TF SF ZF AF PF jump if not zero (signed) No. of Bytes Examples states 16 or 4 2 JNE ET10 ;jump if (ZF)=0
CF
JNO
disp8 Operands
OF
DF
IF
TF
SF
ZF
AF
PF
CF
disp8
Jump if not parity OF DF IF TF SF ZF AF PF | jump if parity odd No. of Bytes Examples states 16 or 4 2 JPO ET12 ;jump if (PF)=0
CF
- 12 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Jump if not sign JNS disp8 Operands disp8 No. of states 16 or 4 Bytes 2
OF
DF
IF
TF
SF
ZF
AF
PF
CF
DF
IF
TF
SF
ZF
AF
PF
CF
OF
DF
IF
TF
SF
ZF
AF
PF
CF
DF
IF
TF
SF
ZF
AF
PF
CF
DF
IF
TF
SF
ZF
AF
PF
CF
Examples LAHF
- 13 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
LDS
d,s Operands
r16, mem32
Load register OF DF IF TF SF ZF (destination) and data segment (DS) No. of Bytes Examples states 16+cAE 2-4 LDS SI,[10H]
AF
PF
CF
LEA
d,s Operands
r16, mem16
Load register OF DF IF TF SF ZF AF (destination) with effective address No. of Bytes Examples states 2+cAE 2-4 LEA BX,[BX+SI+0FFFH]
PF
CF
LES
d,s
Load register OF DF IF TF SF ZF (destination) and extended data segment (ES) No. of Bytes Examples states 16+cAE 2-4 LES DI,[BX]
AF
PF
CF
OF LOCK Operands mem Lock the system bus No. of states 2 Bytes 1
DF
IF
TF
SF
ZF
AF
PF
CF
LODS
Operands
Load string OF DF Loads the current string component into the accumulator No. of Bytes states 12 1 LODSB 12 1 LODSW
IF
TF
SF
ZF
AF
PF
CF
- 14 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
DF
IF
TF
SF
ZF
AF
PF
CF
OF
DF
IF
TF
SF
ZF
AF
PF
CF
OF
DF
IF
TF
SF
ZF
AF
PF
CF
Copies a byte or OF DF word from source to destination Operands No. of Bytes states r, data 4 2-3 MOV , data 10+cAE 3-6 MOV AL|AX, mem 10 3 MOV mem, AL|AX 10 3 MOV r1, r 2 2 2 MOV r, mem 8+cAE 2-4 MOV mem, r 9+cAE 2-4 MOV rs*, r16 2 2 MOV rs*, mem16 8+cAE 2-4 MOV r16, rs 2 2 MOV mem16, rs 9+cAE 2-4 MOV * any segment register except CS MOV d,s
IF
TF
SF
ZF
AF
PF
CF
Examples CX,3168H [BX],491FH AL,[1064H] [1064H],AX AX,CX BP,[BX+DELTA] [DI+100H],CX SS,DX DS,[1000H] BP,SS [2000H],CS
- 15 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Copies the current OF DF IF TF SF ZF AF PF CF component of the source string into the current component of the destination string Operands No. of Bytes Examples states 18 1 MOVSB ; moves one byte 18 1 MOVSW ; moves one word Obs.: MOVS can be prefixed by the repeatability prefix REP; this prefix adds 9 more states. MOVS
MUL
s Operands
OF DF Unsigned integer x multiplication No. of Bytes states 70- 77 2 MUL 118-133 2 MUL 76- 83+ 2-4 MUL cAE 124-139+ 2-4 MUL cAE
IF
TF
SF ?
ZF ?
AF ?
PF ?
CF x
NEG
s Operands
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF 1*
NOT
s Operands
OF
DF
IF
TF
SF
ZF
AF
PF
CF
r mem
- 16 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
OR
d,s Operands
Logical OR No. of states 4 4 17+cAE 3 9+cAE 16+cAE Bytes 2-3 3-4 3-6 2 2-4 2-4
OF 0
DF
IF
TF
SF x
ZF x
AF ?
PF x
CF 0
OUT
d,s Operands
OF
DF
IF
TF
SF
ZF
AF
PF
CF
POP
d Operands
Pop from stack (to destination) No. of states 8 17+cAE 8 Bytes 1 2-4 1
OF
DF
IF
TF
SF
ZF
AF
PF
CF
POPF Operands
OF x
DF x
IF x
TF x
SF x
ZF x
AF x
PF x
CF x
Examples POPF
- 17 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
PUSH
OF
DF
IF
TF
SF
ZF
AF
PF
CF
PUSHF Operands
OF
DF
IF
TF
SF
ZF
AF
PF
CF
Examples PUSHF
Rotate carry left No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF
ZF
AF
PF
CF x
Rotate carry right No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF
ZF
AF
PF
CF x
- 18 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
REP Operands
Repeat OF DF IF TF SF ZF (unconditionally) string operation No. of Bytes Examples states 9 1 REP MOVSB
AF
PF
CF
REPE | REPZ
Operands
Repeat while equal OF DF IF TF SF ZF | while zero the CMPS or SCAS instruction No. of Bytes Examples states 9 1 REPE CMPSB
AF
PF
CF
REPNE|REPNZ
Operands
Repeat while not OF DF equal | while not zero the CMPS or SCAS instruction No. of Bytes states 9 1 REPNE
IF
TF
SF
ZF
AF
PF
CF
Examples SCASW
OF
DF
IF
TF
SF
ZF
AF
PF
CF
data16 data16
4 2
- 19 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Rotate left No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF
ZF
AF
PF
CF x
Rotate right No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF
ZF
AF
PF
CF x
SAHF Operands
OF
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples SAHF
Shift right arithmetic | logical No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit
DF
IF
TF
SF x
ZF x
AF ?
PF x
CF x
- 20 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Shift arithmetic right No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF x
ZF x
AF ?
PF x
CF x
SBB
d,s Operands
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples SBB SBB SBB SBB SBB SBB AX,4D2CH CL,1 [BP+SI],3F8H BL,DL DI,[BX+ALFA] [SI+100],AX
Scan string OF DF IF TF SF ZF AF PF CF x x x x x x (compares the current string element with the accumulator) Operands No. of Bytes Examples states 15 1 SCASB ; compares one byte 15 1 SCASW ; compares one word Obs.: CMPS can be prefixed by one of the repeatability prefixes: REP, REPE|REPZ or REPNE|REPNZ; these prefixes add 9 more states. SCAS
- 21 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Shift right (logical) No. of states 2 8 +4/bit 15+cAE 20+cAE +4/bit Bytes 2 2 2-4 2-4
OF x
DF
IF
TF
SF x
ZF x
AF ?
PF x
CF x
DF
IF
TF
SF
ZF
AF
PF
CF 1
Examples STC
DF 1
IF
TF
SF
ZF
AF
PF
CF
Examples STD OF DF
STI Operands
IF 1
TF
SF
ZF
AF
PF
CF
Examples
- 22 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
Store string OF DF IF TF SF ZF AF PF CF (stores the current component of the string in the accumulator) Operands No. of Bytes Examples states 11 1 STOSB ; store one byte 11 1 STOSW ; store one word Obs.: STOS can be prefixed by the repeatability prefix REP; this prefix adds 9 more states. STOS
SUB
d,s Operands
Subtract No. of states 4 4 17+cAE 3 9+cAE 16+cAE Bytes 2-3 3-4 3-6 2 2-4 2-4
OF x
DF
IF
TF
SF x
ZF x
AF x
PF x
CF x
Examples SUB SUB SUB SUB SUB SUB AL,65H SI,5280 [SI+14H],136H CX,BX DH,[BP+4] [BP+10],CL
TEST
s1,s2
Test OF DF 0 (compares the two values without storing the result) No. of Bytes states 4 2-3 TEST 5 3-4 TEST 11+cAE 3-6 TEST 3 2 TEST 9+cAE 2-4 TEST
IF
TF
SF x
ZF x
AF ?
PF x
CF 0
DF
IF
TF
SF
ZF
AF
PF
CF
Bytes 1 WAIT
Examples
- 23 -
Politehnica University of Bucharest Electronics, Telecommunications and Information Technology Faculty Corneliu Burileanu
DF
IF
TF
SF
ZF
AF
PF
CF
DF
IF
TF
SF
ZF
AF
PF
CF
Examples XLAT
XOR
d,s Operands
OF DF 0 Logical Exclusive OR No. of Bytes states 4 2-3 XOR 4 3-4 XOR 17+cAE 3-6 XOR 3 2 XOR 9+cAE 2-4 XOR 16+cAE 2-4 XOR
IF
TF
SF x
ZF x
AF ?
PF x
CF 0
- 24 -