Sie sind auf Seite 1von 10

9/10/2014

1
INSTRUCTION SET
AND
PROGRAMMING
DATA TRANSFER INSTRUCTIONS
MOV destination, source (move byte or word data)
Example: MOV AX, [SI]
loads the data stored at the memory location addressed by
[SI] into registerAX.
PUSH source (push word onto stack)
Example: PUSH CX
places data from the source register CX into the stack.
POP destination (pop word off stack)
Example: POP DX
places data from the stack into register DX.

IN accumulator, port (input byte or word from port)
Example: IN AL, p8
8 bits are input to AL from I/O port p8.
OUT port, accumulator (output byte or word to port)
Example: OUT p8, AX
16 bits are output from AX to I/O port p8.
LEA destination, source (load effective address)
Example: LEA AX, [SI]
loads the offset address specified by [SI] (contents of SI) into
AX register.
PUSHF (push flag onto stack)
POPF (pop flags off stack)
XCHG destination, source (exchange byte or word)
Example: XCHG BL, [SI]
exchanges the content of the memory location addressed by
[SI] with the content of BL.
XLAT translate_table (translate byte)
Example: MOV DL,3
MOV BX, OFFSET EQUI
XLAT
MOVE SAME, DL
translate 3 into its equivalent from EQUI.
9/10/2014
2
LDS destination, source (load pointer using DS)
Example: LDS CX, [SI]
transfers the 32bit number, addressed by SI in data segment,
into the CX and DS register.
LES destination, source (load pointer using ES)
Example: LES AX, [SI]
transfers the 32bit number, addressed by SI in extra segment,
into the AX and ES register.
LAHF (load AH register from flags)
SAFH (store AH register into flags)



ARITHMETIC INSTRUCTIONS
ADD destination, source (add byte or word)
Example: ADD CL, AL
AL contents add to the contents of CL with the sum stored in
CL.
ADC destination, source (add byte or word with carry)
Example: ADC CL, CH
the byte contents of CH add to the content of CL with carry
and its sum stored in CL.
INC destination (increment byte or word by 1)
Example: INC DH
adds 1 to the content of DH.
SUB destination, source (subtract byte or word)
Example: SUB AL, DL
subtract the contents of DL from the contents of AL with the
difference stored in AL.
SBB destination, source (subtract byte or word with
borrow)
Example: SBB BL, BH
both carry and contents of BH subtract from the contents of
BL with the difference stored in BL.
DEC destination (decrement byte or word by 1)
Example: DEC AH
subtracts 1 from the byte content of AH.
CMP destination, source (compare byte or word)
Example: CMP BL, DL
DL content subtracts from the content of BL without changing
the content of the destination Usually followed by JA or JB.
MUL source (multiply byte or word unsigned)
Example: MUL DL
AL content is multiplied by DL content; The unsigned product
is stored in AX.
Example: MUL BX
AX content is multiplied by BX content, The unsigned product
is stored in DX-AX
9/10/2014
3
IMUL source (integer multiply byte or word)
Example: IMUL BH
AL content is multiplied by BH content, The signed product is
stored in AX.
Example: IMUL DX
AX content is multiplied by DX content, The signed product is
stored in DX-AX.
DIV source (divide byte or word unsigned)
Example: DIV BL
AX content is divided by the content of BL, The unsigned
quotient is stored in AL and the remainder is stored in AH.
Example: DIV BX
DX-AX content is divided by the content of BX, The unsigned
quotient is stored in AX and the remainder is stored in DX.
IDIV source (integer divide byte or word)
Example: IDIV CL
AX content is divided by the content of CL, the Signed quotient
is stored in AL and the remainder is stored in AH.
Example: IDIV DI
DX-AX content is divided by the content of DI, The signed
quotient is stored in AX and the remainder is stored in DX.

NEG destination (negate byte or word)
Example: NEG BL
BL content is 2s complemented
CBW (convert byte to word)
CWD (convert word to double word)
DAA (decimal adjust for addition)
DAS (decimal adjust for subtraction)
AAA (ASCII adjust for addition)
AAS (ASCII adjust for subtraction)
AAM (ASCII adjust for multiply)
AAD (ASCII adjust for division)
BIT MANIPULATION
INSTRUCTIONS
NOT destination (NOT byte or word)
Example: NOT AH
AH content is 1s complemented
AND destination, source (AND byte or word)
Example: AND BL, CL
BL content is ANDed with the content of CL, result is stored in
BL.
OR destination, source (OR byte or word)
Example: OR BH, DL
BH content is Ored with the content of DL, result is stored in
BH.
XOR destination, source (Exclusive-OR byte or word)
Example: XOR DH, AL
9/10/2014
4
CH content is exclusive-ORed with the, contents of AL, result is
stored in DH.
TEST destination, source (test byte or word)
Example: TEST AL, AH
content of AL is ANDed with the content of AH without
changing the destination.
BT register, bit_number
Example: BT BX, 3
Test bit position in BX. The result of the test is located in the
carry flag bit. If bit position 3 is a 1, carry is set; if bit position
4 is 0, carry is cleared.
BTC register, bit_number
Example: BTC BX, 3
Complement bit position 3 after testing it.
BTR register, bit_number
Example: BTR BX, 3
Clears bit position 3 after the test.
BTS register, bit_number
Example: BTS BX, 3
Sets bit position 3 after the test.

SHL/SAL destination, count (shift logical/arithmetic left byte or
word)
Example: SHL BX, 1
BX is logically shifted left 1 place.
Example: SAL BX, 1
BX is arithmetically shifted left 1 place.


SHR destination, count (shift logical right byte or word)
Example: SHR CX, 1
CX is logically shifted right 1 place.
0
C DATA
0
DATA C
SAR destination, count (shift arithmetic right byte or word)
Example: SAR DI, 1
DI is arithmetically shifted right 1 place.



ROL destination, count (rotate left byte or word)
Example: ROL DI, 1
DI rotates left 1 place

SIGN BIT
DATA C
C DATA
9/10/2014
5
ROR destination, count (rotate right byte or word)
Example: ROR DI, 1
DI rotate right 1 place



RCL destination, count (rotate left through carry byte or word)
Example: RCL DL, 1
DL rotates left through carry 1 place

DATA C
C DATA
RCR destination, count (rotate right through carry byte
or word)
Example: RCR DH, CL
DH rotates right through carry the number of places specified
by CL

DATA C
LOOP AND JUMP
INTRUCTIONS
Unconditional JUMP
JMP target (unconditional jump to target)
1. Direct jump the address is given in the instruction.
2. Indirect jump the target address might be contained in a
register or a memory location.
Conditional JUMP
JNC jump if no carry
JAE jump if above or equal
JNB jump if not below
JC jump if carry
JB jump if below
JNAE jump if not above nor equal
JNZ jump if not zero
JNE jump if not equal
JZ jump if zero
JE jump if equal
JNS jump if no sign
JS jump if sign
JNO jump if no overflow
JO jump if overflow
JNP jump if no parity
JP jump if parity

9/10/2014
6
JPE jump if parity even
JA jump if above
JBNE jump if not below nor equal
JBE jump if not below or equal
JNA jump if not above
JGE jump if greater or equal
JNL jump if not less
JL jump if less
JNGE jump if not greater nor equal
JG jump if greater
JNLE jump if not less or equal
JLE jump if less or equal
JNG jump if not greater
LOOP short-label (loop)
LOOPE/LOOPZ short-label (loop if equal/ loop if zero)
JCXZ short-label (jump if CX =0)

PROGRAM CONTROL
INSTRUCTIONS
CALL PROCEDURE-NAME (call procedure)
RET optional-pop-value (return from procedure)
String instructions
A string is a series of bytes or a series of words in sequential
memory locations. A string often consists of ASCII character
codes. In the list, a / is used to separate different
mnemonics for the same instruction. Use the mnemonic
which most clearly describes the function of the instruction in
a specific application. A B In a mnemonic is used to
specifically indicate that a string of bytes is to be acted upon.
A W In the mnemonic is used to indicate that a string of
words Is to be acted upon.
REP (An instruction prefix)
Repeat following instruction until CX = 0
REPE/REPZ (An instruction prefix)
Repeat instruction until CX = 0 or zero Flag ZF!=1
9/10/2014
7
REPNE/REPNZ (An instruction prefix)
Repeat until CX = 0 or ZF = 1
MOVS/MOVSB/MOVSW
Move byte or word from one string to another
COMPS/COMPSB/COMPSW
Compare two string bytes or two string words
INS/INSB/INSW (80186/80188)
Input string byte or word from port

OUTS/OUTSB/OUTSW (80186/80l88)
output string byte or word to port
SCAS/SCASB/SCASW
Scan a string
Compare a string byte with a byte in AL or a string word with a
word in AX
LODS/LODSB/LODSW
load string byte into AL or string word into AX
STOS/STOSB/STOSW
Store byte from AL or word from AX into string

Interrupt instructions
INT
Interrupt program execution call service procedure
INTO
Interrupt program execution OF =1
IRET
Return from interrupt se procedure to main program
High-level language interface
instructions
ENTER
(80l86/80188 only) Enter procedure
LEAVE
(80l86/80188 only) Leave procedure
BOUND
(80l86/80188 only) Check effective address within specified
array bounds
9/10/2014
8
Processor control
instructions
Flag set/clear instructions:
STC
Set carry flag CF to 1
CLC
Clear carry flag CF to 0
CMC
Complement the state of the carry flag CF
STD
Set direction flag DF to l (decrement string pointers)
CLD
Clear direction flag DF to 0
STI
Set interrupt enable flag to 1 (enable INTR input)
CLI
Clear interrupt enable flag to 0 (disable INTR input)
Execution control instructions:
HLT
Halt (do nothing) until interrupt or reset
WAIT
Wait (do nothing) until signal on the test pin is low
ESC
Escape to external coprocessor such as 8087 or 8089
LOCK
An instruction prefix. Prevents another processor from taking
the bus while the adjacent instruction executes
NOP
No action except fetch and decode

DATA MOVEMENT
INSTRUCTIONS
The formats of the 8086-Pentium 4 instructions.



a. 16 bit instruction mode



b. 32 bit instruction mode
(80386 to Pentium 4 only)

OPCODE
1-2 BYTES
MOD-REG-R/M
0-1 BYTES
DISPLACEMENT
0-1BYTES
IMMEDIATE
0-2 BYTES
REGISTER
SIZE
0-1 BYTES

OPCODE
1-2 BYTES

MOD-REG-R/M
0-1 BYTES

ADDRESS
SIZE
0-1 BYTES
DISPLACEMEN
T
0-4 BYTES
IMMEDIATE
0-4 BYTES
9/10/2014
9
Override Prefixes the first two bytes of the 32-bit instruction
mode format
Opcode selects the operation that is performed by the
microprocessor
MOD (mode) specifies the addressing mode for selected
instruction
REG (register) registers existing in microprocessor
R/M (register/memory) registers that are enclosed with the
bracket
* specifies a register instead of a memory location in Register
addressing mode
Direction bit (D) it indicates the data flow
data flow to the register REG from the R/M field (1) or data
flow to the R/M field from the REG field (0)
W bit it indicates the size of the information
Byte size (0) or a word/double word size (1)






MOD Field for 16-bit instruction mode (Table 1)

MOD FUNCTION
00 No displacement
01 8-bit sign-extended
displacement
10 16-bit signed displacement
11 R/M is a register
REG and R/M (when MOD =11) assignments (Table 2)
CODE W=0(Byte) W=1 (Word) W=1 (Double word)
000 AX EAX
001 CL CX ECX
010 DL DX EDX
011 BL BX EBX
100 AH SP ESP
101 CH BP EBP
110 DH SI ESI
111 BH DI EDI
16-bit R/M memory-addressing modes (Table 3)
R/M CODE ADDRESSING MODE
000 DS:[BX+SI]
001 DS:[BX+DI]
010 SS:[BP+SI]
011 SS:[BP+DI]
100 DS:[SI]
101 DS:[DI]
110 SS:[BP]*
111 DS:[BX]
9/10/2014
10
* MOV CS, R/M AND POP CS ARE NOT ALLOWED (Table 4)

CODE SEGMENT REGISTER
000 ES
001 CS*
010 SS
011 DS
100 FS
101 GS

Das könnte Ihnen auch gefallen