Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 12th, 2005, 8:51 AM   #11
omega_red
Newbie
 
omega_red's Avatar
 
Join Date: Jun 2005
Location: Poland
Posts: 5
Rep Power: 0 omega_red is on a distinguished road
Send a message via Yahoo to omega_red
It doesn't work, because you have changed string declarations. Don't declare them as no-size arrays - if you do, compiler treats their names different (push causes actual string content to be pushed, not its address). Declare them as before:
char *str = "something";
__________________
Vulnerant omnes, ultima necat.
omega_red is offline   Reply With Quote
Old Jul 12th, 2005, 9:05 AM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
If he declares them that way, they'll not be modifiable if he tries to change them as he did before. Recall that I mentioned the calling conventions. I checked your procedure and it is of the type that cleans the stack. Consequently you don't need the pops. You have to check these things. As I mentioned earlier, your ability to post sucks. You're asking for free help but you aren't helping your helpers. The post, "Hmmm, this doesn't work," is not a decent question; it's an implicit question. I could give you an implicit answer like, "Well, your code's effed up." You should go sit behind the barn and think about that and the price you're paying for the help you receive. This works for me:
#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    char msg []= "128";
    char msg2 []= "Equal";
    char msg3 []= "NotEqual";
    MessageBox(0,msg3,msg,0);
    __asm{

        push 0;
        lea ecx, msg;
        push ecx;
        lea ecx, msg3;
        push ecx;
        push 0;

        call dword ptr [MessageBoxA];

    }
    MessageBox(0,NULL,NULL,0);
    return 0;
}
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 13th, 2005, 12:14 AM   #13
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
Thanks to both...btw dawei...why would u need to go "lea" as you would have to dereference msg using "[]" before using anyway? isnot that a bit u know?
__________________
Spread your wings and fly! Chicken!
rsnd is offline   Reply With Quote
Old Jul 13th, 2005, 7:01 AM   #14
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
LEA means "the address of MSG". That's what I want to pass to the function, not the first four bytes OF the message. It's the job of the function to perform the dereferencing. Don't mix up C and ASM in your head, they aren't the same.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC