Choosing the Right Compiler for Your Microprocessor: A Newbie's Guide

  • Thread starter Thread starter RedX
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the compatibility of compilers with microprocessors, focusing on the relationship between operating systems and chip architectures. Participants explore the implications of compiler requirements, the nature of assembly language, and the concept of cross-compiling in the context of different hardware architectures.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • Some participants assert that compilers are typically designed for specific chip architectures and operating systems, but this relationship can be complex and not always straightforward.
  • There is a discussion about the role of the operating system in providing support libraries and APIs, which may obscure the underlying chip architecture requirements.
  • One participant suggests that the x86 architecture is generally backwards compatible, which could simplify compatibility concerns for many users.
  • Another participant questions whether compilers targeting 32-bit Windows automatically imply x86-32 architecture, noting the need for clarity in specifications for 64-bit systems.
  • Concerns are raised about whether all chips can interpret assembly language, with some arguing that assembly is specific to each architecture and requires an assembler to convert it to machine code.
  • Some participants mention the existence of cross-compilers that can generate machine code for multiple architectures, allowing development on one platform for another.
  • There is a debate about the extent to which higher levels of abstraction in programming languages reduce the necessity for understanding specific hardware details.

Areas of Agreement / Disagreement

Participants express differing views on the relationship between operating systems and chip architectures, with no consensus reached on whether compilers should primarily be assessed based on OS or architecture compatibility. The discussion remains unresolved regarding the interpretation of assembly language across different architectures.

Contextual Notes

Participants highlight the potential confusion arising from the overlapping terminology of operating systems and architectures, as well as the implications of backward compatibility in the x86 architecture. There are also unresolved questions about the capabilities of various compilers and the nature of assembly language across different processor types.

RedX
Messages
963
Reaction score
3
A compiler converts a high-level language to machine code. So when you buy or download a compiler, don't you have to make sure the compiler is compatible with your microprocessor? Yet when I look at the various compilers I can download, the requirements are listed as what operating system you are running, and not your chip architecture.

I have a Pentium, but that means I could have any operating system written for a Pentium. The operating system does not determine the chip architecture (indeed it is written for the chip architecture), so how can the requirements for a compiler be the operating system and not the chip architecture?
 
Technology news on Phys.org
Compilers are usually made for a specific chip architecture running under a specific operating system, where those two may be conflated (like Windows) or the details relaxed vis the actual versions or such. However it doesn't have to be the case. The compiler translates high-level instructions to something lower. That lower-level might be some kind of portable object code which would then be translated into instructions for a specific chip by an "assembler". The OS dependence is more in the area of support libraries -- how one accesses resources through the operating system. As long as one has a good API specification, e.g. Posix -- I'm not calling it good...just sufficient -- you can "link" your portable object code with the correct libraries and not have to know exactly what is under the sheets. This is the essence of "cross-compiling".

Of course you have to run all of these programs somewhere, so they themselves have to be built for some specific hardware/OS version(s).
 
RedX said:
A compiler converts a high-level language to machine code. So when you buy or download a compiler, don't you have to make sure the compiler is compatible with your microprocessor?

Nope. Most everyone and their grandma have a pc with an x86 or compatible instruction set architecture processor. With various revisions and extensions over the years it's still pretty backwards compatible.

For other stuff there's the hardware abstraction layer.

You really needn't concern yourself with things the compiler developers didn't want you to. The OS matters. Because the OS API is about as low as you need to be privy to nowadays for all but the most advanced software.

With Java, not even the OS matters as much. It only matters in as much as whether there's a version of the JRE written for it.

RedX said:
Yet when I look at the various compilers I can download, the requirements are listed as what operating system you are running, and not your chip architecture.

That would defeat the purpose of an operating system and of open ISAs, to need a compiler and to recompile for every processor out there. Plus the tendency is ever towards more abstraction. Interpreted languages, just in time compilation, common intermediate language, bla bla.

It's all good.

RedX said:
I have a Pentium, but that means I could have any operating system written for a Pentium.

No. You have an OS written for an instruction set.

RedX said:
The operating system does not determine the chip architecture (indeed it is written for the chip architecture), so how can the requirements for a compiler be the operating system and not the chip architecture?

Not so. You can't readily run MacOSX on x86 processors. You need virtualization.
And you can't readily run Windows on PowerPC processors. You need virtualization.
 
schip666! said:
Compilers are usually made for a specific chip architecture running under a specific operating system, where those two may be conflated (like Windows) or the details relaxed vis the actual versions or such.

I sometimes see compilers advertised as written for 32-bit Windows. Are they assuming the x86-32 architecture? I was thinking that it could be the case that 32-bit Windows was only written for the x86-32 architecture, so when you specify 32-bit Windows you automatically specify x86-32, but I don't know if that's true or not. I know for 64-bit Windows there is the x86-64 architecture, and also an Itanium architecture, so a 64-bit Windows compiler would have to specify whether it is x86-64 or Itanium.

However it doesn't have to be the case. The compiler translates high-level instructions to something lower. That lower-level might be some kind of portable object code which would then be translated into instructions for a specific chip by an "assembler".

Can all the different type of chips read Assembly, i.e., convert Assembly code to their machine code? If so, then all compilers could just translate into Assembly, which could then be converted to your particular machine code for your particular processor.
 
RedX said:
Can all the different type of chips read Assembly, i.e., convert Assembly code to their machine code? If so, then all compilers could just translate into Assembly, which could then be converted to your particular machine code for your particular processor.
I'm not aware that any chips can "read" assembly. Assembly code is human-readable code that corresponds to machine code for a particular processor. Each processor architecture (e.g. x86-32, x64, Itanium, and so on) has its own instruction set and hence its own kind of assembly code.

Chips are generally not capable of converting (or translating) assembly code into machine code. For that you need an assembler, a software tool that translates assembly code into machine code.

Some compilers, which are called cross-compilers, are capable of generating machine code for a number of different processor architectures. So for example, you could develop a program on a Windows machine, and have the compiler produce machine code that would run on, for example, a Motorola 68000-family processor.
 
RedX said:
I sometimes see compilers advertised as written for 32-bit Windows. Are they assuming the x86-32 architecture? I was thinking that it could be the case that 32-bit Windows was only written for the x86-32 architecture, so when you specify 32-bit Windows you automatically specify x86-32, but I don't know if that's true or not. I know for 64-bit Windows there is the x86-64 architecture, and also an Itanium architecture, so a 64-bit Windows compiler would have to specify whether it is x86-64 or Itanium.

The x86 architecture is designed towards backwards compatibility. I have an x86-64 processor but run windows XP HE on it. That's why I can't run applications compiled for windows on the x86-64 ISA.

But I could if I had XP 64bit ed. The CPU would just switch between 32 and 64 bit modes or use 64 bit registers to hold 32 bits of data. Etc.

RedX said:
Can all the different type of chips read Assembly, i.e., convert Assembly code to their machine code? If so, then all compilers could just translate into Assembly, which could then be converted to your particular machine code for your particular processor.

There is an assembly language for any processor architecture. For instance, http://en.wikipedia.org/wiki/ARB_(GPU_assembly_language)" . This language is just a shade above the level of actual machine instructions. Or executable code.

What you're thinking of there is http://en.wikipedia.org/wiki/Interpreted_language" (CIL).

All part of the ubiquitous strive towards higher and higher level of hardware abstraction.
 
Last edited by a moderator:

Similar threads

  • · Replies 29 ·
Replies
29
Views
4K
Replies
6
Views
4K
Replies
59
Views
10K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 15 ·
Replies
15
Views
17K
  • · Replies 40 ·
2
Replies
40
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 21 ·
Replies
21
Views
4K