Segment Offset Calculation

Creado el: 10 de enero de 2025

Respondido usando O1 Mini por Chat01

Pregunta

[2-b ] A memory location has a physical address 4A37B H. Compute
I- the offset address if the segment number is 40FF H.
il- the segment number if the offset address is 123B H.

Pensamiento

Mapping out the offset

OK, let's break this down. Multiplying the segment by 16, subtracting it from the physical address, and working carefully with hex subtraction to refine the offset calculation.

Subtracting in hex

I’m aligning digits to subtract nibble by nibble. Borrowing as needed, the operation yields the final offset calculation: B - 0 = B, 7 - F = E.

Confirming calculation steps

I’m re-evaluating the subtraction of A37B and 0FF0, ensuring each digit aligns and any required borrowing is properly accounted for to ascertain the accurate offset.

Recalculating and aligning

I’m working through recalculating the subtraction of 0xA37B and 0xFF0, aligning digits and borrowing where necessary. The final offset, as confirmed by all methods, is 0x938B.

Clarifying the process

I’m aligning nibbles to ensure accurate subtraction of 0xA37B and 0xFF0. Confirming the final offset as 0x938B through detailed calculations and consistent methods.

Verifying accuracy

I’m breaking down the subtraction of 4A37B and 123B, ensuring each digit is correct and resulting in 49140h. This confirms the segment after addressing hex details.

Thought about memory address computation for 13 seconds

Respuesta

In the x86 real-mode segmented addressing scheme, the physical address is computed as:

Physical=Segment×16+Offset\text{Physical} = \text{Segment} \times 16 + \text{Offset}

Using this formula:

Part I: Find the Offset Given Physical = 4A37Bh and Segment = 40FFh

We rearrange the formula to solve for the offset:

Offset=Physical(Segment×16)\text{Offset} = \text{Physical} - (\text{Segment} \times 16)
  1. First, compute Segment×16\text{Segment} \times 16:

    40FFh×10h=40FF0h40FF_{h} \times 10_{h} = 40FF0_{h}
  2. Subtract this product from the physical address:

    Offset=4A37Bh40FF0h\text{Offset} = 4A37B_{h} - 40FF0_{h}
    • Compute the subtraction step-by-step: 4A37Bh40FF0h=(4A37Bh40FF0h)4A37B_{h} - 40FF0_{h} = (4A37B_{h} - 40FF0_{h}) Subtracting: =A37Bh0FF0h= A37B_{h} - 0FF0_{h} Now subtract 0FF0h0FF0_{h} from A37BhA37B_{h}: A  3  7  B  0  F  F  09  3  8  B\begin{array}{r} A\;3\;7\;B \\ -\;0\;F\;F\;0 \\ \hline 9\;3\;8\;B \end{array}
      • Bh0h=BhB_{h} - 0_{h} = B_{h}
      • 7hFh7_{h} - F_{h}: borrow 1 → 7+16=23h7 + 16 = 23_{h}, 23hFh=8h23_{h} - F_{h} = 8_{h} (with borrow)
      • After borrowing, 3h3_{h} becomes 2h2_{h}. Now 2hFh2_{h} - F_{h}: borrow again → 2+16=18h2 + 16 = 18_{h}, 18hFh=3h18_{h} - F_{h} = 3_{h}
      • Borrowing makes the next digit AhA_{h} become 9h9_{h}. Then 9h0h=9h9_{h} - 0_{h} = 9_{h}.

    Thus:

    Offset=938Bh\text{Offset} = 938B_{h}

Part II: Find the Segment Given Physical = 4A37Bh and Offset = 123Bh

We rearrange the formula to solve for the segment:

Segment=PhysicalOffset16\text{Segment} = \frac{\text{Physical} - \text{Offset}}{16}
  1. Subtract the offset from the physical address:

    4A37Bh123Bh4A37B_{h} - 123B_{h}

    Perform the subtraction:

    4  A  3  7  B      1  2  3  B4  9  1  4  0\begin{array}{r} 4\;A\;3\;7\;B \\ -\;\;\;1\;2\;3\;B \\ \hline 4\;9\;1\;4\;0 \end{array}
    • BhBh=0hB_{h} - B_{h} = 0_{h}
    • 7h3h=4h7_{h} - 3_{h} = 4_{h}
    • 3h2h=1h3_{h} - 2_{h} = 1_{h}
    • Ah1h=9hA_{h} - 1_{h} = 9_{h}
    • The most significant digit remains 4h4_{h}

    So:

    4A37Bh123Bh=49140h4A37B_{h} - 123B_{h} = 49140_{h}
  2. Now divide by 16:

    Segment=49140h10h=4914h\text{Segment} = \frac{49140_{h}}{10_{h}} = 4914_{h}

Answers:

  • I. The offset is 938B_1_6.
  • II. The segment number is 4914_1_6.

Compartir este Q&A