Hello world in assembly language

Source: Internet
Author: User
The Hello world of assembly language is not as low as I think. It already has many features of advanced languages, Code It also becomes clear, with a clear hierarchy and easy to maintain.

A. ASM . 386  
. Model flat, stdcall
Includelib kernel32.lib
Includelib user32.lib

Messageboxa proto: DWORD,: DWORD
MessageBox equ < Messageboxa >
Exitprocess proto: DWORD

. Data
Msgboxcaption DB "Welcome " , 0  
Msgboxtext DB " Hello world! " , 0  

. Code
Start:
InvokeMessageBox, 0 , ADDR msgboxtext, ADDR msgboxcaption, 0  
InvokeExitprocess, 0
End start

Ml a. ASM/subsystem: Windows
Run the command after a.exe is generated.

It is time to change the impression that assembly language is a low-level language. The current macro assembly is no longer far from the advanced language. The following factorialProgram:Factorial proc num: DWORD
MoV eax,1
.WhileNum> 1
Imul eax, num
Dec num
. Endw
Factorial endp

Write in C language:

DWORD factorial (Num DWORD)
{
DWORD Val =   1 ;
While (Num > 1 )
{
Val* =Num;
Num--;
}
Return Val;
}

However, the C ++ 2005 built-in MASM does not have * .inc files, and of h2inc.exe is not provided. It is said that M $ may release the masm8.0 development kit, but there is no message so far. Very depressing !!!

After a search, we finally found the third-party supported MASM development kit. Http://www.masm32.rantx.com/files/m32v9r.zip
Supported websites: http://www.movsd.com/
Http://spiff.tripnet.se /~ Iczelion/

The latest version uses the MASM version 6.14. The attached INC and Lib files are comprehensive.
The reason why you do not need to update the version of MASM is to avoid the license issue. For compatibility comparison between version 6.14 and later, refer:
Http://www.masm32.com/mlcompat.htm

The more comprehensive Chinese tutorial (yycnet.yeah.net translation) address is as follows:
Http://211.147.7.6: 9999/flyfish/source/win32asm. CHM

If you are interested in masm8.0 and want to know its improvements, refer to the reference for masm in the msdn library.

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.