Page 35 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 35
Unit 2: Introduction to Assembly Language
You can use blank lines anywhere in your source file. Blank lines are useful for spacing out Notes
certain sections of code, making them easier to read.
The Microsoft Macro Assembler is a free form assembler. The various fields of an assembly
language statement may appear in any column (as long as they appear in the proper order). Any
number of spaces or tabs can separate the various fields in the statement. To the assembler, the
following two code sequences are identical:
mov ax, 0
mov bx, ax
add ax, dx
mov cx, ax
mov ax, 0
mov bx, ax
add ax, dx
mov cx, ax
1. Unless, of course, the semicolon appears inside a string constant: Directives and Pseudo
The first code sequence is much easier to read than the Pseudo code, with respect to readability,
the judicial use of spacing within your program can make all the difference in the world.
Placing the labels in column one, the mnemonics in column 17 (two tabstops), the operand field
in column 25 (the third tabstop), and the comments out around column 41 or 49 (five or six
tabstops) produces the best looking listings. Assembly language programs are hard enough to
read as it is. Formatting your listings to help make them easier to read will make them much
easier to maintain.
You may have a comment on the line by itself. In such a case, place the semicolon in column one
and use the entire line for the comment, examples:
; The following section of code positions the cursor to the upper
; left hand position on the screen:
mov X, 0
mov Y, 0
; Now clear from the current cursor position to the end of the
; screen to clear the video display:
; etc.
2.4 Computer Languages
The term computer language includes a wide variety of languages used to communicate with
computers. It is broader than the more commonly-used term programming language.
Programming languages are a subset of computer languages. For example, HTML is a markup
language and a computer language, but it is not traditionally considered a programming language.
Machine code is a computer language. It can technically be used for programming, and has been
(e.g. the original boots trapper for Altair BASIC), though most would not consider it a
programming language.
Computer languages can be divided into two groups: high-level languages and low-level
languages. High-level languages are designed to be easier to use, more abstract, and more portable
than low-level languages. Syntactically correct programs in some languages are then compiled to
LOVELY PROFESSIONAL UNIVERSITY 29