CSDN博客

img taowen2002

(译)win32asm实例-1

发表于2002/3/18 19:03:00  1124人阅读

 

1.0 - New project新的工程


Create a new folder named 'mosaic' in your asm projects folder (it is adviceable to create this folder on the same drive as the MASM package so you can use the relative lib/include paths in the examples.


在你的asm工程文件夹(建议这个文件夹和masm包放在同一个区因而你可以在例子中使用相对的lib/include(库/包含文件)路径)中创建名为“mosaic”的新目录。


Download this ZIP file and extract it's contents in your 'mosaic' folder: mosaic lesson files.zip


下载这个zip文件并把它的内容解压缩到你的“mosaic”目录中:mosaic lesson files.zip



1.1 - Basic files基本文件


The ZIP contains the basic (almost empty) files for your project. Here's a short description of the files:


Zip包中有你工程的基本(几乎为空)文件。这些文件的简单描述:


Mosaic.asm


;===============================================================================
; Mosaic.asm
;===============================================================================
.486
.model flat, stdcall
option casemap: none


includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/user32.lib
includelib /masm32/lib/gdi32.lib
includelib /masm32/lib/comctl32.lib
includelib /masm32/lib/comdlg32.lib
include /masm32/include/kernel32.inc
include /masm32/include/comctl32.inc
include /masm32/include/comdlg32.inc
include /masm32/include/user32.inc
include /masm32/include/gdi32.inc
include /masm32/include/windows.inc
include mosaic.inc


.code
start:


end start


This file contains the framework for a win32 asm source file.


这个文件包含了win32asm源文件的框架。


.486: indicates to use the 486+ assembly instructions
.model flat, stdcall: defines the memory model (flat) and the calling convention (stdcall)
includelib / include: These include the libraries and include files for the windows functions needed. The windows.inc includes basic windows constants. The mosaic.inc contains your own constants.
.code: select code segment
start: just a label, could be anything
end start: indicates that the entry point of your program is at a label called start.


.486: 说明用486及以上的汇编指令。
.model flat, stdcall:定义内存模式(flat)和调用习惯(stdcall
includelib / include: 这些包含Windows函数所需要的库和包含文件。Windows.inc中有基本的windows常量。Mosaic.inc包含你自有的常量。
.code: 选择代码段
start: 只是一个标签,可以为任何东西
end start:表明你的程序的入口点是位于一个名为start的标签.


Mosaic.inc


;---- msgbox macro: usage MSGBOX "string to display" -------
MSGBOX MACRO msg:REQ
LOCAL @msg
.data
@msg db msg, 0
.code
invoke MessageBox, NULL, ADDR @msg, ADDR AppName, MB_OK
ENDM


In mosaic.inc there is a little macro to simplify the use of MessageBoxes. A macro is a piece of code that can contain variables (here msg for example), which you can then use in your code and will be replaced by the macro code when assembling. I don't go into details about macro's right now, just remember you can show a msgbox in your program by using:


mosaic.inc中有一个小的宏来简化MessageBox的使用。一个宏是一小块可以包含变量(例如这里的msg)的代码。你可以在你的代码中使用它,而且在汇编时将会被宏中的代码所取代。我不会立刻深入宏的细节。只要记住你可以在你的程序中使用一下代码来显示一个消息对话框:


msgbox "Your string to display"


make.bat


@echo off
ml /c /coff mosaic.asm
rc -r mosaic.rc
link /subsystem:windows mosaic.obj mosaic.res
pause>nul


Use this batch file to assemble and link your program. The rc command will compile your resources.


使用这个批处理文件来汇编并链接你的程序。Rc命令编译你的资源


resources/


This folder contains some bitmaps and icons we will use in our program:


这个文件夹包含一些我们将要在我们程序中使用的图片和图标:


















Big icon
(big.ico)


Small icon
(small.ico)


Toolbar buttons
(Toolbar.bmp)


Demo game picture
(demo.bmp)

0 0

相关博文

我的热门文章

img
取 消
img