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.