User forums > Using Code::Blocks

Assembler Code

(1/2) > >>

stream:
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

polygon7:
Hi,
use "__asm" instead of "_asm".

stream:
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'

polygon7:
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
    }

--- End code ---
Working binary: http://www.icpnet.pl/~groman/Release.rar - it's my lame demo in C++ with lot of asm, it uses OpenGL.

tiwag:

--- Quote from: stream 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.
...
The compiler doesn't know what _asm is.

--- End quote ---

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;
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version