Calculate Physical Addresses and Explain Addressing Modes | Microprocessor and Interfacing (MPI)

In this computational exercise, we calculate physical addresses and explain addressing modes of x86 assembly language programming, focusing on the calculation of physical addresses and the elucidation of various addressing modes. Given a scenario where the Data Segment (DS) is set to 5000H, we explore seven distinct instructions, ranging from immediate and register addressing to complex base register with displacement configurations. Each step involves deciphering the memory access pattern, shedding light on the nuanced addressing modes employed in the realm of assembly language programming.

Question: Compute the physical addresses that the following instructions will access. Assume that DS (Data Segment) is equal to 5000H, and the given memory operands are [CX] = 2000H, [SI] = 3000H, [BP] = 4000H, and [DI] = 1000H. Also, explain the addressing modes used by each instruction.

(i) MOV AX, [2000H]:

  • Addressing Mode: Immediate addressing.
  • Explanation: This instruction is directly loading the value at the memory address 2000H into the AX register. The physical address is 2000H.

(ii) MOV BX, AX:

  • Addressing Mode: Register addressing.
  • Explanation: This instruction copies the content of the AX register into the BX register. It does not involve memory access, so there is no physical address calculation.

(iii) MOV AX, [CX]:

  • Addressing Mode: Register indirect addressing.
  • Explanation: The content of the CX register is treated as a memory address, and the value at that address is loaded into the AX register. The physical address is 5000H (DS) + 2000H (content of CX) = 7000H.

(iv) MOV BX, [BP+DI]:

  • Addressing Mode: Base register addressing with displacement.
  • Explanation: The content of the BP register is used as a base address, and DI is added as a displacement. The physical address is 4000H (content of BP) + 1000H (content of DI) = 5000H.

(v) MOV BX, [BP+SI+6000H]:

  • Addressing Mode: Base register addressing with two displacements.
  • Explanation: The content of the BP register is used as a base address, SI is added as the first displacement, and 6000H is added as the second displacement. The physical address is 4000H (content of BP) + 3000H (content of SI) + 6000H = 13000H.

(vi) MOV AX, [BP]:

  • Addressing Mode: Base register addressing.
  • Explanation: The content of the BP register is used as a base address, and the value at that address is loaded into the AX register. The physical address is 4000H.

(vii) MOV AX, 3000H:

  • Addressing Mode: Immediate addressing.
  • Explanation: This instruction loads the immediate value 3000H directly into the AX register. It does not involve memory access, so there is no physical address calculation.

Simplify the Question and Answers for Better Understanding

Question: Imagine you have a computer system, and in this system, you are performing various operations with memory. In the context of your computer, you have a special area called the Data Segment (DS), which is set to 5000H. Additionally, you have specific values stored in different memory locations, like [CX] = 2000H, [SI] = 3000H, [BP] = 4000H, and [DI] = 1000H. Now, let’s explore some instructions:

(i) Move the contents of memory location 2000H into the AX register. What is the actual location in the computer’s memory that this instruction is talking about, and why?

  • Answer: The computer is going to the memory location 2000H to fetch a value and put it into the AX register. The location in the computer’s memory is 2000H.

(ii) Copy the contents of the AX register into the BX register. Where in the computer’s memory does this happen?

  • Answer: This operation doesn’t involve going to a specific memory location; it’s just copying data between registers. No memory address is needed.

(iii) Load the value from the memory location specified by the CX register into the AX register. What is the actual memory location in the computer, and how is it calculated?

  • Answer: The computer is looking at the memory location calculated by adding the contents of the CX register (2000H) to the Data Segment (DS) value (5000H). So, the location in the computer’s memory is 7000H.

(iv) Load the value from the memory location calculated by adding the contents of the BP and DI registers into the BX register. What is the actual memory location?

  • Answer: The computer calculates the memory location by adding the contents of the BP register (4000H) to the DI register (1000H). So, the location in the computer’s memory is 5000H.

(v) Load the value from the memory location calculated by adding the contents of the BP and SI registers and 6000H into the BX register. What is the actual memory location?

  • Answer: The computer calculates the memory location by adding the contents of the BP register (4000H), the SI register (3000H), and the immediate value 6000H. So, the location in the computer’s memory is 13000H.

(vi) Load the value from the memory location specified by the BP register into the AX register. What is the actual memory location in the computer?

  • Answer: The computer is looking at the memory location specified by the BP register (4000H). So, the location in the computer’s memory is 4000H.

(vii) Load the immediate value 3000H into the AX register. Does this involve going to a specific memory location?

  • Answer: No, this operation directly puts the value 3000H into the AX register without going to a specific memory location.

In summary, these instructions involve operations with memory, and the answers provide a simple explanation of the memory locations involved in each case.

JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.

Add a Comment

Your email address will not be published. Required fields are marked *