Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: MASM Code

  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Posts
    357
    Thanks
    46
    Thanked 22 Times in 21 Posts

    MASM Code

    Ok, I was looking at some basic MASM WIN32 tutorials. Heres something I was wondering about:

    Code:
       .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.

    Code:
       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.)

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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++.
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Mar 2007
    Posts
    357
    Thanks
    46
    Thanked 22 Times in 21 Posts
    You mean theres something wrong with trying new things? I'm not doing this for creation purposes. Just learning

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by flynch01 View Post
    You mean theres something wrong with trying new things? I'm not doing this for creation purposes. Just learning
    Ok, I was just making sure you weren't trying to do something serious in it. 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.
    OracleGuy

  • #5
    Regular Coder
    Join Date
    Mar 2007
    Posts
    357
    Thanks
    46
    Thanked 22 Times in 21 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •