Machine Language |
= The native tongue of the CPU.
Each design for a CPU has its own machine language. This is the set of instructions that the chip uses itself. So it is made up of sets of 0's and 1's, that is binary numbers. Very hard for people to work with.
10 23
11 FF
12 12
13 10
14 50
15 23
16 30
17 40
18 C0
19 00
|
Machine language looks like it's just numbers. In the program segment at left the first column tells the computer where to fill memory and the hexadecimal (base 16) numbers in the second column are the values to put into memory at those locations.
For more information on hexadecimal numbers, see Base Arithmetic.
|
Here's another example of machine language.
The segment of Java
code:
int counter = 0;
counter = counter + 1; might be translated into machine language as:
000101000100010001000100001000101010111110
000001110101000111110000100010000010101010 |
|
Assembly Language |
= Codes or abbreviations for the machine language instructions
In an assembly language each machine language instruction is assigned a code. So instead of having to remember a string of 0's and 1's, the programmer would only need to remember short codes like ADD, MOV, or JLE. Certainly an improvement over
000101000100010001000100001000101010111110!! But not really "user friendly" either.
The assembly language program below reads two characters and prints them on the screen. The text to the right of the semicolons ( ; ) is ignored by the computer. It's there to explain the program to anyone looking at the code. Notice that each little step must be coded. All this just to display 2 characters!
;name of the program:one.asm
;
.model small
.stack
.code
mov AH,1h ;Selects the 1 D.O.S. function
Int 21h ;reads character and return ASCII
; code to register AL
mov DL,AL ;moves the ASCII code to register DL
sub DL,30h ;makes the operation minus 30h to
; convert 0-9 digit number
cmp DL,9h ;compares if digit number it was
; between 0-9
jle digit1 ;If it true gets the first number
; digit (4 bits long)
sub DL,7h ;If it false, makes operation minus
; 7h to convert letter A-F digit1:
mov CL,4h ;prepares to multiply by 16
shl DL,CL ;multiply to convert into four bits upper
int 21h ;gets the next character
sub AL,30h ;repeats the conversion operation
cmp AL,9h ;compares the value 9h with the content
; of register AL
jle digit2 ;If true, gets the second digit number
sub AL,7h ;If no, makes the minus operation 7h
; digit2:
add DL,AL ;adds the second number digit
mov AH,4CH
Int 21h ;21h interruption
End ;finish the program code
|
|
FORTRAN |
= Formula Translation
FORTRAN was created around 1957 to help scientists, engineers, and mathematicians write programs that describe complex situations, like nuclear power plant monitoring, nuclear explosions, and space flight. This is still a widely used language. It was the first successful high-level program. Newer versions have been released. FORTRAN 95 was released in Dec. 15, 1997.
The example Fortran program below accepts the bus number 99 and displays the command "TAKE BUS 99"
PROGRAM IDEXMP
INTEGER BUS_NUM
BUS_NUM = 99
WRITE(*,*) ' TAKE BUS ', BUS_NUM
END
|
|
COBOL |
= Common Business Oriented Language
COBOL was written about 1960 with business applications in mind. It has a very English-like structure, using sentences and paragraphs, though they are certainly different from those in a novel. This helps business people who are not high-powered programmers to be able to write or edit a program. But it has the disadvantage of tending toward wordy, lengthy programs. It is a good language for direct, simple programs.
COBOL was used to create many programs for the main frames of large companies.
These programs were upgraded during the Y2K fixes
for the year 2000. So it seems
likely that COBOL programs will be around for a long time yet. [See the
article at http://www.infogoal.com/cbd/cbdz009.htm
for a longer discussion of this issue.]
The example below accepts two numbers, multiplies them, and displays the numbers and the result. Look at the PROCEDURE DIVISION to see where the calculation is done.
$ SET SOURCEFORMAT"FREE"
IDENTIFICATION DIVISION.
PROGRAM-ID. FragmentA.
AUTHOR. Michael Coughlan.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Num1 PIC 9 VALUE ZEROS.
01 Num2 PIC 9 VALUE ZEROS.
01 Result PIC 99 VALUE ZEROS.
PROCEDURE DIVISION.
Calc-Result.
ACCEPT Num1.
MULTIPLY Num1 BY Num2 GIVING Result.
ACCEPT Num2.
DISPLAY "Result is = ", Result.
STOP RUN.
|
|
BASIC |
= Beginner's All Symbolic Instruction Code
This language was written in 1964 (truly the age of dinosaurs for computers!) for college students to use to learn programming concepts. Originally BASIC was intended only for classroom use. But the language has proven to be highly useful in the real world. A wide variety of "dialects" of BASIC developed through the years. Visual Basic is now very popular for programming Windows applications.
Microsoft Visual Basic for Applications is an example of a subset of BASIC that is modified to help users write small subprograms called scripts or macros for use with
applications like MS Word. Some applications used to have their own variety of BASIC for writing their macros,
like Word Basic and Excel Basic.
The creators of BASIC wanted a language that felt more like regular English. So while it doesn't LOOK much like English, it uses enough of the syntax of English to give it a more natural feel than many other computer languages.
The short program below is written in BASIC. It accepts a distance in miles, yards, feet, and inches and converts it to kilometers, meters, and centimeters. Notice how the programmer can write equations to do the calculations.
' English to Metric Conversion
' J. S. Quasney
' ****************************
PRINT : PRINT "English to Metric Conversion"
PRINT
INPUT "Miles: ", Miles
INPUT "Yards: ", Yards
INPUT "Feet: ", Feet
INPUT "Inches: ", Inches
Inches = 63360 * Miles + 36 * Yards + 12 * Feet + Inches
Meters# = Inches / 39.37#
Kilometers = INT(Meters# / 1000)
Meters# = Meters# - 1000 * Kilometers
Final.Meters = INT(Meters#)
Centimeters = Meters# - Final.Meters
Centimeters = 100 * Centimeters
Centimeters = INT((Centimeters + .005) * 100) / 100
PRINT
PRINT "Kilometers:"; Kilometers
PRINT "Meters:"; Final.Meters
PRINT "Centimeters:"; Centimeters
END
|
|
C |
Originally created for writing system software, C has evolved into C++.
Both are widely used by programming professionals for all sorts of programs.
The program below is written in C++. It accepts 3 numbers and checks to see if the third is equal to the difference of the first two.
#include <iostream.h>
void main()
{
int a, b, c;
cout << "Please enter three numbers\n";
cout << "a: ";
cin >> a;
cout << "\nb: ";
cin >> b;
cout "\nc: ";
cin >> c;
if (c=(a-b))
{
cout << "a: ";
cout << a;
cout << " minus b: ";
cout << b;
cout << " equals c: ";
cout << c << endl;
}
else
cout << "a-b does not equal c:" << endl;
}
|
|
Java |
A newly popular language Java is used to write both full computer applications and small applets for web pages. Its goal is to create applications that will run on any computer unlike other languages which are not cross-platform. For example, MS Word for Windows will not run on a Macintosh or Unix computer. You must buy the version of MS Word that is written for your particular operating system.
(By the way, don't confuse Java with JavaScript, a scripting language commonly used on web pages. The only thing they share is the letters in their
names! JavaScript started life as LiveScript in about 1994. Netscape bought it
and renamed it, apparently for marketing reasons.)
The example below draws a box on an HTML page and counts the number of times you have clicked inside the box.
import java.applet.*;
import java.awt.*;
public class exfour extends Applet
{
int i;
public void init()
{
resize(300,300);
}
public void paint(Graphics g)
{
g.drawString("You clicked the mouse "+i+" Times",50,50);
}
public boolean mouseUp(Event e, int x, int y)
{
i++;
repaint();
return true;
}
}
|
|

~~ 1 Cor. 10:31 ...whatever you do, do it all for the
glory of God. ~~
Last updated:
22 Jan 2008 |