Author Topic: Assembler Code  (Read 8709 times)

stream

  • Guest
Assembler Code
« on: October 12, 2005, 02:48:22 pm »
I use Code::Blocks with the "Microsoft Visual C++ Toolkit 2003" compiler and I've imported a project made in VC++.
There is some code in assembler and it doesn't compile.

_asm
{
   mov edi,h.mDstP
   mov esi,h.mSrcP
   mov ecx,h.mRunLength

   copyloop:
      movzx eax,WORD PTR [esi]
      add esi,4

      mov [edi],ax
      add edi,2

      dec ecx
      jnz copyloop
   
   mov h.mDstP,edi
   mov h.mSrcP,esi
}
The compiler doesn't know what _asm is.
How can I compile the assembler code?Do u have any ideas? I'd appreciate some help

Offline polygon7

  • Multiple posting newcomer
  • *
  • Posts: 104
    • Home site
Re: Assembler Code
« Reply #1 on: October 12, 2005, 03:07:08 pm »
Hi,
use "__asm" instead of "_asm".
best regards,
p7
 Free open source UML modeling tool: ArgoUML

stream

  • Guest
Re: Assembler Code
« Reply #2 on: October 12, 2005, 03:35:10 pm »
I've tried using "__asm" instead of "_asm" and it doesn't change a thing.
I get the same compiler error : DDI_ASM_CopyPixels16.cpp(1) : error C2059: syntax error : '__asm'

Offline polygon7

  • Multiple posting newcomer
  • *
  • Posts: 104
    • Home site
Re: Assembler Code
« Reply #3 on: October 12, 2005, 04:03:56 pm »
Strange, becouse "__asm" works for me (I also use MS VC Toolkit 2k3 + Platform SDK). This code was compiled without errors:
Code
 //glFrustum(-0.104f,0.104f,-0.058f,0.058f,0.1f,100.0f);
    __asm
    {
        push    0x40590000; ///
        push    0;          //   100.0
        push    0x3FB99999; ///
        push    0x9999999A; //   0.1

        mov     eax,0x0E560419

        push    0x3FADB22D; ///
        push    eax;        //   0.058
        push    0xBFADB22D; ///
        push    eax;        //  -0.058

        mov     eax,0x76C8B439

        push    0x3FBA9FBE; ///
        push    eax;        //   0.104
        push    0xBFBA9FBE; ///
        push    eax;        // -0.104

        call    dword ptr glFrustum
    }
Working binary: http://www.icpnet.pl/~groman/Release.rar - it's my lame demo in C++ with lot of asm, it uses OpenGL.
« Last Edit: October 12, 2005, 04:08:41 pm by polygon7 »
best regards,
p7
 Free open source UML modeling tool: ArgoUML

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Assembler Code
« Reply #4 on: October 12, 2005, 04:29:33 pm »
I use Code::Blocks with the "Microsoft Visual C++ Toolkit 2003" compiler and I've imported a project made in VC++.
There is some code in assembler and it doesn't compile.
...
The compiler doesn't know what _asm is.

you must have some other syntax error in your program, i just checked, and  the following sample with your asm code compiles and runs quite fine using VCTK2003

Code
#include <stdio.h>
#include <stdlib.h>

typedef struct tagHS {
__int32* mSrcP;
__int16* mDstP;
int mRunLength;
} HS ;

void cpInt2Short(HS h) {
_asm {
mov edi,h.mDstP
mov esi,h.mSrcP
mov ecx,h.mRunLength

copyloop:
movzx eax,WORD PTR [esi]
add esi,4

mov [edi],ax
add edi,2

dec ecx
jnz copyloop

mov h.mDstP,edi
mov h.mSrcP,esi
 }
}


void someasmfoo( void)
{

#define LENGTH 10

__int32 ia1[LENGTH];
__int16 ia2[LENGTH];
HS h;

for(int i=0; i<LENGTH; i++){
ia1[i] = i+100;
}

h.mRunLength = LENGTH;
h.mSrcP = ia1;
h.mDstP = ia2;

cpInt2Short(h);

for(int i=0; i<LENGTH; i++){
printf("i: %i , ia1: %i , ia2: %i\n",i,ia1[i],ia2[i]);
}
}


int main()
{
someasmfoo();
printf("done.\n");
return 0;
}

stream

  • Guest
Re: Assembler Code
« Reply #5 on: October 12, 2005, 09:59:56 pm »
I've made a new project and tryed some assembler code and it worked just fine. The assembler code seems not to be the problem. I think the problem is the order in wich files are beeing compiled.
It's so confusing because in VC++ it compiles perfectly and I've noticed that the file compilation order in VC++ differs from that in C::B.
Do you have any ideas how may I fix this or what else could be wrong?
I apreciate your concern.

Offline polygon7

  • Multiple posting newcomer
  • *
  • Posts: 104
    • Home site
Re: Assembler Code
« Reply #6 on: October 14, 2005, 09:22:20 am »
I've made a new project and tryed some assembler code and it worked just fine. The assembler code seems not to be the problem. I think the problem is the order in wich files are beeing compiled.
It's so confusing because in VC++ it compiles perfectly and I've noticed that the file compilation order in VC++ differs from that in C::B.
Do you have any ideas how may I fix this or what else could be wrong?
I apreciate your concern.

I have no idea. Compress your project and put it here. Maybe somebody looks into it and will help you.
best regards,
p7
 Free open source UML modeling tool: ArgoUML

stream

  • Guest
Re: Assembler Code
« Reply #7 on: October 15, 2005, 12:49:38 pm »
thanx for your concerne, but I've managed top compile it.
The problem occur when I've imported the VC++ project, it forgot some settings - and i've had to cycle through all the cpp files and select the ones that compile and link  and the ones that don't.  :)