ARCHITECTURE AND INSTRUCTIONS

The process of translation might involve per- forming some additional activities before the output is truly machine code. These activities, like relocation and linkage, are part of the translation process. Throughout this text, references to translation (assembling, compil- ing) imply all necessary activities to produce object code.

A program written in assembly language is a symbolic representation of the machine- language program.

The relation between the assembly-language program statements and the resulting object code is usually obvious while the relation between high-level language statements and the resulting object code is often not obvious. Assembly language gives you complete con- trol over the resulting object code and thereby allows you to generate very efficient object code (providing you're a very efficient programmer).

A high-level language compiler frees you from thinking about the object code and lets

~g~~CE _ TRANSLATOR~g~bEECT

(MACHINE

LANGUAGE)

Figure 2-11. Translation Process

SOURCE_ ASSEMBLER f---0BJECT

CODECODE

lASSEMBLY(MACHINE

ANGUAGE)LANGUAGE)

SOURCEBOBJEC,

CODECODE

(HIGH-LEVEL(MACHINE

LANGUAGE)LANGUAGE)

Figure 2-12. Assemblers and Compilers

you concentrate on the task you are pro- gramming. The compiler may generate less efficient object code, but good compilers can sometimes generate more efficient object code than you could have written in assembly language.

SYMBOLIC NAMES

The primary advantage of using assembly language instead of machine language is the ability to use symbolic names. Let's illustrate this point using assembly-language source code:

CYCLE:

 

 

IN

AX,5

;read word from port 5 into AX

INC

AX

;increment AX

OUT

2,AX

;write result to port 2

JMP

CYCLE

;keep repeating

The above program is simpler to read and understand because it uses symbolic names instead of numbers as much as possible. The opcodes ofthe four instructions are 1110010-, 01000---, 1110011-, and 11101011 in the object code. They are IN, INC, OUT, and JMP in the assembly-language source code. Symbolic names for opcodes are called instruction mnemonics. The symbolic opcode names used throughout this book are the instruction mnemonics of ASM-86 that gen- erate corresponding bit patterns for object code.

Register Names

Besides the opcode fields, there are other fields in the object code (see above example). The contents of these fields must be specified in the assembly-language source code, so the assembler can generate the appropriate bit patterns in the object code.

For example, the INC instruction has a 3-bit reg field, indicating which register is to be incremented when the instruction is executed. The contents of this reg field are specified in the source code by indicating the symbolic name of the register, as in "INC AX."

2-19

Page 54
Image 54
Intel 210200-002 manual ~g~~CE TRANSLATOR~g~bEECT