You are on page 1of 22

CMLab

Graphics

A Tutorial of Writing MASM with VC++ 2005 Express


Presented by Ken-Yi Lee Assembly Language 2007

CMLab

Graphics

Assembly Language 2007

MASM
Microsoft Macro Assembler

MASM 8.0 included with Visual C++ 2005 You can download MASM 8.0 and install it with Visual C++ 2005 Express by yourself

CMLab

Graphics

Assembly Language 2007

What do you need ?


helloworld.asm helloworld.obj Editor Assembler (ml.exe) Linker (link.exe) helloworld.exe Debugger
3

Include Files
Where Which

Object File Libraries


Where Which

CMLab

Graphics

Assembly Language 2007

Visual C++ 2005 Express with MASM 8.0


Visual C++ 2005 Express

Editor, Linker, and Debugger Custom build rules


needed]

Set library paths and library dependencies [if Select console as your subsystem
MASM 8.0

Assembler

Set include paths [if needed]


4

CMLab

Graphics

Assembly Language 2007

Visual C++ 2005 Express with MASM 8.0 (contd.)


Download and Install Visual C++ 2005 Express

http://0rz.tw/253mH http://0rz.tw/8d1Xn

Download and Install MASM 8.0

You should install VC 2005 Express rst


5

CMLab

Graphics

Hello MASM !
A simple example to set up the environment

CMLab

Graphics

Assembly Language 2007

HelloMASM
- My Settings:

Project Name: HelloMASM Solution Name: HelloMASM Source code lename: hellomasm.asm Additional library dependencies: Irvine32.lib
user32.lib Used headers: Irvine32.inc Additional library Paths: C:\irvine\ Additional Include Paths: C:\irvine\

CMLab

Graphics

Assembly Language 2007

Create a new project


[ File > New > Project ], [ Visual C++ > emptyproj ]

Enter a name for your project

CMLab

Graphics

Assembly Language 2007

CMLab

Graphics

Assembly Language 2007

Custom Build Rules


Right click on the project name in the solution explorer window and select Custom Build Rules

Turn on Microsoft Macro Assembler

10

CMLab

Graphics

Assembly Language 2007

11

CMLab

Graphics

Assembly Language 2007

Select Console as subsystem


Right click on the project name in the solution explorer window and select Properties

[ Conguration Properties > Linker > System > Subsystem ]

Select Console
12

CMLab

Graphics

Assembly Language 2007

13

CMLab

Graphics

Assembly Language 2007

To work with other libraries


In the same window,

[ Conguration Properties > Linker > General > Additional Library Directories ]

Enter the paths to library les


[ Conguration Properties > Linker > Input > Additional Dependency ]

Enter library lenames


14

CMLab

Graphics

Assembly Language 2007

15

CMLab

Graphics

Assembly Language 2007

To work with other libraries (contd.)


[ Conguration Properties > Microsoft Macro Assembler > General > Include Paths ]

Enter the paths to your header les

16

CMLab

Graphics

Assembly Language 2007

17

CMLab

Graphics

Assembly Language 2007

Add a new le
Right click on Source le in the solution explorer window and select Add > New Item [ Visual C++ > Code > C++ File (.cpp) ]

Enter a lename with asm extension

Write your codes in the editor window

18

CMLab

Graphics

Assembly Language 2007

19

CMLab

Graphics

Assembly Language 2007

Build and Run


[ Build > Build solution ] or [ Build > Compile ] [ Start Debugging ] or [ Start without Debugging ] Build, Run ... and Debug

20

CMLab

Graphics

Assembly Language 2007

21

CMLab

Graphics

Assembly Language 2007

The End

22

You might also like