masm32 basic configuration of a first write assembler

masm32 basic configuration of a first write assembler

 

On the windows system, if you write C / C ++ and other programs, simply use visual Studio can be, but if you plan to write an assembler, often need to configure a lot of things, another novice prohibitive.

masm32 are set by individual developers can write on the Windows platform compilation tools, just a simple configuration, you can write assembler.

Note: Do not confuse with Microsoft masm macro compiler, the two are not a concept.

 

A, masm32 installation

  To the official website , then DownLoad, all the way down, is mounted to the C or D to the root directory.

 

Second, configure the environment variables (user variables)

  Each configuration include (xx.inc header files); lib (static link library); PATH (path tool).

  Note: If you do not add the environment variable, and then you write the code in assembly file, which contains the files must use absolute paths ( the include \ xxx \ xxx \ masm32.inc )

  

 

Third, a write assembly code

 1 .386
 2 .model flat, stdcall
 3 option casemap:none
 4 
 5 include kernel32.inc
 6 includelib kernel32.lib
 7 
 8 include masm32.inc
 9 includelib masm32.lib
10 
11 .data
12        msg1 db "What is your name? ", 0
13        msg2 db "Hello ",0
14 
15 .data?
16        buffer db 100 dup(?)   ; reserve 100 bytes for input storage
17 
18 .code
19 start:
20        push offset msg1        ; put in to stack the effective add of msg1
21        call StdOut                  ; call console display API
22 
23        push 100                    ; set the maximum input character
24        push offset buffer       ; put in to stack the effective add of input storage
25        call StdIn                    ; call console input API
26  
27        push offset msg2       ; put in to stack the effective add of msg2
28        call StdOut                 ; call console display API
29 
30        push offset buffer      ; put in to stack the effective add of input storage
31        call StdOut                 ; call console display API
32 
33 exit:
34        push 0
35        call ExitProcess
36 end start

 

Fourth, compile and execute

  1. Locate the a.asm file.

  2. Compilation generated a.obj document   ml / c / coff a.asm 

  3. Links generated a.exe file   Link / the Subsystem: Console A.OBJ   (Note: This is a command-line program, if the program generated window, subsystem of parameters to be modified to windows)

 

Fifth, the effect of program execution

Guess you like

Origin www.cnblogs.com/onetrainee/p/12093802.html