Thread: [Dev-C++] Problem with __asm statement
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Philip B. <phi...@pb...> - 2007-02-17 00:31:22
|
Hello,
A few days go I hired a person from Rent a coder to write me a couple of =
C++ functions. he was using Vc++ to develop his code as far as I know. =
Now, MinGW has problems compiling his code because of the fact that he =
is using assembly. One part of the code looks like:
__asm {
mov ebx, dwCardID
add ebx, i
xor eax,eax
mov al, bTmp
mov byte ptr [ebx],al
}
But it completely refuses to compile it. Can anyone tell me why?
Thanks in advance.
Regards
Philip Bennefall |
|
From: Per W. <pw...@ia...> - 2007-02-17 00:42:04
|
Because asm isn't examply part of the c++ standard. The use of embedded assembler is a compiler-specific extension, and different architectures and/or compilers can use different formats. VC uses the Intel standard for writing x86 assembly instructions. gcc uses the AT&T syntax. See http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s3 Different compilers also have different calling conventions, so even if the assembly code is modified to the correct dialect, you can't be sure that the two compilers uses the same registers or parameter passing conventions. Did you request him to write in assembler? If you didn't specifically requested it, then the delivery was not according to agreement. If you did request an assembler solution, then you should have specified the target, i.e. processor, OS, compiler, ... /pwm On Sat, 17 Feb 2007, Philip Bennefall wrote: > Hello, > > A few days go I hired a person from Rent a coder to write me a couple of C++ functions. he was using Vc++ to develop his code as far as I know. Now, MinGW has problems compiling his code because of the fact that he is using assembly. One part of the code looks like: > __asm { > mov ebx, dwCardID > add ebx, i > xor eax,eax > mov al, bTmp > mov byte ptr [ebx],al > } > But it completely refuses to compile it. Can anyone tell me why? > > Thanks in advance. > > Regards > Philip Bennefall |
|
From: Philip B. <phi...@pb...> - 2007-02-17 01:03:47
|
No, I did not request him to write assembly code and thus, I did not tell him what compiler I was using either. he compiled a test executable and I thought it was such a simple task and I had seen a working example as well as the code, so I paid him. It was a low price, because it is a simple function. I'm not sure where to go from here, I suppose I will have to hire someone to explissitly translate the thing because I don't have enough knowledge yet to do it myself. The section I pasted was only one of the two that there are all in total, although the second one is a bit longer but the same commands are repeated. Regards Philip Bennefall ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Philip Bennefall" <phi...@pb...> Cc: <dev...@li...> Sent: Saturday, February 17, 2007 1:41 AM Subject: Re: [Dev-C++] Problem with __asm statement > Because asm isn't examply part of the c++ standard. > > The use of embedded assembler is a compiler-specific extension, and > different architectures and/or compilers can use different formats. > > VC uses the Intel standard for writing x86 assembly instructions. > > gcc uses the AT&T syntax. > > See http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s3 > > Different compilers also have different calling conventions, so even if > the assembly code is modified to the correct dialect, you can't be sure > that the two compilers uses the same registers or parameter passing > conventions. > > Did you request him to write in assembler? If you didn't specifically > requested it, then the delivery was not according to agreement. > > If you did request an assembler solution, then you should have specified > the target, i.e. processor, OS, compiler, ... > > /pwm > > On Sat, 17 Feb 2007, Philip Bennefall wrote: > >> Hello, >> >> A few days go I hired a person from Rent a coder to write me a couple of >> C++ functions. he was using Vc++ to develop his code as far as I know. >> Now, MinGW has problems compiling his code because of the fact that he is >> using assembly. One part of the code looks like: >> __asm { >> mov ebx, dwCardID >> add ebx, i >> xor eax,eax >> mov al, bTmp >> mov byte ptr [ebx],al >> } >> But it completely refuses to compile it. Can anyone tell me why? >> >> Thanks in advance. >> >> Regards >> Philip Bennefall > > |
|
From: Per W. <pw...@ia...> - 2007-02-17 01:31:04
|
No, you do not want anyone to translate it to assembly for use with gcc. They guy returned assembler code just to poke fun at you. Based on the looks of the code, he didn't even bother to really write in assembler. He wrote the code in C/C++, requested the compiler to generate an assembler listing and then took the assembler instructions and pasted into the functions, instead of the original code. Exactly what did you originally request help with coding? /pwm On Sat, 17 Feb 2007, Philip Bennefall wrote: > No, I did not request him to write assembly code and thus, I did not tell > him what compiler I was using either. he compiled a test executable and I > thought it was such a simple task and I had seen a working example as well > as the code, so I paid him. It was a low price, because it is a simple > function. I'm not sure where to go from here, I suppose I will have to hire > someone to explissitly translate the thing because I don't have enough > knowledge yet to do it myself. The section I pasted was only one of the two > that there are all in total, although the second one is a bit longer but the > same commands are repeated. > > Regards > Philip Bennefall > ----- Original Message ----- > From: "Per Westermark" <pw...@ia...> > To: "Philip Bennefall" <phi...@pb...> > Cc: <dev...@li...> > Sent: Saturday, February 17, 2007 1:41 AM > Subject: Re: [Dev-C++] Problem with __asm statement > > > > Because asm isn't examply part of the c++ standard. > > > > The use of embedded assembler is a compiler-specific extension, and > > different architectures and/or compilers can use different formats. > > > > VC uses the Intel standard for writing x86 assembly instructions. > > > > gcc uses the AT&T syntax. > > > > See http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s3 > > > > Different compilers also have different calling conventions, so even if > > the assembly code is modified to the correct dialect, you can't be sure > > that the two compilers uses the same registers or parameter passing > > conventions. > > > > Did you request him to write in assembler? If you didn't specifically > > requested it, then the delivery was not according to agreement. > > > > If you did request an assembler solution, then you should have specified > > the target, i.e. processor, OS, compiler, ... > > > > /pwm > > > > On Sat, 17 Feb 2007, Philip Bennefall wrote: > > > >> Hello, > >> > >> A few days go I hired a person from Rent a coder to write me a couple of > >> C++ functions. he was using Vc++ to develop his code as far as I know. > >> Now, MinGW has problems compiling his code because of the fact that he is > >> using assembly. One part of the code looks like: > >> __asm { > >> mov ebx, dwCardID > >> add ebx, i > >> xor eax,eax > >> mov al, bTmp > >> mov byte ptr [ebx],al > >> } > >> But it completely refuses to compile it. Can anyone tell me why? > >> > >> Thanks in advance. > >> > >> Regards > >> Philip Bennefall > > > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Daniel K. O. <dan...@gm...> - 2007-02-17 16:32:18
|
Per Westermark escreveu:
> No, you do not want anyone to translate it to assembly for use with gcc.
>
Indeed, that doesn't look like the right solution. Gcc also accepts
Intel syntax, with -masm=intel, but it may still need some tweaking.
> They guy returned assembler code just to poke fun at you.
>
Hanlon's razor: "never attribute to malice that which can be adequately
explained by stupidity".
The code in question:
> __asm {
> mov ebx, dwCardID
> add ebx, i
> xor eax,eax
> mov al, bTmp
> mov byte ptr [ebx],al
> }
Seems the equivalent to:
dwCardID[i] = bTmp;
Doing the "xor eax, eax" (i.e. "eax = 0") just before setting and
reading "al" suggest that it was not generated by a compiler, but by
someone trying to "optimize" something.
---
Daniel K. O.
|