LEcture 14 Assembly Process and Modular Programming
LEcture 14 Assembly Process and Modular Programming
modular programming
1
Assembler operation
• The assembler program converts a symbolic source module (file) into
a hexadecimal object file.
• Whenever you create a source file, it should have the extension of
ASM.
• Source files are created by using NotePad or almost any other word
processor or editor capable of generating an ASCII file.
• The linker program reads the object files that are created by the
assembler program and links them together into a single execution
file.
2
Assembler Process
• An execution file is created with the file name extension EXE.
3
EXE and COM files
• Execution files are selected by typing the file name at the DOS prompt
(C:\).
• Files less than 64K bytes long can be converted from an execution file
to a command file (.COM).
• COM files must start from 100H origin
• This means that the program must be no larger than 64K–100H in
length.
4
Modular Programming
• Performed by using several OBJ files produced by different
programmers using different programming languages
• Communication between modules is important
• Different keywords are there for aiding inter- modular communication
• PUBLIC declares labels of code, data, or entire segments are available to other
program modules
• EXTRN (external) declares labels are external to a module
5
Example of public
6
Extern
7
Example of Extern
8
Libraries
• A collection of common procedures (OBJ files) so that they can be
used by many different programs
• The main idea behind high level languages
• assembled and compiled by the LIB program that accompanies the MASM
assembler
• When the library file is linked with a program, only procedures
required by are removed from the library file and added to the
program
9
Library (Continued)
• A library file is a collection of assembled .OBJ files that contains
procedures or tasks written in assembly language or any other
language.
• The procedure must be declared PUBLIC and does not need to match
the file name.
10
Dynamic link Libraries (DLLs)
• Lets imagine three programs, all of them using some same function
11
Macros
• A group of instructions with a symbolic name. Similar to EQU for
variables
13
Translation of Assembly Language into
machine code
• Instruction format (real mode)
• Opcode byte
14
• Opcode byte
• D=0, data flows into R/M from REG (or vice versa) and W=0 (for byte) and W = 1
(for word)
15
16
Examples
17
• Segment registers can only be placed in REG field and W=0 in this
18
R/M Memory addressing
19
20
21
• If only displacement, MODE = 00 and R/M = 110, MOV [1000H], DL
22
23