Ekeeda explains 8086 data transfer instructions (MOV, PUSH/POP, IN/OUT, XCHG), covering source-destination transfers, flag effects, and stack operations.
Key Takeaways
- Data transfer instructions move data between memory, registers, and I/O ports.
- MOV requires matching operand sizes and does not change flags.
- PUSH and POP operate on the stack by adjusting the stack pointer by 2 for each 16-bit word.
- IN/OUT handle port I/O through the accumulator without affecting flags.
- XCHG swaps the contents of two operands.
What the video covers
- Introduces data transfer instructions in the 8086 instruction set, which copy data from a source to a destination.
- Sources and destinations can be memory locations, internal registers, or input/output ports.
- Four instruction groups are covered: MOV, PUSH/POP, IN/OUT, and XCHG.
- MOV copies data between register and register, memory and register, register and memory, or from immediate data.
- Source and destination must be the same size (8-bit or 16-bit) for MOV.
- MOV does not affect any flags because data is only copied, not altered.
- Examples illustrate immediate, direct/indirect memory addressing, and segment register moves such as MOV DS, CX.
- PUSH and POP store and retrieve temporary data on the stack, using the stack pointer and stack segment.
- PUSH decrements the stack pointer by 2 before storing a word; POP copies data and then increments the stack pointer.
- IN and OUT transfer data between input/output ports and the accumulator, with flags unaffected.
Full Transcript — Download SRT & Markdown
Speaker A
Do subscribe to Ekeeda channel and press bell icon to get updates about latest Engineering HSC and IIT-JEE Mains and Advanced videos.Hello Friends, In this video we will study about the various data transfer instructions like move in and out push
Speaker A
and pop exchange instructions which are available in the instruction set of eight zero eight six Microprocessor.
Speaker A
The advance where instructions are those instructions which transfers the data from one position to another position okay so from one place to another place if you want to transfer the data or we want to move or copy the data then we
Speaker A
use these data transfer instructions. So these data transfer instructions they are basically used to transfer the data now this data transfer takes place from a source place to the destination that is the data is picked from the source
Speaker A
place and then it is copied or transfer to the destination place okay so source and destination they are the two places now these two places can be either a memory location or a register okay so the data transfer instructions
Speaker A
they are used for transfer of data from memory to the internal register means memory will be the source and internal register will be the destination also from the internal register to memory so in this case internal register will be
Speaker A
the source and memory will be the destination then from one register to another register means between the register also if we want to transfer the data then also we can use the data transfer instructions and then from input port to the internal register if
Speaker A
the microprocessor it wants to read some data from the input port then that data will be transferred from the input port to the internal register so that is input port will be the source and internal register will be the
Speaker A
destination similarly if the microprocessor it is sending some data on the output port so destination will be the output port and source will be an internal register so here in these transfer of data we have the two pieces
Speaker A
source and the destinations okay so there can be different places for it now in these data transfer instructions depending upon the source and the destination switch either memory Susan or the register or an internal for register or input port output port so
Speaker A
depending upon it we have the various data transfer instructions in this we have first is the move instruction second we have and pop third we have in and out and food we have the exchange instruction so these four instructions they come under
Speaker A
the category of data transfer instructions let us study these instructions one by one first we will start with the move instruction so this move instruction it is used to transfer the data between register to register from memory to the register
Speaker A
from register to a memory location or with the immediate data so here the transfer of data takes place the data is not transfer it is just copied from the source to the destination okay so this instruction when the transfer of
Speaker A
data takes face means the data from the source it is copied to the destination so the source and destination they need to be of the same size it means that the if the source is having a data which is
Speaker A
of 8-bit then the destination place should also be of 8-bit so that that data can be transferred also if sources of 16-bit destination should also be a 16-bit so the size of the source and the destination they have to be equal this
Speaker A
move instruction it does not affect any of the flags in the flat register like carry auxilary Carrie sign parity 0 overflow all these flags are not affected due to this move instruction because no changes in the data is taking
Speaker A
place only just it is copied from one place to another place so it does not affect any flags now let us take some examples of this move instruction this instruction move B X comma 0 0 F 2 H it is transferring this image a data
Speaker A
into the internal register B X so this 0 0 F 2 H it is a 16-bit data this is transferred to the base register BX BX is also 16-bit register which is happing BH and BL the higher order
Speaker A
register and the lower order register so 0 0 will be stored here and f2 will be stored in the lower byte so here the size of the source and destination you can see that it is safe it is a 16-bit data so that this
Speaker A
destination is also a 16-bit ok and this type of addressing where the mej data it is available in the instruction itself that is the immediate addressing mode next example we have for move as move CL mm H so here in this instruction the
Speaker A
data which is stored at a memory location that data will be transferred to the CL register CL is the lower order register for the count CX we have CH and CL this is the counter register it is also 16-bit but it can be
Speaker A
divided into 2 8 bit register higher order and lower order so CL here it is an 8 bit resistor and 2008 it is an effective address so this address mm will be added into the data segment address that is segment address
Speaker A
multiplied with 10h that will be the physical address of the memory location so that memory location the 8 bit data is stored so that 8 bit data will be copied into the CL register okay so here we have indirectly given the data so
Speaker A
does a type of indirect addressing okay next time so this is the transfer of data between a register under mej data here we have taken that the transfer of data is between a memory location and ER register this is between the register
Speaker A
and the memory location source is the register and destination is the memory location so five eight nine it is also the effective address that will be added into the data segment address and then the physical address of the memory
Speaker A
location will be obtained so the data the 16-bit data which is available at this in this register base register that will be copied into the memory location okay next example we have is move d s comma c x so in this CX is a 16-bit
Speaker A
register data segment is also a 16-bit register so the contents of this resistor will be copied into the data segment register okay so this is the transfer of data between two registers so the move instruction it is transferring the data between
Speaker A
register to memory memory to register and also from an image a data to the register or image a data to a memory location between the register also it is transferring the data so data is just copied from the source to the
Speaker A
destination okay next type of instruction we have is the push instructions push and pop instructions these two instructions are used to store or retrieve the data from the stack whenever we want to use the stack to store the some temporary data then we
Speaker A
use the push instruction to store the data and pop instruction to retrieve the data from the stack now let's see that how this push push instruction it executes now in the push instruction it is used with the stab
Speaker A
so whenever the stack is used it is always initialized for to a memory location so this initialization of the stack it is you are done with the help of the stack pointer okay so stack pointer it points to the
Speaker A
beginning address from where the stack is starting so suppose we have initialized the stack so the stack pointer it is going to point at this memory location suppose we have given here 30,000 H so stack pointer stack is
Speaker A
going to store the data through this push instruction into the stack so first it is going to decrement the stack pointer by 2 and it is going to copy the word from source to the location where stack pointer now points so this push
Speaker A
instruction it is first going to decrement the stack pointer by 2 so this is stack pointer this is stack pointer minus 1 this is stack pointer minus 2 so it is going to be decremented by 2 so now the stack pointer is going to point
Speaker A
at this memory location so the data is going to be stored first at this memory location then this and then this so in this way the data is stored in the stack let us take an example so that it will
Speaker A
be more clear to you push CX means CX is the come transistor the contents of the count register it will be a 16-bit register so that will be stored in the stack so suppose we have initialized the stack pointer at 0
Speaker A
0 3 4 that is the stack pointer and we have the stack segment because the stack is is stored in the segment which is known as stack segment okay that segment is assigned for the step only so stack
Speaker A
segment is initialized at an address 3000 okay so 3,000 this stack segment it will be multiplied with 10 H and then this will be added with the stack pointer so the address we will get is 30,000 plus 0 0 3 4 so we are getting 3
Speaker A
0 0 3 4 this is the address now at this address the stack is initialized now push instruction it is going to decrement the stack pointer by 2 so first it will be decremented to 0 0 3 3
Speaker A
then it will be decremented to 0 0 3 2 so now the stack pointer it is pointing at the memory location 3 0 0 3 2 now contents of the CX register it will be c h and the CL CH is suppose it is having
Speaker A
20 and CL it is having 30 okay suppose the lower order register will be stored at three zero zero three two again it is going to be decremented and then the higher order register will be stood so here 20 will
Speaker A
be to the 30 will be stored and here 20 will be stored so whenever this Porsha instruction is used the stack pointer wherever it is initialized it is decremented by two and then the contents of the source register that will be
Speaker A
stored in the stack okay so always remember that you have to decrement the address by two in the case of push instructions next instruction we have is hope pop instruction is used to retrieve the data from the stack so
Speaker A
whenever we want that we want to get the contents of the stack we use the pop instruction the execution of this instruction it is similar to the push instruction but in the case of push instruction the address is decremented
Speaker A
by 2 whereas in case of the pop instruction the address is incremented by 2 suppose taking the same example we were having this was the memory location where the stack was initialized then stack is decremented to the memory
Speaker A
location 32 here the lower order address for these store and here the higher order address 20s tone now if we want to get this data we will write here pop CX means we are going to pop the contents of the stack and we are going
Speaker A
to stored it in the CX register so first this xx will be taken out and it will be stored at CH and then 30 will be taken out and it will be stored at CL so in this case the addresses are incremented
Speaker A
okay so that is the difference between push and pop so this pop instruction it copies the word from the stack location which is pointed by the stack pointer because now the stack pointer is pointing to this memory location so from this it will be
Speaker A
copied into the destination and when the content is copied the stack pointer is again decremented by two so now the stack pointer it is going to point at this memory location okay so this is the pop instruction push and pop are used in
Speaker A
the case of stack next instruction we have are the in-and-out instructions these instructions are used to transfer the data from the input and the output oops so instruction is used to copy the data from the input conductivity and how
Speaker A
instruction is going to pop your data from the accumulator to the output book let us see some examples of this so here this data it is copied from the port address 0 f8 because the ports they are there are 256 input/output ports in case
Speaker A
of 8 0 8 6 so their addresses will be from 0 0 0 to F F F so here we have the address of one of the port that is 0 F 8 and the data which is there at this spot
Speaker A
will be copied into the L register ok then we have I n L comma D X suppose after this we have written an instruction move DX comma 0 4 3 f 8h so this will be copied into the data
Speaker A
segment register that is data register D X and then DX will be copied into the accumulator register okay so here that 8-bit data will be copied from the location first that data will be stored into the DX and then DX will be copied
Speaker A
into the L register okay for out similarly we have out so here are the contents of the lower order accumulator register that will be stored at an output port which is whose address is 0 4 7 H okay again here also we can have
Speaker A
an indirect addressing also first we are going to store the data in the register and then that register will be copied on to the output port so here in this way you can see that the data it is
Speaker A
copied from the input port to the accumulator and output instruction out instruction it is copying the data from the accumulator to the output port also now here also know the flags are not affected because just the transfer of
Speaker A
data is taking place next instruction we have is the exchange instruction exchange instruction it is used to exchange the contents of two locations like between register to register also and from register to memory location also it can exchange the contents
Speaker A
so this instruction it exchanged the contents of the destination and the source now we are the destination and source it can be bit to the register and register their contents can be exchanged and registered in memory location their
Speaker A
contents can also be changed but the exchange instruction it cannot exchange the contents of two memory locations you can see here that the source and destination I have not written that between two memory locations it is exchanging the contents so it is an
Speaker A
exception that the exchange instruction it does not exchange the contents of any two memory locations so this exchange instruction it basically exchanges the contents of the source and the destination let us take some examples here so these are some of the exchange
Speaker A
instructions in this first instruction the contents of the BX and the CX register they are exchanged both these resistors are 16-bit registers so their contents can be easily exchanged here now exchange L and Cl both these registers are 8-bit register so 8-bit
Speaker A
content can also be exchanged just keep in mind that the size of the source and the destination it is same because a 16-bit data cannot be exchanged with an 8-bit data so here 16-bit data's are exchanged here 8-bit data is exchanged now here we have
Speaker A
exchanged the contents of the ax register with the contents of this memory location this memory location its address is obtained by adding the data segment address vs multiply it with 10h plus the sum which is the displacement provided in the instruction Plus this BX
Speaker A
register contents so this is collectively forming the physical address of the memory location where the data is stored so that 16-bit data will be exchanged with the X register so here you can see that the contents of the
Speaker A
source and the destination they are exchanged the source can be a register or a memory location on destination can also be a memory location but to exchange between two memory locations it cannot be done using this instruction so
Speaker A
here in this video we have studied about the data transfer instructions move portion pop in and out and exchange instructions these instructions are used whenever we want to transfer the data from the source to the next nation so I hope that this topic is
Speaker A
clear to you thank you
Topics:8086 microprocessordata transfer instructionsMOV instructionPUSH POPstack pointerIN OUT instructionsXCHGaddressing modesinstruction setassembly language











