B.1 Assembly Languages

There are five major advantages of assembly language, as compared to machine language:

  1. It uses mnemonic op-codes, we do not need to remember actual bit-patterns of the op-code. For example, referring to 8085 microprocessor, we can write ‘ADD A’ instead of ‘87’ in hex.
  2. Addresses can be given as symbolic addresses instead of numeric values. The assembler keeps track of the symbolic addresses by building a Symbol Table.
  3. It is more human readable.
  4. It makes available certain auxiliary operations like defining data and storage areas, setting the origin of a program segment, etc.
  5. It may provide address arithmetic, macros, scoping of identifier names, conditional assembly, ready-made macros or subroutine library for input/output, etc.

There are also certain disadvantages:

  1. You have to use an assembler to translate it.
  2. A programmer has to mentally translate the steps of the job to be implemented into a machine-specific sequence of operations.
  3. Many mundane and routine operations are to be implemented by the programmer.
  4. It is tedious and error-prone. Programmer productivity is very low.
  5. It is non-portable, i.e. if the CPU family is changed, complete recoding is required.

In this appendix, we shall use 8085 microprocessor machine code and assembly language as a running example. A typical small program in assembly language: this program copies 100-bytes from location 400016 to 406416. The program starts at location 700016.

B.1.1 Example Assembly Language

As indicated above, we shall use Intel 8085 microprocessor's assembly language as a running example.

 

A small assembly language program

 

Fig. B.1 A small assembly language program

 

Statements: The statements in this language are written one per line. The structure of a statement looks like:


<lable> : <Mnemonic> <blank/s> <operand1>
[ , <operand2>] [; <comments>]

Mnemonic may be a machine code or a pseudo-operation like data definition. Labels are upto 5 characters from set [A–Z@?0–9] with first character from [A–Z@?].

Pseudo-operations: There are several pseudo-operations available:

DB – define a byte or a sequence of bytes.

DS – define storage in terms of bytes.

DW – define 16-bit word data, order is Little-Endian.

EQU – equate a symbol to some value.

ORG – set origin of the following code.

 

Note that EQU requires a label (without colons), DB, DW and DS usually have label and ORG should not have a label.

Addresses: Addresses may be expressed in any of the following forms:

Decimal: Using digits [0–9], not more than 5 digits.

Hexadecimal: Using digits[0–9A–F], not more than 4 digits, followed by ‘H’ and starting with [0–9].

Octal: Using digits [0–7], followed by ‘O’ or ‘Q’.

Binary: Using digits [0–1], followed by ‘B’.

Symbolic: A data label defined somewhere in the program. Address arithmetic may be done – allowed operations are +, -, MOD, *. All address calculations using 16-bit numbers.

Offset from Location Counter (LC): LC is denoted by ‘$’ in the operand field. Offset can be positive or negative.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.250.203