MP - Unit 4
MP - Unit 4
MP - Unit 4
The basic logic instructions include AND, OR, Exclusive-OR, and NOT.
Another logic instruction is TEST.
NEG instruction which is somewhat similar to the NOT instruction.
Logic operations provide binary bit control in low-level software.
The logic instructions allow bits to be set, reset, or complemented.
All logic instructions affect the flag bits.
AND
Instruction performs Logic AND operation between Destination & Source
PF, SF & ZF are updated
Destination can be register or memory location.
Source can be register or memory location.
When both inputs are 1 output is 1 else 0
Ex. AND AL, CL ; AL = AL AND CL
If AL = 47H = 0100 0111
& CL = 36H = 0011 0110
Then AL = 0000 0110 = 06 H
OR
This instruction performs Logic OR operation between destination and source.
Destination can be register or memory location.
Source can be register or memory location.
When either input is 1 output is 1 else 0
Ex. OR AL, CL ; AL = AL OR CL
If AL = 47H = 0100 0111
& CL = 36H = 0011 0110
Then AL = 0111 0111 = 77H
NOT
Performs the 1’s complement operation on the destination.
The result is stored in destination
Ex. NOT AX
If AL = 0100 0111
Then NOT AL = 1011 1000
EX - OR
This instruction performs Logic XOR operation between Destination and source.
Destination can be register or memory location.
When both inputs are same output is 0 else 1
Source can be register or memory location.
Ex. XOR AL,CL ; AL = AL XOR CL
If AL = 47H = 0100 0111
& CL = 36H = 0011 0110
Then AL = 0111 0001
Test Instructions
The TEST instruction performs the AND operation between destination and
source.
Destination can be register or memory location.
Source can be register or memory location.
Result is not stored in register or memory location.
A TEST only affects the condition of the flag register, which indicates the result
of the test.
Uses the same addressing modes as that of AND instruction.
ZF = 1(indicating a zero result) if the bit under test is a zero.
ZF = 0(indicating a nonzero result) if the bit under test is not zero.
2. Near Jump
3 byte instruction
Allows jump to locations within +32kb and -32kb bytes
3. Far Jump
5 byte instruction
Allows jump to any locations within real memory system
MNEMONIC Jump IF
JNC CF = 0
2. WAIT
Pause fetching and execution of the instruction.
Enters into IDLE state
Comes out of this state when a high (1) signal is received from TEST pin or a
valid interrupt signal is received.
Used to synchronize 8086 with peripheral devices.
3. ESC
Used to pass instruction to a co-processor like 8087
6 bit instruction is embedded ESC instruction.
8086 treats ESC as NOP
4. LOCK
In multiprocessor configuration.
Different microprocessor share a system bus
When a microprocessor needs exclusive use of the system bus for a particular
instruction.
5. NOP
No operation is done
3 clock cycles
Time delay can be provided
Does not affect any flag.
1. Hardware Interrupt
These interrupts occurred by externally connected peripheral devices (Ex.
Keyboard).
8086 has 2 pins to accept hardware interrupt NMI and INTR
2. Software Interrupt
These interrupts are caused by writing the software interrupt instruction INTn
where ‘n’ can be any value from 0 to 255 (00H to FFH).
6. INT 5 to INT 31
Reserved by INTEL for higher microprocessors like 80386, Pentium, etc.
Hardware Interrupt
1. NMI (Non Maskable Interrupt)
High priority interrupt
On receiving an interrupt on NMI line microprocessor executes INT 2.
2. INTR
Low priority interrupt
Maskable interrupt
On receiving an interrupt on INTR line microprocessor executes 2 INTA pulse.
1st INTA pulse- the interrupting device calculates the vector number
2nd INTA pulse -the interrupting device sends the vector number ‘N’ to the
microprocessor.