How to use MASM5.0 (Illustration)

Reprinted from: http://www.cnblogs.com/lihaiyan/p/4274475.html


Write the hello.asm file in the E:\masm5.0\MYDOC directory in advance:

copy code
DATA SEGMENT
    BUF DB 'HELLO WORLD!  THIS IS MY FIRST ASM FILE! $'
DATA ENDS
SEGMENT CODE
    ASSUME CS:CODE,DS:DATA
START:   MOV AX,DATA
    MOV DS,AX
    LEA DX,BUF
    MOV AH,09
    INT 21H
    MOV AH,4CH
    INT 21H
CODE ENDS
END START
copy code

 

 

First, enter the path where masm5.0 is located (load-connect-run-debug are all performed in the directory where masm5.0 is located)

(My path to masm5.0 here is E:\masm5.0\)

Winkey+R — cmd —e:——cd masm5.0

picture

1. Loading

Format: masm   asm source file and path 1    obj file target path 2 (if omitted, the default current path)

如:E:\masm5.0>masm .\MYDOC\hello.asm .\MYDOC\


picture

Result: If the program has no errors, add the file HELLO.OBJ to E:\masm5.0\MYDOC

picture

 

2. Connection

Format: link   obj file path 1

如:E:\masm5.0>LINK .\MYDOC\HELLO.OBJ

picture

(After that, HELLO.EXE will appear in the current directory)

 

 picture

3. Run

 

Format: full name of exe file (ie "HELLO.EXE")

Such as: E:\masm5.0> HELLO.EXE

 

 picture

4. Debug

 

-u disassemble

-r display register contents

-g [=address1][address2][address3] Execute to the breakpoint line, such as: -g 12 to execute to the 12th line

-t [=address][value] Trace, use with -g For example: -t 12 1 starts from line 12, and stops after executing 1 instruction

-d view data

-q exit to return to the operating system

picture

In the picture above,

First, -u disassembles the entire hello.exe;

Then -g 9, let the program execute to the 9th line and stop; then use -t to trace, and stop each time an instruction is executed;

Finally, after 3 consecutive -t traces, enter -q to quit the program.

 

 

When the masm5.0 compiler compiles the assembly file name,
the error of Unable to open input file:bcd2ascii.asm may sometimes appear, but the code file does exist.
At this time, two questions can be considered,
first: whether the file extension has been changed, because the extension will be automatically hidden under win7 (unless it has been set);
second: it is caused by the difference in the file name system. Windows can now Support very complex naming,
        you can also see these names under cmd, but when executing debug, masm and other programs, the system will start ntvdm,
        which is a vdm under the nt system, virtual device management, is a 16-bit virtual At this time ,
        the cmd under ntvdm strictly implements the 8.3 naming. At this time, you only need to modify the file name.
        The main file name is within 8 characters, and the extension is asm.

 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325937826&siteId=291194637