MASM for Windows integrated development environment compiling Assembler

Source: Internet
Author: User

Masmfor windows integrated development environment compiling Assembler

Recently I have been studying compilation, and I used a software called "MASM for Windows integrated development environment". However, I found that there is little information about the software. For those who just learned compilation, I have found a lot of information. The following describes the tool and two basic assembly programs.

 

I. Use of software

The following are the basic methods for running the software after reading the courseware of Sichuan University:

1. Go to the MASM forwindows integrated experiment environment

2. Write a program. The Code is the first of the 11 simple entry instances provided by the software. The Code will be detailed later.

3. Save the assembler. The program must be saved before it can run.

4. Run the program

5. debug the program

6. The dosbox debug debugging method can also be used by our teacher in class.

2. Explanation of the "helloword" program

1. segment: a segment that defines pseudo commands. The Assembly contains data segments, code segments, stack segments, and additional segments.

Format: segment name segment [positioning type] [combination type] [category name]


Segment name ends

Function: segments the program to implement segment management of the memory.

The program consists of the datas Data Segment and the codes code segment.

 

2. String dB 13, 10, 'Hello world! ', 13, 10,' $'

The values 13 and 10 indicate the ASCII code of the carriage return and line feed respectively.

'$' Indicates the end sign. Otherwise, garbled characters will appear if '$' is not added.

This sentence is equivalent to C's (char *) string = "\ nhello world! \ N ";

 

3. Int 21h is the interrupt Number of the DOS interrupt function call; MoV ah, 4ch function is to let you exit the program

Where: mov ah, 4ch

Int 21 h

It is the template used when the program ends. Use ah to select the function. The 4ch function is used to exit the program. This interrupt tells the program to return DOS after execution.

 

4. mov ah, 9 indicates the command number of the print string (09h corresponds to the display string)

Note: The first assembly example in the classroom and many teaching materials: the example of "123 + 456 = sum" does not have an output statement. You must use DEBUG debugging to display the program results.

 

5. mov ax, datas

MoV ds, ax

Is to put data into Ds

 

6. Lea dx, string; string offset start DX

Lea: loademeditive address

 

The following csdn blog also provides a detailed explanation and code for this example: (reprinted)

Http://blog.csdn.net/caiyunfreedom/article/details/6557847

 

The author also commented on an example of the number summation of two MASM for Windows self-contained programs. I personally think it is helpful for you to first learn Assembly knowledge: (reprinted)

Http://blog.csdn.net/caiyunfreedom/article/details/6557924

 

3. a bug in the software

When you use the software "MASM for Windows integrated lab environment 2012", you always encounter a "runtime error '70'", which directly causes the program to exit.

For example, if you create a new program, you can press the keyboard and press enter at the first line "stsgsegment Stack's. This makes me confused. I checked some online and suggested using dosbox and masm5.0 for compilation experiments. I don't know why.

Finally, this is the first time that the author has published a blog. I hope you can learn from it. I hope you will forgive me for any bad things. I hope to write the "123 + 456 = sum" instance and detailed debug debugging, and compile the Compilation Program in dosbox.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.