Win32 ASM
Hello guys. I have got a very simple question about assembly.
I''m using MASM32 and I want to make a DLL.
I need to know how to pass a valus to the function ...
Can anybody please write a very simple example of a function called MsgBox, which will when called like:
INVOKE MsgBox, "Hello there", "This is a title", 0
display a corresponding message?
PS. As you can see am at the very beginning(with big B) of the ASM programming.
Thanks a lot.
-Milos
Hi.
I believe you have a long way to go pal, but here is what you asking for:
Topgoro
;You are not a real programmer until you start all your sentences with a semicolon
Edited by - Topgoro on September 9, 2000 10:08:53 PM
I believe you have a long way to go pal, but here is what you asking for:
MsgBox proc near stdcall, Message:dword, Title:dword pusha invoke MessageBox,NULL,Message,Title,NULLExit: popa ret
Topgoro
;You are not a real programmer until you start all your sentences with a semicolon
Edited by - Topgoro on September 9, 2000 10:08:53 PM
We emphasize "gotoless" programming in this company, so constructs like "goto hell" are strictly forbidden.
September 10, 2000 03:21 AM
Thank you. Yes, I know there is a long way to go...
Could you explain me what >> MsgBox proc near stdcall
means, please? (I''m thinking on the second part, "near stdcall") I don''t have experience with ASM or VC++, I know just B out of basics in both of them.
Thank you again.
Regerds
Could you explain me what >> MsgBox proc near stdcall
means, please? (I''m thinking on the second part, "near stdcall") I don''t have experience with ASM or VC++, I know just B out of basics in both of them.
Thank you again.
Regerds
I''m havig a problem here...I can''t make this work.
I''m trying to make the DLL for use with VB.
I have added the PROC. "declaration" as you showed me, but it''s not working...again...
I need help...please.
Regards, Milos.
-Milos
I''m trying to make the DLL for use with VB.
I have added the PROC. "declaration" as you showed me, but it''s not working...again...
I need help...please.
Regards, Milos.
-Milos
-Milos
Hi
really u are a beginner if u CANT make it work
i think u must go to Iczelions main win32asm page:
http://members.xoom.com/_XMCM/winasm/index.html
or searc after Iczelion / win32asm on inet
And LEARN the BASICS there... they have a lots of examples even DirectDraw ones...and i learned a lot from there...
Now i make a comercial RTS in fulll ASM no VC++ so u see i can be done. Just u have to really want it.
Bogdan
Edited by - bogdanontanu on September 10, 2000 7:25:28 PM
really u are a beginner if u CANT make it work
i think u must go to Iczelions main win32asm page:
http://members.xoom.com/_XMCM/winasm/index.html
or searc after Iczelion / win32asm on inet
And LEARN the BASICS there... they have a lots of examples even DirectDraw ones...and i learned a lot from there...
Now i make a comercial RTS in fulll ASM no VC++ so u see i can be done. Just u have to really want it.
Bogdan
Edited by - bogdanontanu on September 10, 2000 7:25:28 PM
obysoft
quote:
proc near
This function i.e. procedure is in the same code segment that the main is in. I think in flat memory mode the near is same as far since you have 4mb to 2gb (on windows) address space for your code and data to reside in. Far would be if you had your code in code segment one which is calling a procedure in code segment two, each segment 64Kb long i.e. DOS 16-bit addressing mode. I don''t know about dll''s but I think the virtual manager maps them into process address space i.e. 4mb to 2gb. There is actually only one Dll loaded but multiple programs/processes can hook into it. I might be wrong so search for more info.
quote:
stdcall
A way to tell the compiler in what order (left to right or right to left) to push the arguments on to the stack frame.
my homepage
E-Mail: BlueOrbSoftware@mailcity.com
Hi.
First I want to clarify that in my original I forgot to end the function with "MsgBox endp".
Ok, you really need to go to Iczelion's page, there is a lot of material there.
But to answer you:
the "near" tells the assembler to generate a near return for the "ret" instructions in the function. A near "ret" or "retn" instruction means that in 16 or 32 bit modes the processor will pop a 16 or 32 bit address, respectively, from the stack and then jump to it.
The counterpart would be "far", which tells the assembler to generate a far return for the "ret" instructions in the function. A far "ret" or "retf" instruction means that in 16 bit mode the processor will pop from the stack a 16 bit offset *AND* a 16 bit segment to then do a far jump to that address. In 32 bit mode the processor pops a 32 bit offset from the stack *AND* a 16 bit selector to then do a far jump to that address.
Another form of return would be "iret" and "iretd". Those instruction are used to return from software (int) or hardware (IRQ) interrupt service functions. "iret" pops a 16 bit offset, 16 bit segment, and 16 bit flags from the stack and then jumps to that far address. "iretd" is exactly the same, but it pops a 32 bit offset, 16 bit selector, and 32 bit flags.
The stdcall tells the asembler how to frame the stack on entry and then clean it up on exit. For the stdcall or "standard call" parameter passing convention the caller needs to push onto the stack all parameters in reverse order, the callee needs to pop those values from the stack before returning, the function name is decorated by preffixing it with an undescore "_", the return value if any (in the x86 processors) is returned in the eax register (ax in 16 bit mode), and finally the following registers (again, in the x86 procesors) must be preserved:
ebx,ebp,esi,edi (bx, bp, si, di in 16 bit mode)
Topgoro
;You are not a real programmer until you start all your sentences with a semicolon
Edited by - Topgoro on September 10, 2000 10:33:30 PM
MsgBox proc near stdcall, Message:dword, Title:dword pusha invoke MessageBox,NULL,Message,Title,NULLExit: popa retMsgBox endp
First I want to clarify that in my original I forgot to end the function with "MsgBox endp".
Ok, you really need to go to Iczelion's page, there is a lot of material there.
But to answer you:
the "near" tells the assembler to generate a near return for the "ret" instructions in the function. A near "ret" or "retn" instruction means that in 16 or 32 bit modes the processor will pop a 16 or 32 bit address, respectively, from the stack and then jump to it.
The counterpart would be "far", which tells the assembler to generate a far return for the "ret" instructions in the function. A far "ret" or "retf" instruction means that in 16 bit mode the processor will pop from the stack a 16 bit offset *AND* a 16 bit segment to then do a far jump to that address. In 32 bit mode the processor pops a 32 bit offset from the stack *AND* a 16 bit selector to then do a far jump to that address.
Another form of return would be "iret" and "iretd". Those instruction are used to return from software (int) or hardware (IRQ) interrupt service functions. "iret" pops a 16 bit offset, 16 bit segment, and 16 bit flags from the stack and then jumps to that far address. "iretd" is exactly the same, but it pops a 32 bit offset, 16 bit selector, and 32 bit flags.
The stdcall tells the asembler how to frame the stack on entry and then clean it up on exit. For the stdcall or "standard call" parameter passing convention the caller needs to push onto the stack all parameters in reverse order, the callee needs to pop those values from the stack before returning, the function name is decorated by preffixing it with an undescore "_", the return value if any (in the x86 processors) is returned in the eax register (ax in 16 bit mode), and finally the following registers (again, in the x86 procesors) must be preserved:
ebx,ebp,esi,edi (bx, bp, si, di in 16 bit mode)
Topgoro
;You are not a real programmer until you start all your sentences with a semicolon
Edited by - Topgoro on September 10, 2000 10:33:30 PM
We emphasize "gotoless" programming in this company, so constructs like "goto hell" are strictly forbidden.
Thank you all on your posts.
Topgoro, I know you forgot the ENDP thingy, it was not the problem... I know how to make ''n'' use procedures, I making a simple program in ASM and it''s going nice. The first problem I have encountered is this one. I don''t know what I''m doing wrong but I simply can''t make this work. Procedures I make can exept only numbers or variables (or registers)... but I can''t make them to exept string expressions.
Anyway, I will check those tutorials you guys mentioned, I may find what I need.
Thanks.
-Milos
Topgoro, I know you forgot the ENDP thingy, it was not the problem... I know how to make ''n'' use procedures, I making a simple program in ASM and it''s going nice. The first problem I have encountered is this one. I don''t know what I''m doing wrong but I simply can''t make this work. Procedures I make can exept only numbers or variables (or registers)... but I can''t make them to exept string expressions.
Anyway, I will check those tutorials you guys mentioned, I may find what I need.
Thanks.
-Milos
-Milos
quote: Original post by Milos
Thank you all on your posts.
Topgoro, I know you forgot the ENDP thingy, it was not the problem... I know how to make ''n'' use procedures, I making a simple program in ASM and it''s going nice. The first problem I have encountered is this one. I don''t know what I''m doing wrong but I simply can''t make this work. Procedures I make can exept only numbers or variables (or registers)... but I can''t make them to exept string expressions.
Anyway, I will check those tutorials you guys mentioned, I may find what I need.
Thanks.
-Milos
Hi.
You can pass strings to your ASM function in much the same way you can pass them to any Windows API or any other fucntion. I think may be you are prototyping your function incorrectly. Are you declaring the string parameter as a "char *TheString" (Or as "char &TheString")?
Topgoro
;You are not a real programmer until you start all your sentences with a semicolon
We emphasize "gotoless" programming in this company, so constructs like "goto hell" are strictly forbidden.
Hello.
Hmm, this is the first time I''ve heard there is a string data type in ASM. I thought it is an array of BYTEs... I have tried to pass a string to a :BYTE and :DWORD parameter... of course, without success.
Please, tell me how to declare a string parameter.
Once again, thanks; you are the best.
-Milos
Hmm, this is the first time I''ve heard there is a string data type in ASM. I thought it is an array of BYTEs... I have tried to pass a string to a :BYTE and :DWORD parameter... of course, without success.
Please, tell me how to declare a string parameter.
Once again, thanks; you are the best.
-Milos
-Milos
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement