CAO unit 2(ARM x86)[1]
CAO unit 2(ARM x86)[1]
Urade
Implied Mode
Immediate Mode
Register Mode
Register Indirect Mode
Autodecrement Mode
Autoincrement Mode
Direct Address Mode
Indirect Address Mode
Indexed Addressing Mode
Effective Address (EA)
The effective address refers to the address of an exact memory location in which an operand’s
value is actually present. Let us now explain all of the addressing modes.
Prof. Ashwini V. Urade
1. Implied Mode
In the implied mode, the operands are implicitly specified in the definition of instruction. Implied
for example,
INCA (“increment accumulator”) instruction.
CMA ( “complement accumulator” )instruction refers to an implied-mode instruction.
It is because, in the definition of the instruction, the operand is implied in the accumulator register.
All the register reference instructions are implied-mode instructions that use an accumulator.
2. Immediate Mode
In the immediate mode, we specify the operand in the instruction itself. Or, in simpler words,
instead of an address field, the immediate-mode instruction consists of an operand field. An
operand field contains the actual operand that is to be used in conjunction with an operation that
is determined in the given instruction. The immediate-mode instructions help initialize registers to
a certain constant value.
3. Register Mode
In the register mode, the operands exist in those registers that reside within a CPU. In this case,
we select a specific register from a certain register field in the given instruction. The k-bit field is
capable of determining one 2k register.
Ex:- ADD R1,R2 (R1 <---R1+R2)
Ex:- ADD A
In an indirect address mode, the address field of an available instruction gives that address in which
the effective address gets stored in memory. The control fetches the instruction available in the
memory and then uses its address part in order to (again) access memory to read its effective
address.
instruction being executed, then the use of relative addressing saves address bits in the instruction.
stackA stack is a linear array of locations. It is sometimes referred to as a pushdown list or last-in-
first-out queue..
The opcode field consists of 1 or 2 bytes. 1 or 2 bytes are also included in the addressing mode
field. If an instruction uses just one register for generating the effective address of an operand, it
only needs one byte in the addressing mode field.
The displacement field is the field that comes after the addressing mode field. If the displacement
value is used to compute an effective address for a memory operand, one or four bytes are used
to encode. When an operand is just an immediate value, it will show in the immediate field and
will be 1 or 4 bytes long.
• Instruction prefixes: The instruction prefix, if present, consists of the LOCK prefix or one of
the repeat prefixes. The LOCK prefix is used to ensure exclusive use of shared memory in
multiprocessor environments. The repeat prefixes specify repeated operation of a string, which
enables the x86 to process strings much faster than with a regular software loop. There are five
different repeat prefixes: REP, REPE, REPZ, REPNE, and REPNZ. When the absolute REP
prefix is present, the operation specified in the instruction is executed repeatedly on successive
elements of the string; the number of repetitions is specified in register CX. The conditional REP
prefix causes the instruction to repeat until the count in CX goes to zero or until the condition is
met.
• Segment override: Explicitly specifies which segment register an instruction should use,
overriding the default segment-register selection generated by the x86 for that instruction.
• Operand size: An instruction has a default operand size of 16 or 32 bits, and the operand
prefix switches between 32-bit and 16-bit operands.
• Address size: The processor can address memory using either 16- or 32-bit addresses. The
address size determines the displacement size in instructions and the size of address offsets
generated during effective address calculation. One of these sizes is designated as default, and
the address size prefix switches between 32-bit and 16-bit address generation.
The instruction itself includes the following fields:
• Opcode: The opcode field is 1, 2, or 3 bytes in length. The opcode may also include bits that
specify if data is byte- or full-size (16 or 32 bits depending on context), direction of data
operation (to or from memory), and whether an immediate data field must be sign extended.
• ModR/m: This byte, and the next, provide addressing information.The ModR/m byte specifies
whether an operand is in a register or in memory; if it is in memory, then fields within the byte
specify the addressing mode to be used. The ModR/m byte consists of three fields: The Mod
field (2 bits) combines with the r/m field to form 32 possible values: 8 registers and 24 indexing
modes; the Reg/Opcode field (3 bits) specifies either a register number or three more bits of
opcode information; the r/m field (3 bits) can specify a register as the location of an operand, or
it can form part of the addressing-mode encoding in combination with the Mod field
• SIB: Certain encoding of the ModR/m byte specifies the inclusion of the SIB byte to specify
fully the addressing mode.The SIB byte consists of three fields: The Scale field (2 bits) specifies
the scale factor for scaled indexing; the Index field (3 bits) specifies the index register; the Base
field (3 bits) specifies the base register.
• Displacement: When the addressing-mode specifier indicates that a displacement is used, an 8-
, 16-, or 32-bit signed integer displacement field is added.
• Immediate: Provides the value of an 8-, 16-, or 32-bit operand.
Prof. Ashwini V. Urade
A stack based computer do not use address field in instruction.To evaluate a expression first it is
converted to revere Polish Notation i.e. Post fix Notation.. The PUSH and POP instructions,
however, need an address field to specify the operand that communicates with the stack.
PUSH A TOP = A
PUSH B TOP = B
ADD TOP = A+B
PUSH C TOP = C
PUSH D TOP = D
Prof. Ashwini V. Urade
AC = M[A]
LOAD A
AC = AC + M[B]
ADD B
M[T] = AC
STORE T
AC = M[C]
LOAD C
AC = AC + M[D]
ADD D
AC = AC * M[T]
MUL T
M[X] = AC
STORE X
It is assumed that the computer has two processor registers, R1 and R2. The symbol M [A] denotes
the operand at memory address symbolized by A. The advantage of the three-address format is
that it results in short programs when evaluating arithmetic expressions. The disadvantage is that
the binary-coded instructions require too many bits to specify three addresses.
Prof. Ashwini V. Urade
• Preindex: The memory address is formed in the same way as for offset addressing.The memory
address is also written back to the base register. In other words, the base register value is
incremented or decremented by the offset value. Figure illustrates this method with the assembly
language instruction STRB r0, [r1, #12]! ! -The exclamation point signifies preindexing.
Prof. Ashwini V. Urade
• Postindex:The memory address is the base register value.An offset is added to or subtracted
from the base register value and the result is written back to the base register. Figure c illustrates
this method with the assembly language instruction STRBv r0, [r1], #12.
produce a sequential range of memory addresses. The lowestnumbered register is stored at the
lowest memory address and the highest numbered register at the highest memory address. Four
addressing modes are used in figure .increment after, increment before, decrement after, and
decrement before. A base register specifies a main memory address where register values are
stored in or loaded from in ascending (increment) or descending (decrement) word locations.
Incrementing or decrementing starts either before or after the first memory access.
These instructions are useful for block loads or stores, stack operations, and procedure exit
sequences.
Data processing instructions use either register addressing of a mixture of register and immediate
addressing. For register addressing, the value in one of the register operands may be scaled using
one of the five shift operators defined in the preceding paragraph.
These instructions perform basic data-processing operations, and share a common format
with some variations.
Shift instructions.
Multiply instructions.
Saturating instructions.
Saturating addition and subtraction instructions.
Packing and unpacking instructions.
Prof. Ashwini V. Urade
D. BRANCH INSTRUCTIONS
The only form of addressing for branch instructions is immediate addressing. The branch
instruction contains a 24-bit value. For address calculation, this value is shifted left 2 bits, so that
the address is on a word boundary. Thus the effective address range is MB from the program
counter
Prof. Ashwini V. Urade
--------------------------------------32 bits---------------------------------------------------------------
OP Code Rn Rd Other Rm
Condition Information
4bit 8bit 4bit 4bit 8bit 4bit
ASSEMBLY LANGUAGE
A processor can understand and execute machine instructions. Such instructions are simply binary
numbers stored in the computer. If a programmer wished to program directly in machine language,
then it would be necessary to enter the program as binary data.
Consider the simple BASIC statement
N=I+J+K
Suppose we wished to program this statement in machine language and to initialize I, J, and K to
2, 3, and 4, respectively.The program starts in location 101 (hexadecimal). Memory is reserved for
the four variables starting at location 201. The program consists of four instructions:
1. Load the contents of location 201 into the AC
2. Add the contents of location 202 to the AC.
3. Add the contents of location 203 to the AC.
4. Store the contents of the AC in location 204.
This is clearly a tedious and very error-prone process. A slight improvement is to write the
program in hexadecimal rather than binary notation We could write the program as a series of
lines. Each line contains the address of a memory location and the hexadecimal code of the
binary value to be stored in that location.Then we need a program that will accept this input,
translate each line into a binary number, and store it in the specified location.
For more improvement, we can make use of the symbolic name or mnemonic of each
instruction. This results in the symbolic program shown in Figure 10.11c. Each line of input
still represents one memory location. Each line consists of three fields, separated by spaces.
The first field contains the address of a location.