Assembly Language


Introduction to concept of Machine Language, Assembly Language and High Level Language

To command a computer's hardware, you must speak its language. The words of a machine's language are called instructions, and its vocabulary is called an instruction set. A CPU can understand and execute machine instructions. Such instructions are simply binary numbers stored in the computer. If a programmer wished to program directly in machine language, then it would be necessary to enter the program as binary data.

Consider the simple BASIC statement:

N = I + J + K

Say, we wished to program this statement in machine language and initialize I, J, and K to 2, 3 and 4, respectively. This is shown in Table 1.0a. The program starts in location 101 (hexadecimal). Memory is reserved for the four variables starting at location 201. The program consists of four instructions:

1.    Load the contents of location 201 into CPU register AC (accumulator).

2.    Add the contents of location 202 to the AC.

3.    Add the contents of location 203 to the AC.

4.    Store the contents of the AC in location 204.

This is clearly a tedious and very error-prone process.

A slight improvement is to write the program in hexadecimal rather than binary notation (Column 3 in Table 1.0a below). Each line contains the address of a memory location and the hexadecimal code of the binary value to be stored in that location. Then we need a program that will accept this input, translate each line into a binary number, and store it in that location.

This is only a slight improvement. To do much better, we can make use of the symbolic name or mnemonic of each instruction. In addition we also use symbolic addresses. This is illustrated in Figure 1.0b. Each line consists of three fields. The first field is for the address, but a symbol is used instead of an absolute numerical address. Some lines have no addresses implying that the address of that line is one more than the address of the previous line. For an instruction, the second field contains the three-letter symbol for the op code. If it is a memory referencing instruction, then a third field contains the address. With these refinements we have invented an assembly language. Programs written in assembly languages are translated into machine language by an assembler.

Address

Contents

Contents in Hexadecimal Code

101

0010 0010 0000 0001

2201

102

0001 0010 0000 0010

1202

103

0001 0010 0000 0011

1203

104

0011 0010 0000 0100

3204

201

0000 0000 0000 0010

0002

202

0000 0000 0000 0011

0003

203

0000 0000 0000 0100

0004

204

0000 0000 0000 0010

0000

Table 1.0a
 

Label

Operation

Openefd

FORMUL

LDA

I

 

ADD

J

 

ADD

K

 

STA

N

I

DATA

2

J

DATA

3

K

DATA

4

N

DATA

0

Table 1.0b

2.0              ASSEMBLY LANGUAGE

Assembly language unlocks the secrets of your computer hardware and software. It teaches you about the way the computer's hardware and operating system work together and how application programs communicate with the operating system. It might be helpful to view a computer and its software as a series of hierarchical levels such as those shown in Table 2.0a. Most programmers work at the high-level language level (examples: C++, Java, Pascal), where individual statements are expanded into multiple machine instructions. At the assembly language level, one creates instructions directly interpreted by the computer's processor. Assembly language is a low-level language.

What is Assembly Language?

Assembly language is a machine specific language with a one-to-one correspondence between its statements and the computer's native machine language. There are many different types of assembly language, each specific to a processor or processor family. This is because the instructions in assembly language are designed to match a computer's machine instruction set and hardware architecture.

What is an Assembler?

An assembler is a program that converts source-code program from assembly language into machine language. A companion program called linker, combines individual files created by an assembler into a single executable program.

Level

Description

Application Program

Software designed for a particular class of applications

High Level Language

Programs are compiled into either assembly or machine language. Each statement usually translates into multiple machine language instructions. Examples are C++, Pascal, Java, and Visual Basic.

Operating System

Contains procedure that can be called from programs written in either high-level language or assembly language. This system may also contain an Application Programming Interface (API).

Assembly Language

Uses instruction mnemonics that have a one-to-one correspondence with machine language

Machine Language

Numeric instructions and operands that can be stored in memory and directly executed by the computer processor.

Table 2.0a

3.0              MACHINE LANGUAGE

A computer doesn't directly interpret assembly language, but it does understand machine language. Machine language is a language made up of numbers, which can be interpreted by a computer's processor. A processor usually has a built-in interpreter called a microprogram that interprets and translates machine instructions into hardware signals.

Machine language contains primitive statements that perform ordinary tasks such as moving data from one location to another or performing simple arithmetic. A processor's instruction set is the set of machine instructions that it can execute. By learning how instructions are represented, you can also discover the secret of computing: stored-program concept. The chosen instruction set here, comes from MIPS, used by NEC, Nintendo, Silicon Graphics, and Sony, among others. Topics 2 through 9 covers the MIPS instruction set step by step.

REFERENCES

Irwin, R. (1999). Assembly Language for Intel Based Computers. (3rd ed.). New Jersey: Prentice.

Stallings, W. (1990). Computer Organization and Architecture. (2nd ed.). New York: Macmillan.

Hennessy, L., & Patterson, A. (1998). Computer Organization and Design. (2nd ed.). San Francisco: Morgan Kaufmann.


MIPS Home