|
... Masm Tutorial #1 ... |
Pulse Reversing Force |
First of all I would like to say that my english isn't for A+, so.. if you don't understand something.. sorry :] This tutorial is the first from the MASM series of Pulse Team, so don't expect very much :). I'll show you the basic directives and how to create simple MessageBox. I'll comment the code below to be all clear. I use MASM 8, which you can find easily on the net. After you install MASM, please open asmbas.asm (which is in this zip) with Qedit.exe. You must notice that the comment in every assembler (incl. MASM) is marked with ";". Now lets start with the code below. If you have problems with the assembler instructions, please see this tutorial. In white is the code and in gray is the comment: --------------------------------------------------------------------------------------------------------- ; These 3 rows must be every time in your code: .386 ; Shows that masm must use up to 80386 instructions. ; The possibilities are: .386 .486 .586 .386p .486p .586p .model flat, stdcall ; .model shows what memory model is used. ; For win32 applications You must use the flat memory model. ; StdCall is the type of call. option casemap :none ; option casemap :none means that the compiler will ; make difference between small and upper case include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc ; include imports code from a file ; in the place where is the directive includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib ; includelib imports code from library on the disk ; in the place where is the directive ; In MASM the code is spitted in a few sections - .data, .data?, .code è .const .data? ; Here is the place for the uninitialized variables (without starting value) .const ; Here is the place for the constants .data ; Here is the place for the initialized variables (with starting value) ; There are few types of varables in every asm (the brackets means optional paramenters): ; name db number[,number] - Define Byte - Defines Byte - number from 0 to 255 (char) ; name dw number[,number] - Define Word - Defines Word - 2 bytes (short int) ; name dd number[,number] - Define Dword - Defines Double Word 4 bytes (int) ; name dq number[,number] - Define Qword - Defines Quad Word - 8 bytes (long int) ; Here are some null terminated strings/char arrays (the zero shows where the string ends) message db "Is 2+2=4?",0 message1 db "Well done ;]",0 message2 db "You need more lessons man ;]",0 caption db "MasmTut #1",0 .code ; Here is the place for the program code, but it must always be in a label (like this below) start: ; The calling of API functions with StdCall becomes when the parameters of the functions ; are push-ed in reverse order and the function is call-ed. ; But for facilitation of the user there is the command invoke. ; Syntax: invoke function[,argument] ; The pointers in MASM are marked with 'offset' invoke MessageBox,0,offset message,offset caption,MB_ICONQUESTION + MB_YESNO ; Two or more parameters are connected with plus (+). ; The result from every API function is returned in the register EAX cmp eax, IDYES ; Compares the result from MessageBoxA (returned in eax) with the constant IDYES, which ; means that the user has clicked Yes je good ; If it's Yes, jumps to the label 'good', if not - continues invoke MessageBox,0,offset message2,offset caption,MB_OK invoke ExitProcess,0 ; The user hasn't clicked Yes. ; The program shows that he is intellectual undeveloped and exits ;) good: invoke MessageBox,0,offset message1,offset caption,MB_OK invoke ExitProcess,0 ; The user has clicked Yes. ; The program shows that Einstein is a dummy kid in comparison with the user ;) end start ; The end of the program label-a and the app :) --------------------------------------------------------------------------------------------------------- I forgot to tell you that all assembler files are with extension *.asm and the include files are *.inc. Now you must click on Project->Build All from the menu of Qedit.exe. The next tutorial will be for keygen, so if you are interested visit our site :). --------------------------------------------------------------------------------------------------------- greetz goin to : ..shade......... ..dim_cr........ ..pumqara....... ..nre........... ..sometimes..... ..buko.......... ..jeux.......... ---------------------------------------------------------------------------------------------------2k3--- Date : 14.1î.2îî3 Author : plux ~ PuLSe E-mail : p.l.u.x@mail.bg Site : www.pulse-team.tk
| |