Thread: Target CPU Compiler Option

  1. #1
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812

    Target CPU Compiler Option

    Hi there,

    The compiler I use has an option for producing instruction set specific output, i.e. I can select between 386, 486, Pentium and Pentium Pro. When compiling, I have always left it at the default of 386 and never looked into it in detail. My compiler is BCB, but I note that VC6 has a similiar option. Neither compiler documents this feature, except to state the obvious.

    I need to know what sort of effect this has, especially with regard to emulation of certain features, such as floating point behaviour. Is possible, for example, that if I compile for 386 then my application is actually using floating point emulation rather than using the FPU? If so, where is this emulation performed?

    What kind of other issues would be relevant if I were to release an app built with 'Pentium Pro' target instruction set, rather than 386?

    Cheers
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  2. #2
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    if you compile for 'pentium pro', it might not work on the 386
    if you compile for '486', it might not work on the 386
    if you compile for '386', there should be a 387 fpu support option. or maybe not, who cares about the 387. the emulation is performed with ordinary assembly instructions inside of your program code - or it might be performed on the planet zarbulon by elvis. perhaps there is an option to dump assembly output from the compiler
    .sect signature

  3. #3
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >if you compile for 'pentium pro', it might not work on the 386
    >if you compile for '486', it might not work on the 386

    Mmmm. Not too helpful, I'd kind of figured that much myself.

    Where can I get info which might help in deciding which I should use? I can find none. Are there any draws backs to setting 'Pentium Pro'.

    I ask this because I had a problem with in C++:

    long double a = 1052.32L;

    Were a was being filled with incorrect data. Initially I put it down to a CPU/FPU fault, but now it appears it was OS setup related, as when WinXP was re-installed the problem vanished.

    So I'm in the dark guessing what the problem was and guessing as to what 386/486/Pentium targert code options actually do. Can find nothing in Google or BCB/VC documentation. Just reading ' select 386 for 386 instruction code' doesn't give me any helpful information.

    Can anybody shed any light?
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  4. #4
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    if you select 386 compilation, it will compile only 386-compatible instruction codes.

    as you select later models, new instructions codes may be output in place of what would be done on lower processor models, for performance purposes, at the cost of backwards compatibility.

    so, saying 'select 386 for 386 instruction code' is quite informative, because that is exactly what happens.

    look into compiler options to see if you can dump out program assembly source if you want to get a closer look at it.
    .sect signature

  5. #5
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Hi ggs,

    Thanks for the reply. I'm sorry if I didn't seem grateful - I realise now you were trying to be genuinely helpful.

    I get the feeling I'm asking the wrong sort of questions. I'll try to keep it simple:

    Is there any good reason why I should keep building my future apps against 386 instruction set?

    Conversely, is there any reason why I should not switch to Pentium Pro instruction set. (Except that my application won't run on a 386 - I trust this isn't an issue).

    Thanks
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  6. #6
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    the only reason you should not compile for the most recent model of processor possible is if you know there are users with earlier processors who you want your programs to reach.

    and since it's just a compiler option, you can always distribute multiple compilations for each processor.

    so yes, definitely set your compiler to optimize as best it can for the pc you're running - if you're running a pentium pro, compile your code for it.
    .sect signature

  7. #7
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Cheers
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Which Compiler?
    By Bladactania in forum C Programming
    Replies: 10
    Last Post: 02-11-2009, 01:32 AM
  2. [resolved] internal compiler error...
    By bling in forum C++ Programming
    Replies: 2
    Last Post: 12-10-2008, 12:57 PM
  3. Can you still view the bios screen with a bad CPU?
    By HyperCreep in forum Tech Board
    Replies: 4
    Last Post: 12-31-2006, 06:57 PM
  4. CPU temp
    By PING in forum Tech Board
    Replies: 5
    Last Post: 01-28-2006, 06:25 AM
  5. Compiler Design... Anyone That Can Help!
    By ComputerNerd888 in forum C++ Programming
    Replies: 3
    Last Post: 09-27-2003, 09:48 AM