程式語言 - MASM32 - Hello, world!



參考資訊:
https://www.masm32.com/

經典的Hello, world!程式框架總是能夠讓人細心品味一款程式語言的美好,司徒就使用一個簡單的Message對話盒來展現Hello, world!框架

main.asm

    .386
    .model flat,stdcall
    option casemap:none
  
include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
  
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
  
    .data
szCaption BYTE " ", 0
szContent BYTE "Hello, world!", 0
  
    .code
start:
    invoke MessageBox, NULL, offset szContent, offset szCaption, MB_OK
    invoke ExitProcess, 0
end start

Makefile

TARGET=main

all:
	myx86 "c:\masm32\bin\ml.exe" /c /coff /nologo ${TARGET}.asm
	myx86 "c:\masm32\bin\link.exe" /SUBSYSTEM:WINDOWS /MERGE:.rdata=.text ${TARGET}.obj

run:
	myx86 ${TARGET}.exe

clean:
	rm -rf ${TARGET}.exe ${TARGET}.obj

編譯、執行

$ make
$ make run