Professional Documents
Culture Documents
8086 Lecture
8086 Lecture
9/4/2012
The minimum mode is selected by making the MN/MX equal to 1. The maximum mode is selected by making the MN/MX equal to 0. Minimum mode 8086 system has one microprocessor.
9/4/2012
9/4/2012
9/4/2012
9/4/2012
9/4/2012
9/4/2012
9/4/2012
interrupts
9/4/2012
9/4/2012
10
Interrupts in 8086
An 8086 Interrupt can come from any of three sources. - Hardware Interrupt External interrupt applied to nonmaskable interrupt NMI. External interrupt applied to maskable interrupt INTR. - Software Interrupt
9/4/2012
11
INTR INTERRUPT REQUEST: is a level triggered input which is sampled during the last clock cycle of each instruction to determine if the processor should enter into an interrupt acknowledge Operation INTA Interrupt Acknowledge from the MP NMI NON-MASKABLE INTERRUPT: an edge triggered input which causes an interrupt request to the P
Naveen Kr. Dubey (ECE DEPT ..RKGITW) 9/4/2012 12
In the 8086 there are a total of 256 interrupts (or interrupt types) INT 00 INT 01 INT FF In 80x86, the memory location to which an interrupt goes is always four times the value of the interrupt number . INT 03h goes to 000Ch
9/4/2012
13
9/4/2012
14
The lowest five types are dedicated to specific interrupts. Interrupts 5 to 31 are reserved by INTEL for complex Processors Upper 224 interrupt types ( 32 to 255) available to use for hardware or software interrupts.
9/4/2012
15
Interrupt Type zero INT 0 Divide by zero interrupt. If the quotient is too large to fit into AL/AX Divide by zero interrupt invoked. Interrupt Type one INT 1 Single step Interrupt If trap flag is set 8086 will do a type 1 interrupt after every instruction execution.
Naveen Kr. Dubey (ECE DEPT ..RKGITW) 9/4/2012 16
Non Maskable Interrupt Type 2 When 8086 receives a low to high transition on its NMI input.
9/4/2012
17
The system execute instruction up to break point and then goes to break point routine. Used for debugging. Overflow Interrupt Type 4
INTO: Interrupt on overflow instruction used for invoking an interrupt after overflow in an arithmetic operation. If no overflow it will be a NOP instruction.
9/4/2012
18
Interrupt Priority
HIGH
LOW
9/4/2012
19
What if 8086 receives INTR while executing DIV which produces divide-by-zero error? 8086 executes INT 00 (as it has higher priority) This clears the IF and thus disables INTR Complete routine of INT 00 is executed and in the end IRET is executed This enables the INTR again Now INTR will be processed
9/4/2012
20
What if 8086 receives NMI while executing DIV which produces divide-by-zero error?
9/4/2012
21
Operand types: REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. SREG: DS, ES, SS, and only as second operand: CS. memory: [BX], [BX+SI+7], variable, etc...(see Memory Access). immediate: 5, -24, 3Fh, 10001101b, etc...
9/4/2012
22
Notes: When two operands are required for an instruction they are separated by comma. For example: REG, memory When there are two operands, both operands must have the same size (except shift and rotate instructions). For example: AL, DL DX, AX m1 DB ? AL, m1 m2 DW ? AX, m2
9/4/2012
23
Some instructions allow several operand combinations. For example: memory, immediate REG, immediate memory, REG REG, SREG
9/4/2012
24
These marks are used to show the state of the flags: 1 - instruction sets this flag to 1. 0 - instruction sets this flag to 0. r - flag value depends on result of the instruction. ? - flag value is undefined (maybe 1 or 0).
9/4/2012
25
9/4/2012
26
9/4/2012
27
9/4/2012
28
9/4/2012
29
9/4/2012
30
9/4/2012
31
9/4/2012
32
CLC Clear Carry Flag CLD Clear Destination Flag CLI Clear Interrupt Flag (this disables H/W interrupts ) CMC Compliment Carry Flag CMP - REG, memory
memory, REG REG, REG memory, immediate REG, immediate
result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according to result.
Naveen Kr. Dubey (ECE DEPT ..RKGITW) 9/4/2012 33
Compare bytes: ES:[DI] from DS:[SI]. Algorithm: DS:[SI] - ES:[DI] set flags according to result: OF, SF, ZF, AF, PF, CF if DF = 0 then SI = SI + 1 DI = DI + 1 else SI = SI - 1 DI = DI - 1
9/4/2012
34
CMPSW
Compare words: ES:[DI] from DS:[SI]. Algorithm: DS:[SI] - ES:[DI] set flags according to result: OF, SF, ZF, AF, PF, CF if DF = 0 then SI = SI + 2 DI = DI + 2 else SI = SI - 2 DI = DI - 2
9/4/2012
35
CWD
Convert Word to Double word. Algorithm: if high bit of AX = 1 then: DX = 65535 (0FFFFh) else DX = 0 Example:
MOV DX, 0 ; DX = 0 MOV AX, 0 ; AX = 0 MOV AX, -5 ; DX AX = 00000h:0FFFBh CWD ; DX AX = 0FFFFh:0FFFBh RET
9/4/2012
36
DAA
DAS
Decimal adjust After Addition. Corrects the result of addition of two packed BCD Values Decimal adjust After Subtraction. Corrects the result of subtraction of two packed BCD values.
9/4/2012
37
Decrement.
Unsigned divide. Algorithm: when operand is a byte: AL = AX / operand AH = remainder (modulus) when operand is a word: AX = (DX AX) / operand DX = remainder (modulus)
9/4/2012
38
IDIV
Signed divide. Algorithm: when operand is a byte: AL = AX / operand AH = remainder (modulus) when operand is a word: AX = (DX AX) / operand DX = remainder (modulus) Example:
MOV AX, -203 ; AX = 0FF35h MOV BL, 4 IDIV BL ; AL = -50 (0CEh), AH = -3 (0FDh)
9/4/2012
39
Signed multiply. Algorithm: when operand is a byte: AX = AL * operand. when operand is a word: (DX AX) = AX * operand. Example:
MOV AL, -2 MOV BL, -4 IMUL BL ; AX = 8 RET
9/4/2012
40
IN (AL, im.byte AL, DX AX, im.byte AX, DX) INC (reg, memory) INT (immidiate byte) INTO
Input from port into AL or AX. Second operand is a port number. If required to access port number over 255 DX register should be used Increment. Interrupt numbered by immediate byte (0..255).
9/4/2012
41
IRET
LAHF
Interrupt Return. Pop from stack: IP CS flags register Load AH from 8 low bits of Flags register. Algorithm: AH = flags register
9/4/2012
42
LDS
Load memory double word into word register and DS. Algorithm: REG = first word DS = second word
LES
Load memory double word into word register and ES. Algorithm: REG = first word ES = second word
9/4/2012
43
9/4/2012
44
LODSB
LODSW
Load byte at DS:[SI] into AL. Update SI. Algorithm: AL = DS:[SI] if DF = 0 then SI = SI + 1 else SI = SI 1 Load word at DS:[SI] into AX. Update SI.
9/4/2012
45
LOOP
LOOPE
LOOPNE
LOOPNZ LOOPZ
Decrease CX, jump to label if CX not zero and Not Equal (ZF = 0). ZF=0 ,CF!=0
ZF=1 ,CF!=0
9/4/2012
46
9/4/2012
47
9/4/2012
48
9/4/2012
49
9/4/2012
50
9/4/2012
51
9/4/2012
52
9/4/2012
53
9/4/2012
54
9/4/2012
55
9/4/2012
56
9/4/2012
57
9/4/2012
58
9/4/2012
59
9/4/2012
60
9/4/2012
61
9/4/2012
62
9/4/2012
63
9/4/2012
64
9/4/2012
65
9/4/2012
66
9/4/2012
67
9/4/2012
68
9/4/2012
69