Stored Program/Software View

Here is a brief illustration of the relationships among "high-level" languages, assembly language, and machine language.

This is a very simple program in the C language that asks the user for two numbers, adds them, and prints the result. Note that this program makes no assumptions about a particular machine ("platform"); it's really just a slightly odd-looking description of an algorithm; any computer should be able to perform this algorithm.

But C is a compiled language, which means that in order for a computer to execute the algorithm described by this program, we need to convert it to machine language. As we discussed, the first step is to translate it into assembly language; then that is translated to machine language. Now, although our C program doesn't say anything about a particular type of computer, creating an executable form of the program does require that it be translated into the proper machine language for whichever computer we are using. Each different kind of CPU (for example Pentiums, or Macintosh G5s, or Sun SPARCstations like those in the back of the Atrium lab) has a different machine language -- and therefore a different assembly language. Even more complicated, we might have different compilers that may use different techniques for translating our program into assembly language.

So, here's what happens when we translate our program into assembly language. First, compare the translation into Macintosh assembly language versus Sun assembly language. Then compare the Sun assembly language version with a different representation using the same language -- these were produced by two different compilers: the two programs use the same language but have very different structures.

Finally, these assembly language programs must be translated into machine code. This is not very readable to us, but it's worth taking a quick look. Below are the 3 machine language versions of our assembly language programs. They are printed using hexadecimal notation (just like Web page background color notation) because it's a little bit easier for humans to interpret it. (Plus, there's some odd geek humor at the beginning of the Macintosh version....)

Remember, there are people out there who actually can look at this stuff and tell you something about what it means -- but most of us prefer to work with the original C language representation and let the compiler/assembly software do the nasty work.