News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

from c/c++ to masm32 syntax i need help!

Started by oversight, February 14, 2006, 10:45:12 PM

Previous topic - Next topic

oversight

Hi,

how does this function looks inside masm32 invoke syntax?

//result = sendto( sendSocket, (const char *)outBuffer, count, 0, (SOCKADDR *)&remoteAddr, sizeof( SOCKADDR ) );

my try: (buggy keeps crashing)
__asm
{

   invoke  ::sendto, sendSocket, ptr outBuffer, count, 0, ptr remoteAddr,SOCKET_SIZE_PZ

mov eax,result
}


i really hope to fix this one.


Thanx.

Timbo

//I think the addr operator can be used in inline asm with MSVC
invoke sendto, sendsocket, addr outBuffer, count, 0, addr remoteAddr, sizeof SOCKADDR
mov result, eax//  <-- you had the operand order reversed, thus trashing EAX with trash in your uninitialized variable.

oversight

d:\Soldner\SecretOps\source\Cyberspace\NetworkUDP\cHost.cpp(625): error C2400: inline assembler syntax error in 'opcode'; found 'sendto'

damm sizeof and addr are not supported or its the invoke wich visual studio 7 doesn`t support.
I am totaly lost here  :dazzled:

__asm
{
invoke sendto, sendsocket, addr outBuffer, count, 0, addr remoteAddr, sizeof SOCKADDR

}
Thanx for your support.

i am using asm to speed up game players lag probs.
we have 64 max players now :-)

and only server uses critical sections... have to determine that from running game ;-)

I found xxxx errors on vc7 also with popa, pusha shit it jusr crashed ;-)


zooba

You won't gain anything by using ASM to call functions. In fact, you're more likely to get faster code by letting C/C++ do it, since it disables optimisations once you put an '__asm' statement in your function.

If you've got a lot of number crunching to do or an algorithm that the compiler just doesn't quite get right, assembly will help. Otherwise, chances are you're not gaining a thing.

Timbo

Oversight, you're right.  You must use the push/call method for invocation in _asm blocks in MSVC.  I'm also uncertain now if the addr operator is functional or not in this context.  It makes no difference, though, as you aren't allow to declare LOCAL vars in the block anyway it seems which means that 'offset' will suffice as an operator.

Watch your operand order. :naughty:

Regards,

Tim

zcoder

this line:

result = sendto( sendSocket, (const char *)outBuffer, count, 0, (SOCKADDR *)&remoteAddr, sizeof( SOCKADDR ) );

converted to asm is:

                push           16 ;push Sizeof SOCKETADDR struct
                lea              ecx, remoteAddr
                push           ecx
                push           0
                push          [count]
                push         OFFSET outBuffer
                push         OFFSET sendSocket
                call           sendto
                mov         [result], eax


I hope this is what you needed.

Zcoder....
Back in 1979, My computer ran so fine.
And there was no such thing,
As a Microsoft Crashed Machine.
http://zcoder.110mb.com
http://www.dietzel.com/partner/idevaffiliate.php?id=345_6  Free Domain Names