Anda di halaman 1dari 5

Exp 4: Introduction to Microsoft Macro Assembler

Microsoft Macro Assembler:

The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for
MS-DOS and Microsoft Windows. Beginning with MASM 8.0 there are two versions of the
assembler - one for 16-bit and 32-bit assembly sources, and another (ML64) for 64-bit sources
only.

MASM is maintained by Microsoft, but since version 6.12 has not been sold as a separate
product, it is instead supplied with various Microsoft SDKs and C compilers. Recent versions of
MASM are included with Microsoft Visual Studio.

After windows XP, Microsoft does not provide direct support for MASM. So, we are using it
externally.

Why DOSBox?

DOSBox is an emulator program that emulates an IBM PC compatible computer running a DOS
operating system. Many IBM PC compatible graphics and sound cards are also emulated. This
means that original DOS programs (including PC games) are provided with an environment in
which they can run correctly, even though the modern computers have dropped support for
that old environment.

Pre-Lab Instructions:
Unzip the zip file EX4
Inside the folder EX4 you will find three files.
Use DOSBox0.74-win32-installer.exe to install DOSBox .74.
Use npp.7.4.2.Installer.exe to install notepad++ (Optional).
Keep the 8086 folder inside C drive.

EECE 408 Microprocessor and Interfacing Laboratory


1
Exp 4: Introduction to Microsoft Macro Assembler
Writing a sample code:

Open a notepad++. Write the following example code:

CODE SEGMENT;
ASSUME CS:CODE, DS:CODE
ORG 100H
MOV AX,CS
MOV DS,AX
MOV AX,D1
MOV D2,AX
MOV AX,10
MOV BL,0FFH
MOV BH,0FFH
ADD BL,BH
HLT
INT 3H; Setting a breakpoint
ORG 150H
D1 DW 1234H
ORG 160H
D2 DW ?
CODE ENDS
END

Save the file with a name test.asm. Keep in mind that .asm extension. Using Notepad++ is
optional. You can do the same thing with Notepad but Notepad++ is easy to correct.

Executing the program:


Open DOSBox.74:

EECE 408 Microprocessor and Interfacing Laboratory


2
Exp 4: Introduction to Microsoft Macro Assembler
Type mount c c:\8086 & Press Enter (Ctrl C, Ctrl V does not work in DOSBox as you
are using a DOS environment )

Type c: & Press Enter

Type masm test.asm & Press Enter for three times until you get the following
window

EECE 408 Microprocessor and Interfacing Laboratory


3
Exp 4: Introduction to Microsoft Macro Assembler

Type link test.obj & Press Enter for three times until you get the following
window

Type debug test.exe & Press Enter

EECE 408 Microprocessor and Interfacing Laboratory


4
Exp 4: Introduction to Microsoft Macro Assembler
Few Debugging Commands:
Type: g & Press Enter (This command can be thought as the run button in emu 8086)

Type: t & Press Enter (t is for trace, this command can be used to see current contents of flags
and registers)

In the time of debugging flags have some unique symbol. They are as follows:

Type: t =100 & Press Enter

This command will invoke the registers and flags at that particular offset. Remember we have
started our code on 100H. In this command, the number is automatically considered as Hexa-
decimal number. After that if you keep typing t and pressing enter, it will work as the single step
button in emu8086.
Type: d150 & Press Enter(It will show the variables )

Type: q & Press Enter(It will get you out from debugging mode )

Reference:

Assembly Languages Programming and Organization of the IBM PCYtha Yu, Charles
Marut

Appendix E

Prepared By:
Lecturer A.S.M. Iftekhar, Syeda Puspita Mouri, Farin Rahman
Under the supervision of Wg Cdr Toyobur Rahman

EECE 408 Microprocessor and Interfacing Laboratory


5

Anda mungkin juga menyukai