[logo]

What is a Compiler? What is Ada?

Home
Products
What's Ada? What's a Compiler?
Contacts
Technologies
Partners
Freebies
Support

Compilers

A compiler is a computer program that transforms "source code" written by a programmer into the "machine language" that a computer can understand.

Programmers write source code in a computer language, such as Ada, Pascal, C, C++, Cobol, Fortran, BASIC, or Java. These languages have a specific structure, syntax, and rules the programmer must follow. The compiler takes this source code and translates it into specific steps that the processor can understand. The resulting machine language can only be understood by a specific processor, such as a Pentium, PowerPC, 68000, Alpha AXP, or Intel i960 MX.

Here's an example:

Source Code (written in Ada)

while (row <= max) and (col <= max) loop
   if is_safe(row, col) then
      set_queen(row, col);
      col := col+1;
      row := min;
   else
      row := row+1;
   end if;
end loop;

The compiler translates this into Assembly Language (for Intel i960 MX)

.I6.295: 	# --label_295--
  ldis       40(r3),g7
  cmpibg.f   r4,g7,.I6.296
  cmpibg.f   r7,g7,.I6.296
  mov        r7,g1
  mov        r4,g0
  lda        64(fp),g12
  callj      _QueensnIs_safe289
  cmpobe.f   0,g0,.I6.298
  mov        r7,g1
  mov        r4,g0
  callj      _QueensnSet_queen283
  addi       r7,1,r7
  mov        g14,r4
  b          .I6.295
.I6.298:        # --label_298--
  addi       r4,1,r4
  b          .I6.295
.I6.296: 	# --label_296--

The assembly language gets translated into code that the processor can run:

40002E20:  C8B8E028
40002E24:  3925C03E
40002E28:  393DC03A
40002E2C:  5C881607
40002E30:  5C801604
40002E34:  8CE7E040
40002E38:  09FFFF08
40002E3C:  3204201E
40002E40:  5C881607
40002E44:  5C801604
40002E48:  09FFFE68
40002E4C:  59385087
40002E50:  5C20161E
40002E54:  08FFFFCC

Next: What's Ada?



Copyright © 2002 Irvine Compiler Corporation. All Rights Reserved.
Last modified 5/13/02. Comments to webmaster@irvine.com