Program Translation

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

To the source program, where the change is easy to make. The changed source program is then translated into a new executable program.

Program Translation

Here is a picture that shows what usually happens with programs written in "C" (Java is different; it will be discussed in the next chapter.)

Translating a source program

Here is an overview of what goes on:

  1. The source file is created using a text editor.
    • It contains instructions in a high level language.
    • It contains bytes that represent characters.
    • The source file is kept on the hard disk.
    • The source file can not be run by the processor.
  2. A translator (compiler) program translates the source file into an executable file.
    • The source file remains unchanged; a new executable file is created.
    • The executable file contains machine instructions.
    • A translator translates from a specific high level language (like C) into machine instructions for a specific processor type (like Pentium).
    • The executable file is also kept on hard disk.
  3. The program is run by copying machine language from the executable file into main memory. The processor directly executes these machine language instructions.
Executing Machine Language

The above is what goes on with most languages: Ada, Pascal, C, C++, FORTRAN and others. Java adds a few more steps, which will be discussed in the next chapter.

QUESTION 10:

A source program has been written in the "C" language. The file has been copied onto the hard disk of a Pentium-based computer and also onto the hard disk of an Motorola-based computer. What must now be done so that the program can execute on both computers?