On 16 bit dos machine there is options like FP_SEG and FP_OFF for converting a pointer to linear address but since these method no more exist on 32 bit compiler what are other function that can do same on 32 bit machine??
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They’re luckily not needed as 32-bit mode is unsegmented and hence the addresses are always linear (a simplification, but let’s keep it simple).
EDIT: The first version was confusing let’s try again.
In 16-bit segmented mode (I’m exclusively referring to legacy DOS programs here, it’ll probably be similar for other 16-bit x86 OSes) addresses are given in a 32-bit format consisting of a16-bit segment and a 16-bit offset. These are combined to form a 20-bit linear address (This is where the infamous 640K barrier comes from,
2**20 = 1MBand 384K are reserved for the system and bios leaving ~640K for user programs) by multiply the segment by16 = 0x10(equivalent to shifting left by 4) and adding the offset. I.e.:linear = segment*0x10 + offset.This means that
2**12segment:address type pointers will refer to the same linear address, so in general there is no way to obtain the 32-bit value used to form the linear address.In old DOS programs that used far – segmented – pointers (as opposed to near pointers, which only contained an offset and implicitly used
dssegment register) they were usually treated as 32-bit unsigned integer values where the 16 most significant bits were the segment and the 16 least significant bits the offset. This gives the following macro definitions forFP_SEGandFP_OFF(using the types fromstdint.h):To convert a 20-bit linear address to a segmented address you have many options (
2**12). One way could be:Finally a quick example of how it all works together:
Segmented address:
a = 0xA000:0x0123As 32-bit far pointer
b = 0xA000012320-bit linear address:
c = 0xA0123