Arithmetic and Logical Instructions of 8086 Microprocessor – Microprocessor

Arithmetic and Logical Instructions of 8086 Microprocessor – Microprocessor


Do subscribe to Ekeeda channel and press bell icon to get updates about latest Engineering HSC and IIT-JEE Mains and Advanced videos. The arithmetic and logical instructions they are used to perform the arithmetic and logical operations like addition subtraction logical and logical or compare increment decrement so whenever these operations are to be performed in eight zero eight six these instructions are used so let us start with our first instruction which is used for addition that is add, The mnemonic of these this instruction addition is A D D so whenever we want to use this instruction we are going to write A D D ad in the main program so this add instruction it is used to add the contents of the destination and the source and the result of this addition it is stored in the destination ok here we can use the source and destination it can be the registers also it can be an image a data also it can be a memory location also with this instruction and instruction it is used with all the flags like carry auxilary carry side and parity zero overflow all these flags are affected so we can say that all the flags are modified and we can check the status of the result in these flags that if in the case of addition any caddy is generated if the addition has generated a zero then how many number of ones are there so we can check all the flags all the flags will be affected through this instruction let us take an example if you talk about the general format of this instruction then generally it is written as ad then destination is written and then source is specified so source is added with the destination and result is stored in the destination itself let’s take examples this is an example there an 8-bit data is added with the contents of the L register L is the lower order accumulator register so this resistor is also an 8-bit register so the contents of this register are added with this immediate data 0fh and the result is stored in the L register only this ad X comma BX this instruction it is going to add the contents of the BX resistor and the X register and result will be stored in the ax because if we compare it with this then destination is a and source is the BX so result is going to stored in the destination okay ax and BX both are 16-bit registers so the result will be also a 16-bit or more than it you can also be generated okay so 16-bit numbers are added here we are adding the 8-bit numbers now this is an example where we are adding the contents of the X register with the memory location and the address of that memory location is calculated by adding the data segment with the source index register okay so the address will be data segment multiplied with NH plus the source index so that will be the address of the memory location and at that memory location the data is stored so that data will be added up with the accumulator register and result is a student accumulator okay suppose this type of instruction is written at 0 1 0 0 edge so here the operand it is specified in the instruction itself the operand is implicit here so this is a type of implicit addressing here by default we use the destination register as the accumulator so one of the operand will be accumulator its contents are added with this data 0 1 0 0 and the result will be stored in the accumulator itself so when we are not specifying oprand in the instruction that type of addressing mode is called the implicit addressing mode so this is the addition and instruction through which we are adding the contents of either two resistors or register and a memory location or an imaging data with the register or the memory location okay next we have the addition with carry we are using the carry flag here and this caddy flag along with the data it will be added with the contents of the destination the mnemonic for this instruction is a DC we are going to write a DC in the main program to use this instruction so this is adding the contents along with the carry so this ADC instruction it also performs the addition operation but it also adds the carry plaque bit to the result now this Daddy plaque bit it may be set or he said you do some previous instructions which are executed so that carry flag bit if it is 1 or 0 then that bit will be added to the destination along with the source contents and the result will be stored in the destination also all the flags are affected due to this instruction the carry flag parity flag all the flags will be affected now if we take the examples so here we are writing the mnemonic ABC and we are adding the contents of ax and BX register along with the carry flag here X and the address of the memory location which is obtained by adding the data segment at the source index that memory location that data plus the accumulator register and the carry flag then here we have the address of the memory location data segment Plus this 5,000 so that memory location data is stored there that data will be added with the ax register and plus the carry flag and result is stored in the ax here accumulator carry flag and this data it will be added and a result will be stored in the accumulator so these are the examples of the add will carry instruction next instruction we have is for the subtraction su be the mnemonic for this the code is su B we are going to write su be to use this instruction in the main programs so this instruction it is used to subtract the contents of their destination with that of the source and store the result in the destination so destination will be subtracted from the source and result is stored in the destination through this instruction also all the flags will be modified so let us see the examples of this instruction SUV if we talk about its Jordan format then we will write SUV destination and source so we can have SUV so these are the examples of this instruction in this the 0f data that is subtracted from the L that is the lower order register of the accumulator that will be subtracted and the result is stored in the L register here BX is subtracted from the X that is X minus BX is executed here the contents of the memory location they are subtracted from the X register contents however this data is subtracted the data at this memory location it will be subtracted from the it’s register so these are some of the examples of the subtraction okay next instruction we have is subtraction with borrow just like they are having the addition with carry then we are having here the subtraction will borrow ok for this we will write the mnemonic SBB like s subtract with borrow so when we are using this instruction subtraction with borrow means we are subtracting the source of rent and the borrow flag borrow flag means the carry flag caddy flag it is used as both the for addition and for subtraction also in case of subtraction it is treated as the borrow flag so borrow flag is just the carry flag and we are subtracting the source and this flag with the destination okay this means that we are subtracting one from the subtraction which is obtained by this SUV instruction so the subtraction is the same but we are subtracting one also from this through this SBB instruction examples of this instruction are so examples are like the same we are writing you the SBB instead of SUV and we are subtracting this content plus the borrow flag with this accumulator register also you are the BX resistor borrow flag add vector from the ax register okay here also all the flags will be modified and the result of this operation will be stored in the destination next instruction we have is now compare for this instruction we have the mnemonic cmp so we are going to write cmp in the main program to use this instruction now this instruction it is used to compare the contents of two registers like whether these two contents they are equal to each other or they are greater than or less than each other so this comparison is done using this instruction so this register instruction compare it is going to compare the source operand which can be a register or an image a data or a memory location with the destination operand which can be a register or a memory location so in comparison it is going to compare the source and the destination by subtraction so this comparison is done by subtracting the source operand from the destination and the result of this subtraction it does not store anywhere just the carry flags the flags are chained suppose if the source and the destination they are equal to each other so when they are subtracted then zero flag will be set because the result of the subtraction will be a zero because both are equal so zero flag will be set so if both source and destination they are equal then zero flag is set if suppose source is greater than the destination then carry flag is set means it will be equals to 1 and if source is less than the destination then carry flag is reset means it will be 0 so this comparison is done by checking the 0 and the carry flags if they are set or reset then the N type interpretations are made that whether the contents are equal to each other or they are greater than or less than to each other so let’s take some of the examples of this compare instruction so these two instructions are an example of immediate addressing where the immediate data it is available in the instruction itself and this data is going to be compared with the BX transistor so these two operands they will be subtracted from each other and then the zero flag and the carry flag they will be checked we have some other examples of this instruction also where the contents of this BX register and the address of the memory location which is specified by the source index plus the data segment that memory location is having the data so that data will be compared with the B X here the contents of the BX + CX registers are compared so these are some of the examples of the compare instruction next instructions we have other increment and decrement instructions these instructions are used to increment or decrement the contents of the registers these instructions they are also affect all the flags auxilary carry carry all the flags are modified example of these instructions are so these incl and int X they are going to add the lower order register accumulator register so L plus 1 will be done and the result will be stored in the AL register so this will be incremented by 1 then X register it is also incremented by 1 through this dec decrement is done so al will be decremented by 1 on a X is decremented by 1 so these instructions are used to increment our decrement the contents of the specified destination next we have the logical instructions like logical and or exhort not all these logical operations can also be performed through 8 0 8 6 first we have the and instruction this instruction it is going to add the contents of the source and the destination and the result is stored in the destination okay now we are every bit of the source and operand and the destination they are going to be ANDed with each other so this and instruction it is going to logically and each bit of the source white and gold with the corresponding bit of the destination so suppose the sources having an 8-bit data and that it be data is having the bits from D naught to d7 the destination is also having an 8-bit data from D naught to d7 so every bit will be ended with each other D naught of source will be ended with the D naught bit of the destination similarly d7 will be acted with the d7 bit of the destination so corresponding bits they will be ended with each other and the result of this operation is a stored in the destination you have the Cadi flag and the over flag overflow flag they are set to zero and the zero flag parity Flag signs and they will be affected and auxilary carry flag it is undefined if we see the general format of this instruction then we have this and then destination and then source so the destination and source they are specified in the instruction and their bits will be handed with each other let’s take some examples and B L and L registers both these resistors are 8-bit registers suppose BL is having the content this and L is having then both these builds they are registers bits they will be ANDed with each other so we will get so this result of this operation will be stored in the BL register so each bit you can see that each bit is ANDed with each other and the corresponding result is obtained okay just like this this was an 8 bit and operation here we can have C X and X both are 16 bits so we can have the 16 bit and operation also so the contents of CX are ANDed with the contents of the X register now this was the example of the and instruction next we have is the logical or instruction where the all operation is performed between the source and the destination mnemonic is all you so this is also going to logically or each bit of the source and the destination here flags are also modified just like the logical and we are going to set the carry flag and the overflow flag are made to zero zero flag parity flag sign flag they will be affected and auxilary carry flag it is undefined so if we take the examples it’s general format will be we are going to write the whole instruction then we will write the destination and then source so if we take the examples we have or BL comma L so suppose BL is having the 8-bit data as 1 0 0 0 0 1 1 0 L is having the data so these are two registers they will be logically odd with each other so we will have 1 1 0 0 & 1 1 1 0 this will be the result of this operation and it will be stored in the BL register also we can have or see X comma X so these two 16-bit register they can also be logically or with each of them so corresponding bits of the source and the destination they are logically odd and the result of this operation is stored in the destination register next instruction we have is the not instruction this instruction is going to complement the bits of the register which is specified in the instruction complement means that if it’s bit is 1 then it will be made 0 if it is 0 then it will be made 1 ok complements or we can say invert the contents of an operand this operand can be a memory location or a register so it’s format will be like not and we are going to write here the operand if we take examples of this instruction not X so X is a 16-bit register suppose its contents are this was the content it was a 16-bit so we can write here suppose this was the content when this operation is performed so X new contents will be so one is change to zero and zero is changed to one so these are the new contents of the ax register after applying this instruction not next instruction we have is the zuhr instruction this instruction is going to perform the illogical exhortation between the source and the destination so logical exalt operation it says that the when the two bits of the souls and the operand they are dissimilar to each other then we will get a high on the output okay so if we take 0 0 0 1 1 0 & 1 1 then 0 0 will produce 0 1 1 will also produce 0 when the two bits are dissimilar to each other then we will get a high at the output so in this way the bits of the source and the operands they will be checked when both the bits are dissimilar to each other then in the result we will get high that means 1 and if the bits are similar to each other then we will get a 0 if we take an example X or X comma 0 0 9 8 H so this is the mej date now and this will be compared with the contents of the X register so both will be logically exhort with each other and the result of the operation will be stored in the accumulator register so suppose that of the eggs it is having the contents these are the contents of the X register it is a 16-bit register now we are having 0 0 9 8 so 0 0 9 & 8 we are going to logically or this XOR this so 1 0 the bits are dissimilar so we will get 1 0 0 bits are similar we are going to get 0 1 0 dissimilar 1 1 similar similar so this will be the result of this operation and it will be stored in the ax register so this was the logical exalt operation we are going to write eggs or and the destination and source ok so we have studied about the logical instructions which are represent which are available in the eight zero eight six microprocessor instruction set we studied the arithmetic and logical instructions like in arithmetic we studied addition subtraction addition with carry subtraction with borrow and increment decrement compare in logical we studied the logical and or and XOR and not operations so in this video we studied about all the arithmetic and logical instructions which are available in the instruction set of eight zero eight six microprocessor I hope that this topic is clear to you thank you

One thought to “Arithmetic and Logical Instructions of 8086 Microprocessor – Microprocessor”

Leave a Reply

Your email address will not be published. Required fields are marked *