Manual Masm
Manual Masm
INTRODUCTION TO MASM
The Microsoft macro assembler is an x86 high level assembler for DOS and Microsoft
windows. It supports wide varieties of macro facilities and structured programming
idioms including high level functions for looping and procedures
A program called assembler used to convert the mnemonics of instructions along with
the data into the equivalent object code modules, these object code may further
converted into executable code using linked and loader programs. This type of program
is called as ASSEMBLY LANGUAGE PROGRAMMING. The assembler converts and
Assembly language source file to machine code the binary equivalent of the assembly
language program. In this respect, the assembler reads an ASCII source file from the
disk and program as output. The major different between compilers for a high level
language like PASCAL and an Assembler is that the compiler usually emits several
machine instructions for each PASCAL statement. The assembler generally emits a
single machine instruction for each assembler language statement.
MASM PROG.ASM
The MASM program will assemble the PROG.ASM file. (To create PROG.OBJ
from PROG.ASM)
To link more than one object file use + signs between their file names as in:
LINK PROGA+PROGB+PROGC
DEBUG is a utility program that allows a user to load an 80x 86 programs into
memory and execute it step by step. DEBUG displays the contents of all processor
registers after each instruction execute, allowing the user to determine if the code is
performing the desired task. DEBUG only displays the 16-bit portion of the general
purpose registers. Code view is capable of displaying the entire 32 bits. DEBUG is a
very useful debugging tool. We will use DEBUG to step through a number of simple
programs, gaining familiarity with Debug’s commands as we do so. DEBUG
contains commands that can display and modify memory, assemble instructions,
disassemble code already placed into memory, trace single or multiple instructions,
load registers with data and do much more.
DEBUG loads into memory like any other program, in the first available slot.
The memory space used by DEBUG for the user program begins after the end of
Debug’s code. If an .EXE or .COM file were specified, DEBUG would load the
program according to accepted DOS conventions.
DEBUG PROG.EXE
DEBUG uses a minus sign as its command prompt, so should see a “-“ appear on
display.
ASSEMBLER DIRECTIVES: The limits are given to the assembler using some pre
defined alphabetical strings called Assembler Directives which help assembler to
correctly understand. The assembly language programs to prepare the codes.
DB GROUP EXTRN
DW LABEL TYPE
DQ LENGTH EVEN
DT LOCAL SEGMENT
ASSUME NAME
END OFFSET
ENDP ORG
ENDS PROC
EQU PTR
DB-Define Byte: The DB drive is used to reserve byte of memory locations in the available
on memory.
DW-Define Word: The DW drive is used to reserve 16 byte of memory location available
on memory.
DQ-Define Quad Word (4 words): The DB directives is used to reserve 8 bytes of memory
locations in the memory available.
DT-Define Ten Byte: The DT directive is used to reserve 10 byte of memory locations in
the available memory.
ASSUME: Assume local segment name the Assume directive is used to inform the
assembler. The name of the logical segments to be assumed for different segment used in
programs.
END: End of the program the END directive marks the end of an ALP.
PROCEDURE:
1. Entering Program:-
Start Menu
Run
Cmd
C:\cd MASM
C:\ MASM> edit filename.asm
C:\MASM\filename.asm
This is editor
Enter program here
After entering program save & exit (ALT F & Press S or ALT F &Press X)
C:\MASM>
2. Compile the Program:-
C:\MASM> MASM filename.asm
3. Linking a Program:-
4. Debug a Program:-
C> debug filename.exe
- (Screen shows only dash)
-t
‘t’ for trace the program execution by single stepping starting from the address
SEG.OFFSET. ‘q’ for Quit from Debug & return to DOS.