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

来源:互联网 发布:风量流量计软件专利 编辑:程序博客网 时间:2024/05/29 03:34

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

.386        .model flat ,stdcallNULL    equ 0MB_OK   equ 0ExitProcess PROTO :DWORDMessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORDincludelib kernel32.libincludelib user32.lib          .dataszText    db "Hello, world!",0szCaption 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:\MASMF:\MASM>ml /c /coff 3.asmMicrosoft (R) Macro Assembler Version 12.00.21005.1Copyright (C) Microsoft Corporation.  All rights reserved. Assembling: 3.asmF:\MASM>link /subsystem:windows /libpath:d:\masm32\lib 3.objMicrosoft (R) Incremental Linker Version 12.00.21005.1Copyright (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


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







原创粉丝点击