0.masm32-搭建环境和MessageBoxA弹框

环境在:http://www.masm32.com/download.htm下载,直接安装就OK了,百度这里有篇不错的安装解释:https://jingyan.baidu.com/article/72ee561abec330e16138df93.html

.386
        .model flat ,stdcall

NULL    equ 0
MB_OK   equ 0

ExitProcess PROTO :DWORD
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD

includelib kernel32.lib
includelib user32.lib

          .data
szText    db "Hello, world!",0
szCaption db "Win32Asm",0

        .code 
start: 
        push MB_OK
        lea eax,szCaption
        push eax
        lea eax,szText
        push eax
        push NULL
        call messageboxa
        xor eax,eax
        push eax
        call exitprocess
        end start
编译:

C:\Users\hgy>pushd F:\MASM

F:\MASM>ml /c /coff 3.asm
Microsoft (R) Macro Assembler Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: 3.asm

F:\MASM>link /subsystem:windows /libpath:d:\masm32\lib 3.obj
Microsoft (R) Incremental Linker Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

第一步生成3.obj,第二步生成3.exe


上面的寄存器不需要堆栈保护, 根据Intel ABI,EAX、EDX及ECX可以自由在过程或函数中使用,不需要保留。参看:https://zh.wikipedia.org/wiki/X86%E8%B0%83%E7%94%A8%E7%BA%A6%E5%AE%9A


设置下编译环境,可以使编译更简单:

0.masm32-搭建环境和MessageBoxA弹框_第1张图片






你可能感兴趣的:(MASM32)