A microprocessor is an electronic component that is used by a computer to do its work. It is a central processing unit on a single integrated circuit chip containing millions of very small components including transistors, resistors, and diodes that work together. Some microprocessors in the 20th century required several chips. Microprocessors help to do everything from controlling elevators to searching the Web. Everything a computer does is described by instructions of computer programs, and microprocessors carry out these instructions many millions of times a second. [1]
Microprocessors were invented in the 1970s for use in embedded systems. The majority are still used that way, in such things as mobile phones, cars, military weapons, and home appliances. Some microprocessors are microcontrollers, so small and inexpensive that they are used to control very simple products like flashlights and greeting cards that play music when you open them. A few especially powerful microprocessors are used in personal computers.
Report
Share
Report
Share
1 of 5
More Related Content
Notes arithmetic instructions
1. Arithmetic Instructions
1. ADD Destination,Source
• Thisinstructionisusedto add the contentsof source to the destination.
• The resultisstoredin the destination.
• The source operandcanbe a immediate,aregisterora memorylocationaddressedby
any of the 24 addressingmodes.
• The destinationcanbe a registerora memorylocation,butnotan immediate data.
• Both operandscannotbe immediate dataormemorylocation.
• The source andthe destinationmustbe of the same data type i.e.,ADDinstruction adds
a byte to byte or a wordto word.
• It affectsAF,CF,OF, PF,SF,ZF flags.
E.g.:
ADD AL, 74H
ADD DX,AX
ADD AX,[BX]
2. ADC Destination,Source
• Thisinstructionisusedto add the contentsof source to the destinationandcarry flag.
• The resultisstoredin the destination.
• The source operandcanbe a immediate,aregisterora memorylocationaddressedby
any of the 24 addressingmodes.
• The destinationcanbe a registerora memorylocation, butnotan immediate data.
• Both operandscannotbe immediate dataormemorylocation.
• The source andthe destinationmustbe of the same data type i.e.,ADDinstruction adds
a byte to byte or a wordto word.
• It addsthe twooperandswithCF.
• It effects AF,CF,OF,PF,SF, ZF flags.
E.g.:
ADC AL,74H
ADC DX,AX
ADC AX,[BX]
3. SUB Destination,Source
• Thisinstructionisusedto subtract the contentsof source from the destination.
• The resultisstoredin the destination.
• The source operandcanbe a immediate,aregisterora memorylocationaddressedby
any of the 24 addressingmodes.
• The destinationcanbe a registerora memorylocation,butnotan immediate data.
• Both operandscannotbe immediate dataormemorylocation.
• The source andthe destinationmustbe of the same data type i.e.,SUBinstruction
subtractsa byte frombyte or a word fromword.
• It affectsAF,CF,OF, PF,SF,ZF flags.
• For subtraction,CFacts as borrow flag.
E.g.:
SUB AL, 74H
SUB DX, AX
SUB AX, [BX]
4. SBB Destination,Source
• Thisinstructionisusedto subtract the contentsof source withborrow from the
destination.
• The resultisstoredin the destination.
• The source operandcanbe a immediate,aregisterora memorylocationaddressedby
any of the 24 addressingmodes.
• The destinationcanbe a registerora memorylocation,butnotan immediate data.
• Both operandscannotbe immediate dataormemorylocation.
2. • The source andthe destinationmustbe of the same data type i.e.,SUBinstruction
subtractsa byte frombyte or a word fromword.
• It affectsAF,CF,OF, PF,SF,ZF flags.
• For subtraction,CFacts as borrow flag.
E.g.:
SBB AL, 74H
SBB DX, AX
SBB AX,[BX]
5. INC Destination
• It incrementsthe byte orwordin destination byone.
• The destinationoperandcanbe a registerora memorylocationaddressedbyanyof the
24 addressingmodes.
• It affectsAF,OF,PF,SF, ZF flags.
• CF isnot affected.
E.g.:
INC AX
INCBL
6. DEC Destination
• It decrementsthe byte orword indestination byone.
• The destinationoperandcanbe a register ora memorylocationaddressedbyanyof the
24 addressingmodes.
• It affectsAF,OF,PF,SF, ZF flags.
• CF isnot affected.
E.g.:
DEC AX
DEC CL
7. DAA (Decimal Adjust Accumulator)
Syntax :-- DAA
• This instructionisusedtoconvertthe resultof the additionof twopackedBCD
numberstoa validBCDnumber.
• The resulthasto be onlyin AL.
• Afteradditionif the lowernibble isgreaterthan9 or AF =1, it will add06H to the lower
nibble inAL.
• Afterthisaddition,if the uppernibbleisgreaterthan9 or if CF = 1, DAA instruction
adds 60H to AL.
• DAA instructionaffectsAF,CF,PFandZF.OFisundefined.
OperationPerformed:--
– If lowernibble of AL> 9 or AF =1 thenAL = AL +06
– If highernibble of AL> 9 or CF =1 thenAL = AL +60
NumericExamples
AL = 53H, CL = 29H
ADD AL,CL ; AL AL + CL
;AL 53 + 29
;AL 7CH
DAA ; AL 7C +06 (asC>9)
;AL 82
8. DAS (Decimal Adjust AfterSubtraction)
Syntax :-- DAS
• This instructionisusedtoconvertthe resultof the subtractionof twopackedBCD
numberstoa validBCDnumber.
• The subtractionhasto be onlyin AL.
3. • Aftersubtractionif the lowernibble isgreaterthan9or AF=1, it will subtract06H from
the lowernibble inAL.
• If the resultof the subtractionsetsthe carry flag or if the uppernibble isgreaterthan9,
DAS instructionsubtracts60H fromAL.
• DAS instructionaffectsAF,CF,PFandZF.OFis undefined.
OperationPerformed:--
– If lowernibble of AL> 9 or AF =1 thenAL = AL -06
– If highernibble of AL> 9 or CF =1 thenAL = AL -60
NumericExamples
AL = 75, BH = 46
SUB AL,BH ; AL (AL) - (BH)
;AL 75 - 46
;AL 2FH
; AF = 1
DAS ; AL 2F - 06 (as F>9)
;AL 29
9. MUL (Unsignedmultiplication)
Syntax :-- MUL source
• This instructionmultipliesan unsignedbyte fromsource withan unsignedbyte in AL
register
or
Unsignedword fromsource withanunsignedwordin AX register.
• The source can be a registerormemorylocationbutcannotbe an immediatedata.
• Whena byte is multipliedwithabyte inAL, the resultisstoredinAX.
• Whena wordis multipliedwithawordinAX,the MSW (Most SignificantWord) of the
resultisstoredinDX and the LSW (LeastSignificantWord) of the resultisstoredinAX.
• If MS Byte or Word of the resultiszero,CF and OF bothwill be set.
• All otherflagsare modifieddependinguponthe result
OperationPerformed:--
– If source isbyte thenAX AL * unsigned8bitsource
– If source iswordthenDX, AX AX * unsigned16 bitsource
Examples:--
1. MUL BL ; MultiplyALby BL & the resultinAX
2. MUL CX ; MultiplyAXbyCX & the resultinDX,AX
3. MUL Byte PTR [SI] ; AX AL * [SI]
10. IMUL (Signedmultiplication)
Syntax :-- IMUL source
• This instructionmultipliesa signedbyte fromsource witha signedbyte in ALregister
or
signedword fromsource withan signedwordin AX register.
• The source can be a register,general purpose,base orindex,ormemorylocation,but
cannot be an immediate data.
• Whena byte is multipliedwithabyte inAL, the resultisstoredinAX.
• Whena wordis multipliedwithawordinAX,the MSW (Most Significant Word) of the
resultisstoredinDX and the LSW (LeastSignificant Word) of the resultisstoredinAX.
• If the magnitude of the productdoesnotrequire all the bitsof the destination,the
unusedbits are filledwithcopiesof the signbit.
• If AH and DX containparts of the 16 & 32 bit results,CFandOF are set,If the unused
bitsare filledbythe signbit,OFandCF are cleared.
4. OperationPerformed:--
• If source isbyte thenAX AL * signed8bit source
• If source iswordthenDX, AX AX * signed16 bit source
Examples:--
1. IMUL BL ; MultiplyALby BL & the resultinAX
2. IMUL CX ; MultiplyAXbyCX & the resultinDX,AX
3. IMUL Byte PTR [SI] ; AX AL * [SI]
•
11. DIV (UnsignedDivision)
Syntax :-- DIV source
• This instructiondividesanunsigned word(16Bits) in AX registerbyan unsigned byte
(8Bits) fromsource
or
an unsigned double word(32 bits) in DX & AX registerbyan unsigned word(16bits)
fromsource
• The source can be a registerormemorylocationbutcannotbe an immediate data.
• Whena word inAX isdividedbyabyte,AL will containthe 8 bitquotientandAHwill
containan 8 bitremainder.
• Whena double wordinDX(MSW) & AX (LSW) isdividedbyaword,AX will containthe
16 bit quotientandDXwill containan16 bitremainder.
• If a byte isto be dividedbya byte,ALis loadedwithdividendandAHisfilledwithall 0’s.
• If a wordis to be dividedbyaword,Ax is loadedwithdividendandDXis filledwithall
0’s.
• If an attemptismade to divide by0,or the quotientis toolarge (FFor FFFF),type 0
interruptisgenerated.
• No flagsare affected.
OperationPerformed:--
• If source isbyte then
• AL AX/ unsigned8bit source ; (quotient)
• AH AXMOD unsigned8bitsource ; (remainder)
• If source iswordthen
• AX DX:AX / unsigned16 bitsource ; (quotient)
• DX DX:AXMOD unsigned16 bitsource ; (remainder)
Examples:--
1. DIV BL ; Divide wordinAXby byte in BL, Quotientisstoredin AL,
remainderinAH.
2. DIV CX ; Divide double wordinDX:AX bywordinCX,QuotientinAX,
RemainderinDX.
3. DIV [BX] ; Divide wordinAXby byte in memorylocationpointerby BX.
12. CBW (ConvertSignedByte to Word)
Syntax :-- CBW
• This instructionconvertsasignedbyte toa signedword.
• Thisinstructioncopiesthe signof a byte inAL to all the bitsin AH.
• AH is thensaidto be the signextensionof AL.
• CBW operationisdone before performingdivisionof asignedbyte inthe ALby another
signedbyte withIDIV instruction.
Operation :--
• AH filledwith8th
bitof AL i.e.,D7
Thisdoesnot affectanyflags.
Example :--
If AX = 009BH, (00000000 10011011
AfterCBW Instruction,
5. AX=FF9B (11111111 10011011)
13. CWD (ConvertSignedWordto Double Word)
Syntax :-- CWD
• This instructioncopies the signbitof aword inAXto all the bitsinDX.
• Thus the signof AXis saidto be extendedtoDX.
• CWD operationisdone before performingdivisionof asignedwordinthe AXby
anothersignedwordwithIDIV instruction.
Operation :--
• DX filledwith16th
bitof AXi.e.,D15
Thisdoesnot affectanyflags.
Example :--
If DX = 0000H (00000000 00000000)
If AX = F0C7H, (11110000 11000111)
AfterCWD Instruction,
DX = FFFFH (11111111 11111111)
AX=F0C7 (11110000 11000111)
14. CMP (Compare)
Syntax :-- CMP destination,source
• Thisinstructioncomparesthe source operand,whichmaybe a register,immediate data
or memorylocationwithadestinationoperandwhichmaybe a registerormemory
location.
• It subtractsthe source operandfromthe destinationbutdoesnotstore the result
anywhere.
• The flags(OF,CF, PF,AF,SF, ZF)are affecteddependingonthe resultof subtraction.
• Source and destinationbothcannotbe memorylocations.
OperationPerformed:--
• If destination>source thenCF = 0, ZF = 0, SF = 0
• If destination<source thenCF = 1, ZF = 0, SF = 1
• If destination=source thenCF = 0, ZF = 1, SF = 0
Examples:--
1. CMP AL,0FFH; ComparesAL withFFH
2. CMP AX,BX ; ComparesAXwithBX
3. CMP CX,COUNT ; ComparesCXwithmemory variable COUNT
15. NEG ( Negate )
Syntax :-- NEG destination
• This instructionreplacesthe numberinthe destinationwiththe 2’scomplementof that
number.
• For obtainingthe 2’scomplement,itsubtractsthe contentsof destinationfromzero.
• The resultisstored back in the destinationwhichmaybe a registerora memory
location
• If OF =1, it indicatesthatthe operationcouldnotbe completedsuccessfully.
• NEG instructionaffectsall conditionalflags.
• Examples:--
1. NEG AL ; 2’s complementof ALbyte.
2. NEG BX ; 2’s complementof BXword.