What is the difference between MASM32 (The SDK that provides includes and macros for writing Windows assembly programs) versus the Microsoft Macro Assembler http://msdn.microsoft.com/en-us/library/afzk3475(v=VS.90).aspx. I am using ML64.exe to compile my assembly programs. Confusingly for me, the MSDN documentation for the supported assembly directives also uses the acronym MASM (http://msdn.microsoft.com/en-us/library/8t163bt0(v=VS.90).aspx).
I would appreciate any clarification you can offer.
Ranjit
Masm is Microsoft's tool that allows you to assemble code. Version 6.14 is part of the private Masm32 package (you will find it as \masm32\bin\ml.exe) maintained by Hutch with support from the members of this forum.
Without the Masm32 libraries, programming in assembler would be possible but very difficult.
Thanks for the response. If I understand correctly, the private Masm32 SDK bundles the version 6.14 of Microsoft's assembler, which is ML.exe. Downloading and installing Masm32 provides all the macros, .inc files and various high level language constructs that simplify programming in Microsoft assembly.
Is there a 64-bit version of the Masm package?
I am currently using Microsoft's vanilla ML64.exe but unable to compile code that uses .IF constructs, which happens to be documented on MSDN as supported in the vanilla Microsoft assembler. http://msdn.microsoft.com/en-us/library/8t163bt0(v=VS.90).aspx.
This has caused me some confusion.
Ranjit
ranjitiyer,
ML64 does not support most of the high-level directives that 32-bit ML does.
Here is an example "Hello World" console program for ML64.
EXTRN lstrlen:PROC
EXTRN GetStdHandle:PROC
EXTRN WriteFile:PROC
EXTRN printf:PROC
EXTRN _getch:PROC
EXTRN ExitProcess:PROC
INCLUDELIB kernel32.lib
INCLUDELIB user32.lib
INCLUDELIB msvcrt.lib
.DATA
szMsg BYTE "Hello x64 World!", 13, 10, 0
.CODE
;------------------------------------------------------
main PROC
sub rsp, 40
lea rcx, szMsg
call StdOut
call WaitKey
xor ecx, ecx ; exit code = 0
call ExitProcess
main ENDP
;------------------------------------------------------
StdOut PROC
; int StdOut(char* pText);
LOCAL pText:QWORD
LOCAL hFile:QWORD
LOCAL dwLen:DWORD
LOCAL dwBytesWritten:DWORD
sub rsp, 40
mov pText, rcx
call lstrlen
mov dwLen, eax
mov ecx, -11 ; STD_OUTPUT
call GetStdHandle
mov hFile, rax
mov rcx, hFile
mov rdx, pText
mov r8d, dwLen
lea r9, dwBytesWritten
call WriteFile
mov eax, dwBytesWritten
add rsp, 40
ret
StdOut ENDP
;------------------------------------------------------
WaitKey PROC
; int WaitKey(void);
LOCAL dwCrLf:DWORD
LOCAL dwChar:DWORD
.DATA
szPrompt BYTE 13,10,"Press any key to exit ... ", 0
.CODE
sub rsp, 40
mov dwCrLf, 00000A0Dh
lea rcx, szPrompt
call printf
call _getch
cmp eax, 0
je again
cmp eax, 0E0h
je again
jmp @F
again:
call _getch
@@:
mov dwChar, eax
lea rcx, dwCrLf
call printf
mov eax, dwChar
add rsp, 40
ret
WaitKey ENDP
;------------------------------------------------------
END
Both ml.exe and ml64.exe are referred to as MASM.
There is no 64-bit version of the MASM32 package.
Thanks for the clarification.
Hi ranjitiyer,
Don't forget also to check Jwasm, the Masm compatible assembler :
http://japheth.de/JWasm.html