...

View Full Version : MASM Code



flynch01
08-28-2008, 09:42 PM
Ok, I was looking at some basic MASM WIN32 tutorials. Heres something I was wondering about:



.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF


I wanted to try something less... you know, that. So I tried this, which still compiled but the window didn't show so I'm guessing the message loop died.



cmp uMsg,WM_DESTROY
je msg_destroy
jmp msg_default
msg_destroy:
invoke PostQuitMessage,NULL
jmp SkipLoop
msg_default:
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
SkipLoop:
<more code>


Is there a reason this is wrong? I'm assuming it's the cmp instruction. (Sorry if I'm stupid, I get the feeling I'm out of my depth here.)

oracleguy
08-28-2008, 09:53 PM
Why oh why are you trying to write a Win32 GUI in assembly? You'd be much better off doing it in C or C++.

flynch01
08-28-2008, 11:16 PM
You mean theres something wrong with trying new things? I'm not doing this for creation purposes. Just learning :D

oracleguy
08-29-2008, 05:17 AM
You mean theres something wrong with trying new things? I'm not doing this for creation purposes. Just learning :D

Ok, I was just making sure you weren't trying to do something serious in it. :D The Win32 API is convoluted enough as it is, doing it asm would be torture for a big application, lol.

That code you posted in the second block should work. If the window doesn't come up at all, there is probably an issue some where else in your app.

flynch01
08-29-2008, 08:46 AM
I'm not on my pc atm eitherwise I'd post the whole code.

With the first code in the program runs absolutely fine, window shows up with the correct windows styles etc. It's only when I replace the message loop with that. I have to run off to work now, I will try again when I get home. If nothing happens I'll post the lot.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum