I am trying to figure asm, out slowly, I like it's form much better that any of the high level languages, and I'm sure after extensive learning curve, I'll appreciate it's power aswell....

MY question is like this.....

include %include%/win32ax.inc

.code

start:
invoke MessageBox, HWND_DESKTOP,'MYTEXT','MYTITLE',MB_YESNO
cmp eax, 0
jne newbox
invoke ExitProcess, 0

newbox:
invoke MessageBox, HWND_DESKTOP,'one','another',MB_OK
ret

end start.

I believe that if I click on the no button, the windows stores 0 in eax,
if I compare eax to 0 and jump if it's not equal to zero to newbox, then when I click no, the messagebox should just close, if I click yes, the prog should jump to newbox, display the newbox, until I click, ok and then the program should return to start: label, and continure exicution at last line, therefor invokeing exit process and closing.....

what am I not understanding correctly here, because Regarless of click yes or no, it still open new box....

thanks for you help.....


:stupid:
Posted on 2003-03-02 00:56:53 by va3gdr
hi,
first of all eax only returns 0 when there is not enough memory to create the message box. it returns 6 when yes is pressed and 7 when no is pressed.
also i dont think you can just enter the text and caption like you've done


invoke MessageBox, HWND_DESKTOP,'MYTEXT','MYTITLE',MB_YESNO

rather do it like ive done here


format PE GUI 4.0

include '%include%/win32a.inc'

section '.data' data readable
_MYTEXT db 'MYTEXT',0
_MYTITLE db 'MYTITLE',0
_one db 'one',0
_another db 'another',0

section '.code' code readable executable
entry start
start:

invoke MessageBox, HWND_DESKTOP,_MYTEXT,_MYTITLE,MB_YESNO
cmp eax, IDYES
je newbox

Exit:
invoke ExitProcess, 0

proc newbox
enter
invoke MessageBox, HWND_DESKTOP,_one,_another,MB_OK
return

section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'

import kernel,\
ExitProcess,'ExitProcess'

import user,\
MessageBox,'MessageBoxA'

ok so wat happens here is that the user presses yes and we then compare the returned value with 6....if it is 6 then it goes to our small procedure which shows another messagebox...if it isnt 6 then it exits
that should answer your question....any other questions just ask
Posted on 2003-03-02 02:21:11 by keyoke
Excellent

actually, I have entered both programs and they both work wonderfully. All I had to do was change


cmp eax, IDNO and everything went great....

Now, my magical friend, could you tell me how to find out all of these great return codes, ie...

IDYES IDNO, and also the 6 and 7 that they return....

If I change my program to... example

invoke Messagebox,HWND_DESKTOP,"whatever","whatever",3

my message box will have yes, no, cancel,,,,, how do I know cancel will return 8?

you just made this very exciting for me.... My little program actually did what I wanted......

who says assembler is hard..... 3 hours, only and I have a working program.....

microsoft is in trouble.....

my program not only compiles.... it also didn't crash..... take a tip bill gates.... he he he
Posted on 2003-03-02 02:34:43 by va3gdr
in the file you included ...

win32a.inc ... open it with a text editor and look for yourself
Posted on 2003-03-02 03:16:02 by code1101
:))))

Sorry ... I didn't check fasm before ...

check the file user32.inc ... you should find the values there ...

better not talk about things I don't know next time ...:P
Posted on 2003-03-02 03:37:59 by code1101
Excellent....

It took some looking but I did find the ID codes, and return values..... Not exactly in the form of a help file but they are there......... Things are looking up........ I love assembly......

Maybe I'm strange but this all seems much more understanable than c++ or pascal..... even basic with all that goto, and crap......

if a value is true, do this, if not do that.... makes sense to me.....

it's so much clearer to read without all that superfluous crud in there......

You guys are great for answering my baby question....

I wonder if you'll still be so willing to answer when I get to the real mnemonics......

mmx 3dnow, all that wonderful stuff....

thanks again.....
Posted on 2003-03-02 03:49:25 by va3gdr
I recommend looking into Win32 API docs instead of searching include files for possible flags. You can also use the online MSDN library, for example here's the reference for MessageBox function:
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messagebox.asp?frame=true
Posted on 2003-03-02 04:07:33 by Tomasz Grysztar
Thank you very much....

I have just looked at that address you left, and I see where it gives the return codes, is that also included in the win32api.chm file...... I'll have to take a lot harder look at that big beast of a file. This should make things much easier......:grin:

:confused: Is it possible to add that on the help menu, or will it be in the near futute... Items such as win32help and mmediahelp etc....

Thank you again for you help.....

This will make it much easier to deal with the api...
Posted on 2003-03-02 16:07:34 by va3gdr
You need the .hlp version of that file to get it work correctly with FASMW. I was trying to add .chm support there, but it had been causing problems. But I'll look again at it, maybe at second try I'll succeed.
Posted on 2003-03-02 16:23:03 by Tomasz Grysztar
Cool,,,
:)

I seem to have the help file working but it will only let me put one on help menu....

would be great if I could add whole list of helpfiles to menu... ie..

win32
mmedia
opengl
opcode
directx

but the api is good for now.....

thanx again...

PS. if your the programmer who created this wonderful little assembler... PLEASE don't go adding a bunch of crap to it.... I've seen some seggestions on adding win32asm routines and the such.... The lack of all that stylised junk is the reason I like fasm so much.... I've tried masm and tasm and spasm, and they all have to much confusing stuff in it....

fasm works great, fast and cleanly..... I like that very much....

thanks again...
:grin: :grin: :grin:
Posted on 2003-03-02 17:39:29 by va3gdr
:)
Posted on 2003-03-02 18:23:36 by va3gdr
With the same program now, could I do it without invoke, ie

push eax, MB_OK
push eax, mytext
push eax, mytitle
push eax, 0

call USER32.MessageBoxA
call KERNEL32.EndProcess

??
Posted on 2003-03-04 05:03:31 by va3gdr
It should be:


push MB_OK
push mytext
push mytitle
push 0
call [MessageBox]
Posted on 2003-03-04 05:25:39 by Tomasz Grysztar
format PE GUI 4.0

include '%include%/win32a.inc'


section '.data' data readable
_mytext db 'hello cruel world', 0
_mytitle db 'hello cruel world',0


section '.code' code readable executable
entry start

start:
push MB_OK
push _mytext
push _mytitle
push 0
call
call

this doesn't seem to work, what have I done wrong?
Posted on 2003-03-04 09:10:25 by va3gdr
I've started reading Art of Assembly
and a lot of other materials, and I'm trying to get the grass roots with push and pop etc..... before I start using all of the invoke and macros etc. I was wonder if there is some documentation I've overlooked that explains these macros etc.... I couldn't seem to find any documentation on source forge.....

thanks...
Posted on 2003-03-04 09:14:11 by va3gdr
invoke as used in masm is nothing more than a push of all your parameters (and an argument count check ;) )

so instead of writing


push 0
push 1
push 2
call routine

you can write


invoke routine, 2,1,0


it tends to read easier but that's just a matter of personal preference.
Posted on 2003-03-04 10:26:30 by Hiroshimator
One of the biggest problems I'm having is understanding these include files....

What do they do exactly..... do they give me access to the entire windows api......

is it possible to write my own, if the need evey arises,

what information is in them....

I've looked at some of them, but they really don't make a lot of sense.....

If you could answer this for me it would help alot....

oh yeah,,,, how do I know which one I have to include...

win32a
win32ax etc etc...

thanks
Posted on 2003-03-04 17:48:43 by va3gdr
the include directive usually just includes the whole file in the source. Like if you'd copy paste it on that location.

They're just textfiles containing data and directives. you can create them yourself. The reason they exist is so that you can separate info a bit and your program doesn't get a big unoverseeable mess of info all in one file.

As for to know which one to include: most have the same name as the corresponding header file (c language) they were translated from. So if a dll needs a certain header file were it has been defined its properties in then you can be 99% sure that you need the correspondingly named include file for asm.

whenever you lookup an API in MSDN at the end it will tell you which header file it needs (just substitue .h for .inc and it should almost always work ;) )

it'll get clearer with time so don't worry too much about it.

the important use for you is that you can use an include directive to divide your program in smaller logical parts, which makes maintaining and developing your application easier.
Posted on 2003-03-04 17:58:46 by Hiroshimator
Sometimes it gets difficult trying to figure which .h or .inc file to include or look for. Most programs will use windows.inc but you won't need d3d.inc if you don't use DirectX.

Include files help by keeping definitions in one place so you don't have to retype things all the time, ie,

color EQU 3

If this was needed in five different files then it might be better to put this and other related items in one file and call it "colors.inc"

A lot of things in the .h/.inc file you may never use. So don't freak out by it or try and learn them all. It'll just bog you down. Just learn the ones you are using at the moment.
Posted on 2003-03-04 19:26:46 by drhowarddrfine

invoke as used in masm is nothing more than a push of all your parameters (and an argument count check ;) )


and, for all intents and purposes, a type check :grin:
Posted on 2003-03-04 22:13:38 by jademtech