Page 13 - DCAP102_DCAP_401_Foundations of Computer Programming
P. 13
Basic Programming Skills/Foundations of Computer Programming
Notes 4. Trace the execution of the specifi ed segment of the program and display the register and
memory contents after the execution of each instruction.
5. Disassemble a section of the program, i.e., convert the object code into the source code or
mnemonics.
In summary, to run an assembly program you may require your computer:
1. A word processor like notepad
2. MASM, TASM or Emulator
3. LINK.EXE, it may be included in the assembler
4. DEBUG.COM for debugging if the need so be.
Errors
Two possible kinds of errors can occur in assembly programs:
1. Programming errors: They are the familiar errors you can encounter in the course of
executing a program written in any language.
2. System errors: These are unique to assembly language that permit low-level operations.
A system error is one that corrupts or destroys the system under which the program is
running - In assembly language there is no supervising interpreter or compiler to prevent
a program from erasing itself or even from erasing the computer operating system.
Task Discuss the roles of assembler in computer programming.
1.4 Assembler
An assembly program is used to transfer assembly language mnemonics to the binary code for
each instruction, after the complete program has been written, with the help of an editor it is then
assembled with the help of an assembler.
An assembler works in two phases, i.e., it reads your source code two times. In the first pass the
assembler collects all the symbols defined in the program, along with their offsets in symbol table.
On the second pass through the source program, it produces binary code for each instruction of
the program, and give all the symbols an offset with respect to the segment from the symbol
table.
The assembler generates three files. The object file, the list file and cross reference file. The object
file contains the binary code for each instruction in the program. It is created only when your
program has been successfully assembled with no errors. The errors that are detected by the
assembler are called the symbol errors.
Example: MOVE AX1, ZX1 ;
In the statement, it reads the word MOVE, it tries to match with the mnemonic sets, as there is no
mnemonic with this spelling, it assumes it to be an identifier and looks for its entry in the symbol
table. It does not even find it there therefore gives an error as undeclared identifi er.
List file is optional and contains the source code, the binary equivalent of each instruction, and
the offsets of the symbols in the program. This file is for purely documentation purposes. Some
of the assemblers available on PC are MASM, TURBO etc.
6 LOVELY PROFESSIONAL UNIVERSITY