Books and References © Rance Necaise
Computer AbstractionsChapter 1. IntroductionThe Digital Computer

Programming Language Levels

As you saw in the previous section, the programming languages used with modern computers are divided into three levels:

  • High-level languages
  • Assembly language
  • Machine language (or machine code)

High-Level Languages

As computer scientists and computer programmers, we prefer to use high-level languages like Python, C, or Java because they are easier to use. For example, suppose we want to evaluate the mathematical expression

y = x × a + x × b

Most high-level languages provide a simple way to write this expression using familiar notation. In Python or C, we might implement this expression as follows:

y = x * z + x * b;

Programs written in a high-level language are machine independent. That is, they can be used on different architectures without having to rewrite the program. A programmer can write the program without having to know or depend on the instructions of the given processor.

In order to use these programs, however, we must use a compiler or an interpreter to translate the high-level language instructions into assembly language and then into machine code. Typically, this involves taking a single high-level language instruction and translating it into multiple assembly language instructions.

A program written in a high-level programming language can not be executed directly by a computer processor. Some languages like C, C++, and Fortran are translated into machine code and executed directly on the computer. Other languages like Python and Java are translated into byte-code (a generic machine code) that is "executed" by a virtual machine on the actual computer. The virtual machine is simply a program written in a high-level language that has been compiled for a given processor. Although the source programs are machine independent, the executable virtual machine is dependent on a specific processor.

Assembly Language

Assembly language is a rudimentary programming language machine dependent or specific to each particular type of architecture. It provides a symbolic representation for the machine code of the processor. Typically, a single high-level language statement will result in multiple assembly language instructions. For example, the statement evaluating the mathematical expression from the previous section may translate to the following assembly language instructions

MUL S, X, A
MUL T, X, B
ADD Y, S, T

The assembly language instructions consists of a one-to-one correlation between machine code instructions and assembly language instructions. Most assembly languages also provide pseudo instructions, which allows the assembly language to be expanded to incorporate groups of machine instructions in one assembly language command. The assembly language instructions must be translated into machine code using an assembler.

Machine Code

A processor is designed for a specific instruction set architecture, which are specified as a sequence of binary digits. This means the processor understands a unique binary language, and no other.

As an electronic device, a processor can only interpret two values, on and off, which are indicated as electrical signals. Humans normally notate these values as 1 and 0.

Machine code instructions are the binary representation of assembly language instructions. These instructions, which are machine dependent, are "executed" by the digital circuits in the processor. The assembly language instructions for our mathematical expression may be represented in machine code as

1010011000111011
1010101000011011
1000110010100000

Executable programs are simply files that contain machine code in binary form for a specific architecture. When the program is executed, the processor reads the binary instructions, one at a time, interprets them and then carries out the task using its digital circuits.

Example

Below is a complete example of a function written in the C programming language that is compiled into MIPS assembly language and then assembled into machine code for a MIPS processor.

Question 1.

For each of the following languages or program types, indicate whether the language is machine dependent or machine independent.

Select the correct answer by clicking on the appropriate button.
  1. dependent|independent
  2. Java
    Java is a high-level language that can be used to write programs that are machine independent.
  3. C++
    C++ is also a high-level language that is a superset of the C programming language. Like C, it can be used to write programs that are machine independent.
  4. MIPS assembly language
    All assembly languages are machine dependent. That is, they can only be used to create an executable program for a specific computer architecture. You will learn the MIPS assembly language in this course.
  5. Intel executable program

    An executable program is nothing more than a file containing machine code instructions. Thus, it can only be executed by a processor with a specific architecture.

Computer AbstractionsChapter 1. IntroductionThe Digital Computer
Page last modified on August 16, 2021, at 10:33 PM