Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6528323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:31:26+00:00 2026-05-25T09:31:26+00:00

On 16 bit dos machine there is options like FP_SEG and FP_OFF for converting

  • 0

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??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:31:26+00:00Added an answer on May 25, 2026 at 9:31 am

    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 = 1MB and 384K are reserved for the system and bios leaving ~640K for user programs) by multiply the segment by 16 = 0x10 (equivalent to shifting left by 4) and adding the offset. I.e.: linear = segment*0x10 + offset.

    This means that 2**12 segment: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 ds segment 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 for FP_SEG and FP_OFF (using the types from stdint.h):

    #define FP_SEG(x) (uint16_t)((uint32_t)(x) >> 16) /* grab 16 most significant bits */ 
    #define FP_OFF(x) (uint16_t)((uint32_t)(x)) /* grab 16 least significant bits */
    

    To convert a 20-bit linear address to a segmented address you have many options (2**12). One way could be:

    #define LIN_SEG(x) (uint16_t)(((uint32_t)(x)&0xf0000)>>4)
    #define LIN_OFF(x) (uint16_t)((uint32_t)(x))
    

    Finally a quick example of how it all works together:

    Segmented address: a = 0xA000:0x0123
    As 32-bit far pointer b = 0xA0000123
    20-bit linear address: c = 0xA0123

    FP_SEG(b) == 0xA000
    FP_OFF(b) == 0x0123
    LIN_SEG(c) = 0xA000
    LIN_OFF(c) = 0x0123
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to create 16-bit .COM executables (DOS) using some gcc distribution
is there any way to write 16-bit MS-DOS programs using a Windows environment? I
Bit of an edge case, but any idea why &&= would behave this way?
Bit of a dumb question, but I'm wondering what the accepted way of passing
In the old days of DOS there was DPMI (DOS Protected Mode Interface). I
I have a bit of an unusual question. I'm running an old DOS game
I'm doing some embedded DOS development with OpenWatcom (great Windows-hosted compiler for targeting 16-bit
I am using Runtime.exec() to launch an external 16-bit DOS program (for legacy app
Is there some tool which allows one to control the MS-Windows (XP-SP3 32-bit in
I'm writing an encoding/decoding .COM program using Huffman algorithm for dos 8086 (16-bit tasm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.