This document discusses key concepts in modular programming including assemblers, linkers, public and external directives, libraries, and macros. Assemblers convert source code modules into object files while linkers combine object files into a single executable. Public and external directives allow communication between modules by declaring labels as available or external. Libraries are collections of common procedures that can be reused across programs. Macros provide a way to group instructions that perform a specific task to execute more efficiently than procedures.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
93 views
Modular Programming
This document discusses key concepts in modular programming including assemblers, linkers, public and external directives, libraries, and macros. Assemblers convert source code modules into object files while linkers combine object files into a single executable. Public and external directives allow communication between modules by declaring labels as available or external. Libraries are collections of common procedures that can be reused across programs. Macros provide a way to group instructions that perform a specific task to execute more efficiently than procedures.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14
MODULAR PROGRAMMING
MODULAR PROGRAMMING • Many programs are too large to be developed by one person.
• This means that programs are routinely
developed by teams of programmers. Assembler and Linker • Assembler program converts a symbolic source module (file) into a hexadecimal object file.
• The linker program, reads the object files that are
created by the assembler program and links them together into a single execution file. PUBLIC and EXTRN • The PUBLIC and EXTRN directives are very important to modular programming because they allow communications between modules.
• EXTRN , PUBLIC informs the assembler that the
names of procedures and labels declared after this directive have been already defined in some other assembly language modules. • PUBLIC is used to declare labels of code, data, or entire segments that are available to other program modules.
• When a data or Procedure needs to be accessed by
other modules, it is declared as Public.
• Public data1 OR Public mul
• EXTRN (external) declares that labels are external to a module.
• When a module needs to use data or code that is
defined elsewhere, it should use directice EXTRN meaning that the labels being used with EXTRN are external to the module.
• Without these statements, modules could not be
linked together to create a program by using modular programming techniques. .model small .data extrn data1:byte,data2:byte, here:near
.code mov bh,data2
mov ax,@data call here mov ax, 0FFFFh mov ds,ax mov ah,4ch mov bl,data1 int 21h end .model small .data mov ax,5678h data1 db 12h mov si,4567h data2 db 24h ret .code here endp mov ax,@data mov ds,ax mov ah,4ch public data1,data2,here int 21h here proc near end Libraries • Library files are collections of procedures that are used by many different programs.
• These procedures are assembled and compiled
into a library file by the LIB program that accompanies the MASM assembler program.
• Libraries allow common procedures to be collected
into one place so they can be used by many different applications. Macros • A macro is a group of instructions that perform one task, just as a procedure performs one task.
• In macros, all the instructions defined in the
macro, is inserted in the program at the point of usage.
• Creating a macro is very similar to creating a new
opcode. • Macro sequences execute faster than procedures because there is no CALL or RET instruction to execute.
• The MACRO and ENDM directives delineate a
macro sequence.
• The first statement of a macro is the MACRO
instruction, which contains the name of the macro and any parameters associated with it. Macro_name MACRO arg1, arg2,…..argn Statement 1 Statement 2 Statement k EndM • The last statement of a macro is the ENDM instruction, which is placed on a line by itself.
• Never place a label in front of the ENDM
statement. If a label appears before ENDM, the macro will not assemble. • Sometimes, macros contain local variables.
• A local identifier is one that appears in the macro,
Docker: The Complete Guide to the Most Widely Used Virtualization Technology. Create Containers and Deploy them to Production Safely and Securely.: Docker & Kubernetes, #1
Docker: The Complete Guide to the Most Widely Used Virtualization Technology. Create Containers and Deploy them to Production Safely and Securely.: Docker & Kubernetes, #1