0%

WIN32汇编 Hello World

编译命令:

1
ml /c /coff /Cp test.asm

链接命令:

1
link /subsystem:windows test.obj test.res

或者手动编译Makefile 用 nmake 命令直接编译链接

1
2
3
4
5
6
7
8
9
10
11
12
13
NAME = test
OBJS = $(NAME).obj
RES = $(NAME).res

LINK_FLAG = /subsystem:windows
ML_FLAG = /c /coff

$(NAME).exe: $(OBJS)
Link $(LINK_FLAG) $(OBJS) $(RES)
.asm.obj:
ml $(ML_FLAG) $<
clean:
del *.obj

代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.386
.model flat,stdcall
option casemap:none

include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib

.data
szCaption db '你士大夫士大夫 !',0
szText db '距离喀什地方',0

.code
start:
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
invoke ExitProcess,NULL
end start

求大佬赏个饭