ADDRESSING MODE.Docx.Docx
Total Page:16
File Type:pdf, Size:1020Kb
© 2014 IJIRT | Volume 1 Issue 5 | ISSN : 2349-6002 ADDRESSING MODE Aarti Singh, Ananya Anikesh Abstract- Addressing mode is the way of addressing a to multidimensional arrays and arrays of data struct memory location in instruction. Microcontroller ures. The addressing mode may be "implicit" - the needs data or operands on which the operation is to location of the operand is obvious from the be performed. The method of specifying source of particular instruction. This would be the case for operand and output of result in an instruction is an instruction that modified a particular control known as addressing In this paper we explain types of addressing mode getting familiar with 8085 register in the CPU or, in a stack based processor addressing mode, explain 8086 addressing mode where operands are always on the top of the stack. II. NUMBER OF ADDRESSING MODE Index Terms- addressing mode, 8086 addressing mode,8085 addressing mode etc Different computer architectures vary greatly as to the number of addressing modes they provide in I. INTRODUCTION hardware. There are some benefits to eliminating Addressing mode is the way of addressing a complex addressing modes and using only one or a memory location in instruction. Microcontroller few simpler addressing modes, even though it needs data or operands on which the operation is to requires a few extra instructions, and perhaps an be performed. The method of specifying source of extra register.[1] It has proven[2] [3] [4] much easier to operand and output of result in an instruction is designpipelined CPUs if the only addressing modes known as addressing mode. One of a set of available are simple ones. methods for specifying the operand(s) for a Most RISC machines have only about five simple machinecode instruction.Differentprocessors vary g addressing modes, while CISC machines such as reatly in the number of addressingmodes they provi the DEC VAX supermini have over a dozen de. The more complex modes described belowcan addressing modes, some of which are quite usually be replaced with a short sequence of complicated. The IBM System/360 mainframe had instructions using only simpler modes. The most only three addressing modes; a few more have been common modes are "register" the operand is stored added for the System/390.When there are only a in a specified register; "absolute" the operand is sto few addressing modes, the particular addressing red at a specified memory address; and mode required is usually encoded within the "immediate" - the operand is contained within the instruction code (e.g. IBM System/360 and instruction. Most processors also have indirect successors, most RISC). But when there are lots of addressing modes, e.g. "register indirect", "memory addressing modes, a specific field is often set aside indirect" where the specified register or memory in the instruction to specify the addressing mode. location does not contain the operand but contains The DEC VAX allowed multiple memory operands its address, known as the "effective address". For for almost all instructions, and so reserved the first an absolute addressing mode, the effective few bits of each operand specifier to indicate the address is contained within the instruction. addressing mode for that particular operand. Indirect addressing modes often have options for pr Keeping the addressing mode specifier bits e- or post- increment or decrement, meaning separate from the opcode operation bits produces that the register ormemory location containing an orthogonal instruction set. the effective address is incremented or Even on a computer with many addressing modes, decremented by some amount (either fixed or measurements of actual programs[5] indicate that alsospecified in the instruction), the simple addressing modes listed below account either before or after the instruction is executed. for some 90% or more of all addressing modes These are very useful for stacks and for accessing used. Since most such measurements are based on blocks of data. Other variations form the effective code generated from high-level languages by address by adding together one or more registers an compilers, this reflects to some extent the d oneor more constants which may limitations of the compilers being used.[6] themselves be direct or indirect. Such complex addressing modes are designed tosupport access IJIRT 100248 INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 397 © 2014 IJIRT | Volume 1 Issue 5 | ISSN : 2349-6002 III. TYPES OF ADDRESSING MODE ▪ EA = R ▪ Limited number of registers The common addressing modes are: ▪ Very small address field needed ▪ Immediate —Shorter instructions ▪ Direct —Faster instruction fetch ▪ Indirect ▪ No memory access ▪ Register ▪ Very fast execution ▪ Register indirect ▪ Very limited address space ▪ Displacement (Indexed) ▪ Multiple registers helps performance ▪ Stack —Requires good assembly programming or ▪ compiler writing Immediate Addressing: —N.B. C programming Instruction –register int a; ▪ operand is a part of instruction Register Indirect Addressing: ▪ operand = address field ▪ e.g. ADD 5 ▪ C.f. indirect addressing —Add 5 to contents of accumulator ▪ EA = (R) —5 is operand ▪ Operand is in memory cell pointed to by ▪ No memory reference to fetch data contents of register R ▪ Fast ▪ Large address space (2n) ▪ Limited range ▪ One fewer memory access than indirect Direct Addressing: addressing Displacement Addressing: ▪ Address field contains address of operand ▪ Effective address (EA) = address field (A) ▪ EA = A + (R) ▪ e.g. ADD A ▪ Address field hold two values —Add contents of cell A to accumulator —A = base value —Look in memory at address A for operand —R = register that holds displacement ▪ Single memory reference to access data —or vice versa ▪ No additional calculations to work out Stack Addressing: effective address ▪ Operand is (implicitly) on top of stack ▪ Limited address space ▪ e.g. Indirect Addresssing: —ADD Pop top two items from stack and add ▪ Memory cell pointed to by address field ▪ The stack mode of addressing is a form of contains the address of (pointer to) the operand implied addressing ▪ EA = (A) ▪ the machine instructions need not include a —Look in A, find address (A) and look there memory reference but implicitly operate on top for operand of stack. ▪ e.g. ADD (A) (30930) —Add contents of cell pointed to by contents of A to accumulator ▪ Large address space ▪ 2n where n = word length ▪ May be nested, multilevel, cascaded —e.g. EA = (((A))) ▪ Multiple memory accesses to find operand ▪ Hence slower Register Addressing: ▪ Operand is held in register named in address filed IJIRT 100248 INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 398 © 2014 IJIRT | Volume 1 Issue 5 | ISSN : 2349-6002 The most common names for addressing mode Addressing Example Meaning When used modes Instruction Register Add R4,R3 R4 <- R4 + R3 When a value is in a register Immediate Add R4, #3 R4 <- R4 + 3 For constants Add R4, Displacement R4 <- R4 + M[100+R1] Accessing local variables 100(R1) Register Accessing using a pointer or a Add R4,(R1) R4 <- R4 + M[R1] deffered computed address Useful in array addressing: Add R3, (R1 + Indexed R3 <- R3 + M[R1+R2] R1 - base of array R2) R2 - index amount Direct Add R1, (1001) R1 <- R1 + M[1001] Useful in accessing static data Memory Add R1, If R3 is the address of a pointer p, R1 <- R1 + M[M[R3]] deferred @(R3) then mode yields *p Useful for stepping through arrays Auto- R1 <- R1 +M[R2] in a loop. Add R1, (R2)+ increment R2 <- R2 + d R2 - start of array d - size of an element Same as autoincrement. Auto- R2 <-R2-d Add R1,-(R2) Both can also be used to implement decrement R1 <- R1 + M[R2] a stack as push and pop Used to index arrays. May be Add R1, R1<- Scaled applied to any base addressing mode 100(R2)[R3] R1+M[100+R2+R3*d] in some machines. Getting Familiar with the 8051’s Addressing something done, the 8051’s restrictions are less Modes pleasing. Many addressing modes that make perfect You don’t need to know a lot about the 8051’s sense— addressing; we use most modes, of its modest set, such as “MOVX @DPTR, #012h” or “CLR R5” or but not “MOV R3, R4”—just aren’t available all. When you are learning assembly language, it’s ADDRESSING MODE ON 8086 good news that the 8051 isn’t very versatile (in The x86 instructions use five different operand contrast, types: registers, constants, and three memory say, to Motorola’s 68000, which we used some addressing schemes. Each form is called years ago; it offered fourteen addressing modes). an addressing mode. The x86 processors support There’s the register addressing mode , less to learn than for a more complex machine. On the immediate addressing mode, the other hand, when you’re trying to write code to the direct addressing mode, get the indirect addressing mode, the base plus index addressing mode, the register relative addressing mode, IJIRT 100248 INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 399 © 2014 IJIRT | Volume 1 Issue 5 | ISSN : 2349-6002 and the base relative plus index addressing mode. mov ax, [1000] Register operands are the easiest to understand. mov ax, [bx] Consider the following forms of mov ax, [1000+bx] the mov instruction: The first instruction above uses mov ax, ax the direct addressing mode to load ax with the 16 mov ax, bx bit value stored in memory starting at location 1000 mov ax, cx hex. mov ax, dx The mov ax, [bx] instruction loads ax from the The first instruction accomplishes absolutely memory location specified by the contents of nothing. It copies the value from the ax register the bx register. This is an indirect addressing mode. back into the ax register. The remaining three Rather than using the value in bx, this instruction instructions copy the value of bx, cx and dx into ax.