In: Computer Science
There are 3 forms of Program Memory Addressing Modes: Direct, Relative and Indirect. Explain/Illustrate what happens to CS and IP registers if the JMP THERE instruction is stored at memory address 10000H (CS=1000H, IP=0000H) and the address of THERE is:
(A) 10020H
(B) 30000H
(A) Address of THERE is 10020H
Direct addressing -
The current value of IP which holds the address of next instruction to be executed will be stored in the TOP OF THE STACK. Now, the IP will be replaced by the mentioned value, i.e. IP <- 10020H
Now, the Memory address is calculated as: (Contents of CS) X 10H + (contents of IP).
Indirect addressing -
Suppose that the content present at address 10020H is 0003H. So, the working of the microprocessor for executing the above instruction will be as follows:
IP <- content present at 10020H i.e. IP <- 0003H
And the required memory address is calculated in a similar way as in Direct Addressing mode: (Contents of CS) X 10H + (contents of IP).
Relative addressing -
In this mode, the Effective Address (EA) of the operand is calculated by adding the content of the CPU register and the address part of the instruction word. The effective address is calculated by adding displacement (immediate value given in the instruction) and the register value.
EA = CPU Register + Displacement
(B) Address of THERE is 30000H
Direct addressing -
The current value of IP which holds the address of next instruction to be executed will be stored in the TOP OF THE STACK. Now, the IP will be replaced by the mentioned value, i.e. IP <- 30000H
Now, the Memory address is calculated as: (Contents of CS) X 10H + (contents of IP).
Indirect addressing -
Suppose that the content present at address 30000H is 0003H. So, the working of the microprocessor for executing the above instruction will be as follows:
IP <- content present at 30000H i.e. IP <- 0003H
And the required memory address is calculated in a similar way as in Direct Addressing mode: (Contents of CS) X 10H + (contents of IP).
Relative addressing -
In this mode, the Effective Address (EA) of the operand is calculated by adding the content of the CPU register and the address part of the instruction word. The effective address is calculated by adding displacement (immediate value given in the instruction) and the register value.
EA = CPU Register + Displacement