176 Computer Architecture and Organization
level language to machine language is not optimum and tailor-made for the purpose. High level lan-
guage instructions are of general purpose type, and to maintain its applicability in all types of situa-
tions, the compiler has to take a broader view at the time of changing it to assembly language code.
For example, a compiler would always assign 4 bytes of space to accommodate an integer, while in
certain situations it might be accommodated within a byte by the assembly language programmer.
Therefore, every time one integer has to be compared with another integer, the compiler generated
machine language program (for high level language) has to compare four bytes of data, while one
byte comparison might solve the problem for its assembly language counterpart. Evidently, this
reduces the execution time of the assembly language program and makes it more ef cient (works
faster).
The second advantage of assembly language programming is that it makes the programmer’s concept
clear about the architecture of the processor. It is as if talking with someone with her(his) own language.
All advantages and utility of the processor become available to the assembly language programmer to
generate ef cient program codes. Therefore, the best way to understand the architecture of any proces-
sor is to develop a few assembly language programs by using it.
6.9.2 Assembly Language Program Format
Similar to every other language, assembly language also has its own format, which is a simple one. To
start with, assembly language programs are translated to machine language by the assembler, one line
after another . We shall discuss in details about assembler in Section 6.9.4. At present, we should keep
in mind that in assembly language programming, every line of the program listing is taken as a new and
complete statement. Therefore, every line of any assembly language program must be self-suf cient
and continuation of any line to the next line is not permitted in assembly language programming (in
general).
The general format for any line is shown in Figure 6.18 . As it may be observed, there are a total of
four elds, one each for ‘label, ‘mnemonic’, ‘operand’ and ‘comments’. Out of these four, comment
statements are non-executable statements and ignored by assembler during its assembly process.
They are included to improve the readability of the program and for general descriptions. Gener-
ally, they are indicated by a semicolon (;) at the beginning. A complete line may also be devoted by
comment statement, as shown. However, if any comment statement needs additional line(s), then
at the start of every line, there should be a semicolon, to indicate that the line contains a comment
statement.
As far as the instructions are concerned, its mnemonic eld is a compulsory one. An instruction may
or may not have any operand(s). For example, the mnemonic ‘NOP’ does not have any operand. If it
needs any, like ‘MOV A, B’, they have to be placed within the operand eld, which is generally sepa-
rated from the mnemonic eld by a space. If more than one operand to be placed, comma (,) has to be
used to separate them from each other.
The leftmost eld is reserved to accommodate labels. Labels are indications of various important
locations of the program body, referred within some instructions for branching or calling purpose. In
our example case (Figure 6.18 ), the rst instruction’s location is indicated by the label START, which
was referred in the second instruction. Labels are not only used to indicate some special locations
within the program body, they may also be used to improve the readability of any program. Note that
no reserved words may be used for label. These reserved words include mnemonics and assembler
directives (Section 6.9.4).
M06_GHOS1557_01_SE_C06.indd 176M06_GHOS1557_01_SE_C06.indd 176 4/29/11 5:09 PM4/29/11 5:09 PM