Upload
hamza-asim-ghazi
View
217
Download
0
Embed Size (px)
Citation preview
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 1/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Chapter 3Chapter 3
Addressing Modes Addressing Modes
Barry B. BreyBarry B. [email protected]@ee.net
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 2/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Addressing Modes Addressing Modes
In order to write a program addressing modesIn order to write a program addressing modes
must be thoroughly understood.must be thoroughly understood.
There are many addressing modes, but the mostThere are many addressing modes, but the most
common are easy to master and represent mostcommon are easy to master and represent most
instructions in most programs.instructions in most programs.
Register addressing, immediate addressing,Register addressing, immediate addressing,
direct addressing, and simple forms of indirectdirect addressing, and simple forms of indirectaddressing are the most common addressingaddressing are the most common addressing
modes.modes.
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 3/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Stack addressing is also used with theStack addressing is also used with the
PUSH and POP instructions and as a wayPUSH and POP instructions and as a wayto link a program to its procedures or to link a program to its procedures or
functions.functions.
Program flow instructions are either Program flow instructions are either
unconditional or conditional.unconditional or conditional.
Conditional program flow instructions areConditional program flow instructions are
the ³if´ statements of assembly language.the ³if´ statements of assembly language.
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 4/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Data Addressing ModesData Addressing Modes
Data addressing modes are presents withData addressing modes are presents with
the MOV instruction because it is by far the MOV instruction because it is by far
the most common instruction in a program.the most common instruction in a program. MOV really moves nothing. MOV copiesMOV really moves nothing. MOV copies
the source into the destination. It probablythe source into the destination. It probably
should be named COP for copy, but it isshould be named COP for copy, but it is
not.not.
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 5/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 6/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 7/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Register Register
MOV EAX,EBXMOV EAX,EBX
MOV CX,DXMOV CX,DX
MOV AH,ALMOV AH,AL MOV AX,DSMOV AX,DS
MOV ES,CXMOV ES,CX
ADD AL,CL (most instructions use it) ADD AL,CL (most instructions use it) OR AX,DXOR AX,DX
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 8/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 9/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
ImmediateImmediate
MOV EAX,234HMOV EAX,234H
MOV CX,2MOV CX,2
MOV AL,34HMOV AL,34H ADD AL,3 ADD AL,3
SUB CL,4SUB CL,4
AND EAX,1 AND EAX,1
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 10/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 11/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
DirectDirect
MOV BOB,EAXMOV BOB,EAX
MOV FRED,CXMOV FRED,CX
MOV BILLY,ALMOV BILLY,AL MOV EDI,RALPHMOV EDI,RALPH
MOV AX,STEVEMOV AX,STEVE
MOV DS,BARNEYMOV DS,BARNEY MOV AL,DS:[1000H]MOV AL,DS:[1000H]
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 12/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 13/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Register IndirectRegister Indirect
MOV AL,[BX]MOV AL,[BX]
MOV AX[EBX]MOV AX[EBX]
MOV [EDI],EAXMOV [EDI],EAX MOV [EAX],EDXMOV [EAX],EDX
MOV BYTE PTR [EAX],6MOV BYTE PTR [EAX],6
MOV WORD PTR [ECX],12MOV WORD PTR [ECX],12 MOV DWORD PTR [ESI],2345HMOV DWORD PTR [ESI],2345H
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 14/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 15/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Base Plus IndexBase Plus Index
MOV AL,[BX+SI]MOV AL,[BX+SI]
MOV [BX+DI],AXMOV [BX+DI],AX
MOV [BP+SI],EAXMOV [BP+SI],EAX MOV AL,[BP+DI]MOV AL,[BP+DI]
MOV WORD PTR [BX+SI],5MOV WORD PTR [BX+SI],5
ADD AL,[BX+DI] ADD AL,[BX+DI]
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 16/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 17/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Register RelativeRegister Relative
MOV AL,[BX+3]MOV AL,[BX+3]
MOV AX,[DI+20H]MOV AX,[DI+20H]
MOV [EDI+200H],EAXMOV [EDI+200H],EAX MOV [BXMOV [BX--33],ECX33],ECX
ADD BYTE PTR [BX+2],5 ADD BYTE PTR [BX+2],5
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 18/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 19/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Relative Plus IndexRelative Plus Index
MOV AL,[BX+SI+22]MOV AL,[BX+SI+22]
MOV [BX+DIMOV [BX+DI--22],AX22],AX
MOV EAX,[EBX+EDI+100H]MOV EAX,[EBX+EDI+100H]
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 20/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 21/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Scaled IndexScaled Index
MOV EAX,[EBX+ 4*ECX]MOV EAX,[EBX+ 4*ECX]
MOV AX,[EDI+2*EBX]MOV AX,[EDI+2*EBX]
MOV [EAX+2*EBX],DXMOV [EAX+2*EBX],DX MOV [4*ECX],EBXMOV [4*ECX],EBX
ADD AL,[ECX+EBX] ADD AL,[ECX+EBX]
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 22/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
Program FlowProgram Flow
Program flow instruction are unconditionalProgram flow instruction are unconditional
(JMP) or conditional (JNZ).(JMP) or conditional (JNZ).
Flow instructions are short (Flow instructions are short (+127,+127, --128),128),near (near (±±32K), or far (anywhere in the32K), or far (anywhere in the
memory).memory).
Conditionals do not contain the far type.Conditionals do not contain the far type.
Labels are followed by a colon if they areLabels are followed by a colon if they are
jumped to in a program. jumped to in a program.
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 23/25
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 24/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e
PUSH AXPUSH AX
PUSH EAXPUSH EAX POP AXPOP AX
POP EAXPOP EAX
PUSH BOBPUSH BOB POP BOBPOP BOB
PUSHFPUSHF
POPFPOPF
8/8/2019 brey_ch3
http://slidepdf.com/reader/full/breych3 25/25
© 2006 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved.Brey: The Intel Microprocessors, 7e