How to Start Coding Assembly on Windows

Tools: MASM, Visual Code, Batch

Here's a brief tutorial on how to begin coding assembly on Windows. I've found many videos and write-ups that overcomplicate the process and I expect turn people off the idea. I tried to simplify it to get people MASM programming as soon as possible. No long-winded and redundant introduction, no windows media maker title crawls, and no begging for likes, comments, or subscriptions.

Step 1: please install MASM32 here.

Step 2: save the following Hello World code as "helloworld.asm".

.386                                  ; this gets use to use 386 instruction set 
.model flat, stdcall                  ; this specifies the memory model of the program, flat is for windows
                                      ; stdcall means our parameters are pushed from left to right
option casemap :none                  ; this means our labels will be case sensitive

include \masm32\include\kernel32.inc  ; for ExitProcess
include \masm32\include\masm32.inc    ; for StdOut 
includelib \masm32\lib\kernel32.lib   ; the libraries for above 
includelib \masm32\lib\masm32.lib

.data                                 ; all initialized data must follow the .data directive
    message db "Hello World!", 0      ; define byte named 'message' to be the string 'Hello World!'
                                      ; followed by the NULL character

.code                                 ; all code must follow the .code directive
    main:								
      invoke StdOut, addr message		
      invoke ExitProcess, 0			
    end main

Step 3: navigate to the folder containing helloworld.asm and compile the it into an executable using the following commands.

set projectName=helloworld
\masm32\bin\ml /c /Zd /coff %projectName%.asm
\masm32\bin\Link /SUBSYSTEM:CONSOLE %projectName%.obj
%projectName%.exe