Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
66 views

LEcture 14 Assembly Process and Modular Programming

The assembler converts assembly language source files into object files. The linker then combines multiple object files into a single executable file. Modular programming involves using multiple object files produced by different programmers and languages, with communication between modules enabled by keywords like PUBLIC and EXTRN. Libraries are collections of common procedures that can be reused across programs, reducing duplicated code. Dynamic link libraries (DLLs) similarly allow sharing of code in memory. Assembly language instructions are translated into machine code based on their opcode, operands, and addressing modes.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

LEcture 14 Assembly Process and Modular Programming

The assembler converts assembly language source files into object files. The linker then combines multiple object files into a single executable file. Modular programming involves using multiple object files produced by different programmers and languages, with communication between modules enabled by keywords like PUBLIC and EXTRN. Libraries are collections of common procedures that can be reused across programs, reducing duplicated code. Dynamic link libraries (DLLs) similarly allow sharing of code in memory. Assembly language instructions are translated into machine code based on their opcode, operands, and addressing modes.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Assembly process and

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

• EXTRN appears in both data and code segments to define labels as


external to the segment.
• if defined as external, sizes must be defined as BYTE, WORD, or DWORD
• if jump or call address is external, it must be defined as NEAR or FAR

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.

• A variable is transferred to each file, so the EXTRN statement also


appears in each procedure to gain access to an external variable.

10
Dynamic link Libraries (DLLs)
• Lets imagine three programs, all of them using some same function

• In static linking, that function would be included in all the three


programs causing the replication of the function three times

• In dynamic linking, the function would be placed in a DLL and one


copy of the DLL would be provided for all the three programs. The
programs can dynamically link, resulting in memory savings

11
Macros
• A group of instructions with a symbolic name. Similar to EQU for
variables

• When the macro name is written in an assembly language program,


the macro expands to include all the instructions

• Thus macros increase the size of the program

• Macros are faster than CALLs and RETs


12
Example of Macro

13
Translation of Assembly Language into
machine code
• Instruction format (real mode)

• Opcode byte

14
• Opcode byte

• Mode / REG / R/M

• 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

You might also like