Simplified understanding of addressing modes

First of all, you need to know about what is the term addressing? Okay, addressing is referred to as how the operand of an instruction is specified. So, you don’t know what instructions are….

What is Instruction?

Instructions are a segment of code containing steps that need to be executed by the processor. It can be divided into three parts:(a)Addressing mode, we will define it later, for now, keep in mind its size is 1 bit. (b)The opcode is the portion of an instruction that specifies the operation to be performed. ©The operand is the one on which the operations are performed, it is the address where the data is stored. For example- ADD (A), R1.

Next, you have to get some idea about Registers in the processor and how they are arranged, refer to this link for more info “CPU Architecture made Simpler!

Now, you have a basic idea about register. Let’s discuss the size of the registers For example, A computer has the memory unit of 4096 words of 16 bits each a binary instruction is stored in one word of memory. Fund the size of each register?

4096 words mean this many different locations to store memory, we know that address is a combination of 0,1( a word is the natural unit of data used by a particular processor design. A word is a fixed-sized piece of data handled as a unit by the instruction set or the hardware of the processor.)

so the number of possible combination for 4096 address is ²¹² and each word have a size of 16 bits

Memory Address Register then has a size of 12 bits (0–11), since 2^(12) i.e the address bit can be represented with 12 different combinations of 0,1.

Memory Data Register has a size of 16 bits(0- 15)each data set can only transfer data equal to that of the word.

Accumulator has the same size as that of MDR since it is a temporary storage

Program Counter stores the address of the next instruction so its size is the same as that of MAR

Instruction Register, fist of all the size of IR is 16 bits because it is the data from MDR i.e, the instruction. The next question that comes what is the size of different parts of instruction(addressing mode, opcode, address/operand). As said earlier the addressing mode is 1 bit, the address should be the size of size 12 bits (refer to MAR), so the remaining opcode should of size 3 bits (16 -(1+12)).

Types Of Instruction Format:

#Zero Addressing(Stack Based)- In this, the instruction doesn’t contain the address of the instruction. A basic temporary stack is maintained for the evaluation and execution of the program. To evaluate an expression first it is converted to revere Polish Notation i.e. Postfix Notation. There is basic stack operation like PUSH and POP and other arithmetic operations(like, ADD, SUB). For every operation, the top two elements are popped evaluated and the result is pushed back into the stack, they don’t take any argument.

For example, evaluate the steps X=(A*B)+(C*D)

firstly convert it into postfix notation X=AB*CD*+

#One Addressing(Accumulator based)- Here an implied Accumulator register is used data manipulation. There are basic operations like LOAD(store data from memory to accumulator), STORE (data from the accumulator to memory), ADD is available but in this case, the operation is followed by an operand which is the address of the data in memory. The opcode can be divided into three parts the operation, operand, and the addressing mode.

Parts of Instructions

lets take the same example, evaluate the steps X=(A*B)+(C*D)

#Two Addressing(Register Based)- In this addressing mode we have many registers, rather than an accumulator(in one addressing). The opcode can be divided into four-part of the operation, two operands, and the addressing mode. Unlike earlier in one address instruction, the result was stored in accumulator here result cab is stored at a different location rather than just accumulator, but require several bits to represent address.

again taking the same example, evaluate the steps X=(A*B)+(C*D)

#Three Addressing(Register Based)- This addressing is similar to two addressing but with two source addresses. The opcode can be divided into five-part the operation, three operands, and the addressing mode. Program created are much short in size but number of bits per instruction increases.

Once again the same old code in a new form, evaluate the steps X=(A*B)+(C*D)

Next thing that we are going to discusses is the ,

Types Of Addressing Modes:

>> Immediate Addressing Mode- In this mode, the data is present in the address field,i.e the constant value is immediately accessed and put in the location, it is done with the symbol “#”. the address field contains the Effective Address of operand i.e., EA=A

Example, MOV #50,A . The limitation of is this addressing mode is that the range of constants is restricted by the size of the address field.

>>Direct Addressing Mode- In direct mode, the address field provides the location in the memory where the operand could be found.

Example, MOVE A, R1 ……..Here the operand present in the address is moved to the register R1, by obtaining the address from the A

>>Indirect Addressing Mode- In this mode, the address field of the instruction gives the address where the “Effective Address” is stored in memory. i.e., EA=(A). Control fetches the instruction from memory and then uses its address part to access memory again to read Effective Address.

Example, ADD (A), R1

>>Register Addressing Mode- In this mode, the data is stored in the register i.e, within the CPU and to get operand there is no memory access involved i.e, EA=(R)

Means, control fetches an instruction from memory and then uses its address to access Register and looks in Register(R) for the effective address of the operand in memory.

Example, ADD R2, R1

>>Index Addressing Mode- xR is the index register, Address can be divided into two parts: (a)the address in the index register and (b) constant. The actual address of the operand is the sum of the constant and the contents of the index register. It is generally used to access an array whose elements are in successive memory location. This also used when the size of the address of array is greater than the size of the register to hold and execute the operand i.e, EA=A+Index.

Example, 10(xR) and xR=2

>>Relative Addressing Mode- This mode of addressing is used when we to indicate the distance of an address from another specific address, called Base address. The content of the Base Register is added to the direct address part of the instruction to obtain the effective address i.e, EA=A+PC

Example, 2(BR), BR=826

>>Auto Increment Addressing Mode- Effective Address of the operand is the content of the register given in instruction like normal register addressing mode as discussed earlier. But, the difference here is that after accessing the data, the content of the register is automatically incremented to the next consecutive address location i.e, EA=(R) But, after accessing operand, the register is incremented by 1.

>> Auto Decrement Addressing Mode- This mode is almost similar to Autoincrement mode the difference is that the content of the register is first automatically decremented then the data is accessed i.e. EA=(R) — 1

These the the basic addressing modes that you generally come across in day to day life .

--

--

--

We are the community for the Hardware Engineers

Recommended from Medium

HOW WE BEGAN @LEARNFACTORY NIGERIA.

In A Digital World Where Customer Experience Defines Your Business, Is Your APM Solution Doing Its…

How to deal with throttling on Sharepoint online listing API

Tree traversal techniques in Python using Recursion

Navigating through non-answers

How a one-line fix halved the load time of our new KYC Form

The Republican Party prides itself on “family values.” Its evangelical

When things aren’t so reliable, move slower, mitigate problems, take fewer risks.

When things aren’t so reliable, move slower, mitigate problems, take fewer risks.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Debanshu Datta

Debanshu Datta

Android @Gojek | Mobile Developer | Backend Developer (Java/Kotlin)

More from Medium

Confusion, coolness, refactoring and inventory | WTR 6.27

Off The Shelf Schemes — Read, Write, Inc.

Feedback #2

Construct Week of Unit-2 | Project-BestBuy