posted Jul 07, 2003
in Communication Ethics

Communication Ethics book part for Non-Assembly Languages. (This is an automatically generated summary to avoid having huge posts on this page. Click through to read this post.)
The original C code to the assembly program in the previous figure.

In reality, assembly language is too low level for normal usage by humans. For example, the code in the assembly language figure only sets up a single function call; that's a lot of typing to do something very, very simple; any non-trivial program will have thousands or even millions of function calls, so a function call needs to be as simple as possible because every keystroke will be repeated that many times. Fortunately, we can create our own languages that are simpler to use for humans, and convert them into machine code. Some famous languages of this type are C and C++, Java, Javascript, Lisp, and Fortran, but there are thousands of others. I've created two of my own for graphics processing and audio processing simply to facilitate finishing an in-class assignment. We weren't required to write a language; it was simply easier then the alternative. It is quite easy to write a language for a specific purpose for a person skilled in the art; I only mention the big ones because I expect you might recognize them but I would imagine that not a day goes by without some new little language being created somewhere. Computers don't understand these languages directly, but we can tell them how to translate these other made up languages into machine code that the computer can understand. (The precise mechanics involved in this process are absolutely fascinating, and ranks as one of the great engineering triumphs of the 20th century... and are way too complex to cover here.)

Since even dealing with assembly code gets old very quickly, we taught the computers how to take care of this for us. In C, I can write this:

area = width * height;

and the C compiler will automatically create the code for doing the multiplication and storing of the value, without the code writing needing to muck about with the exact memory location those things go into, or the exact bin the computation is performed in. And more importantly, the code writer doesn't need to think about these things, leaving their brains free to think about more important, high-level things that only humans are good at doing.

By creating these languages for our own use, which we call higher level languages (because they allow us humans to think at a higher level of abstraction, which we are more comfortable with), we allow ourselves to use words and other symbols where the computer only understands numbers. But before a modern computer can obey our command, the compiler program must convert "area = width * height" back into the machine code numbers that the computer understands, or it will be unable to execute them.

This is some of the machine language code from the Hello World program.

I derived the assembly language in the assembly language figure from the C program in the C language figure above. The C compiler I use works by converting the C code into assembly language, then the assembly language into machine code; I got the assembly language by asking the compiler to stop there. Most of that is just boilerplate; the important line is printf("Hello world!\n");. (The \n tells the computer to go to the next line after it prints Hello world!.) Almost all of the assembly code in the assembly language figure is the translation of that line, pretty much everything except the last three lines, which are the translations of return 0; and is a necessity imposed by the operating system, which always expects a program to return a number back to it. But you can see how it's still easier to read the C then the assembler. Some languages like Python are even simpler, where the code for the equivalent Python program would simply be print "Hello world!". Finally, I let the compiler generate the machine language from the assembly code, a portion of which is shown immediately above.

In order to make the easier languages work, we've learned how to tell computers to convert from one language to another. The computer only knows how to run code in machine language, so there are a lot of converters that go from some language to machine language, but there are other converters that work without ever going to machine language. For instance, there's a program called asp2php that takes code written to work on Microsoft's Internet Server platform in Visual Basic script using their Active Server Pages structure and converts the code to PHP, another web server programming system that allows the creation of dynamic pages.


Site Links


All Posts