how to find a segment address from given data?
Physical address = 0x119B, Effective address = 0x10AB
what could be the formula?
The effective address in x86 16-bit real mode is just the offset portion of a 20-bit segment:offset address. The question you have been given is to determine a segment value when combined with the effective address 0x10AB yields a physical (linear) address of 0x119B.
The physical address can be computed from a segment:offset pair with the formula physaddr=(segment<<4)+offset
or physaddr=(segment*0x10)+offset
. Reworking the formula a bit:
physaddr = (segment*0x10)+offset physaddr-offset = segment*0x10 (physaddr-offset)/0x10 = segment segment = (physaddr-offset)/0x10
Now that we know the formula for segment is segment = (physaddr-offset)/0x10
we can perform the calculation to find the answer for your question:
segment = (0x119B-0x10AB)/0x10 segment = 0xF0/0x10 segment = 0xF
We can check this result by plugging it into the original equation for physical address and get:
physaddr = (0xF*0x10)+0x10AB = 0x119B.