Sunday, December 2, 2012

The Assembly Language Level


The assembly language level differs in a significant respect from the micro architecture, ISA, and operating system machine levels- it is implemented by translators rather than by interpretation.

Translator: Program that convert a user's program written in some language to another language are called translator.

Source Language: The language in which the original program is written is called the source language.

Target Language: The language to which it is converted is called the target language.


  • Difference between translation and interpretation    
In translation, the original program in the source language (C, C++, or JAVA)  is not directly executed. Instead, it is converted to an equivalent program called an object program (.obj) or executable binary program (.class, .exe) whose execution is carried out only after the translation has been completed.

  1. Generation of an equivalent program in the target language
  2. Execution of newly generated language
These two steps do not occur simultaneously. The second step does not begin until the first has been completed.


"When the source language is essentially a symbolic representation for a numerical machine language, the translator is called an assembler and the source language is called an assembly language. "


Assembly Language:
  • each statement produces exactly one machine instruction
  • much easier code than in machine language
  • combination of symbolic names and symbolic addresses 
  • It has access to all the features and instruction available on the target machine
  • an assembly language program can run only one family of machines 

Macros:

  • A macro definition is a way to give name to a piece of text. After a macro has been defined, the programmer can write the macro name instead of the piece of program 
Example:

           SWAP MACRO
                       MOV EAX,P
                       MOV EBX,B
                       MOV Q,EAX
                      MOV P,EBX
                      ENDM

                      SWAP
                      SWAP 

Courtesy: Andrew S. Tanenbaum, Structured Computer Organization (Fifth Edition)