Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Import projektu/ów z Visual C++ 2008 do Code::Blocks 16.01 (wstawki asemblerowe i inne [...] )

Ostatnio zmodyfikowano 2016-11-11 23:03
Autor Wiadomość
Rashmistrz
Temat założony przez niniejszego użytkownika
Import projektu/ów z Visual C++ 2008 do Code::Blocks 16.01 (wstawki asemblerowe i inne [...] )
» 2016-11-09 23:59:41
Ostatnio ściągnąłem z githuba repozytorium  pewnej gry:
https://github.com/id-Software​/RTCW-SP (RTCW-SP.git)

Używając wbudowanego w C::B importera projektów zaimportowałem plik wolf.sln.
(Na wszystkie okna dialogowe odpowiadałem "TAK".)
Powstały projekty *.cbp: (pojawiły się w zakładce "projects")
Splines, botlib, cgame, extractfuncs,
game, renderer, ui i wolf.

Projekty Splines, botlib i extractfuncs "buildują" się bez problemów.
Zaś reszta napotyka jakieś problemy:

game, cgame i ui mają wspólny problem z plikiem q_math.c:
E:\KODY\RTCW-SP\src\game\q_math.c|744|warning: 'naked' attribute directive ignored [-Wattributes]|
E:\KODY\RTCW-SP\src\game\q_math.c||In function 'BoxOnPlaneSide':|
E:\KODY\RTCW-SP\src\game\q_math.c|748|error: expected '(' before '{' token|
E:\KODY\RTCW-SP\src\game\q_math.c|750|error: unknown type name 'push'|
E:\KODY\RTCW-SP\src\game\q_math.c|752|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cmp'|

renderer napotyka problem w:
  //basetsd.h (biblioteka dołączona do kompilatora):
  C:\x86\CodeBlocks\MinGW\include\basetsd.h|54|error: conflicting types for 'INT32'|
  E:\KODY\RTCW-SP\src\jpeg-6\..\jpeg-6\jmorecfg.h|152|note: previous declaration of 'INT32' was here|
 
  // (brak tych bibliotek "standardowych")
  E:\KODY\RTCW-SP\src\win32\win_local.h|46|fatal error: dinput.h: No such file or directory|
  E:\KODY\RTCW-SP\src\win32\win_local.h|47|fatal error: dsound.h: No such file or directory|
 
  E:\KODY\RTCW-SP\src\renderer\tr_shade_calc.c||In function 'myftol':|
  E:\KODY\RTCW-SP\src\renderer\tr_shade_calc.c|1113|error: expected '(' before 'fld'|
  E:\KODY\RTCW-SP\src\renderer\tr_shade_calc.c|1113|error: unknown type name 'fld'|
  E:\KODY\RTCW-SP\src\renderer\tr_shade_calc.c|1114|error: expected '(' before 'fistp'|
  E:\KODY\RTCW-SP\src\renderer\tr_shade_calc.c|1113|error: 'f' redeclared as different kind of symbol|
  E:\KODY\RTCW-SP\src\renderer\tr_shade_calc.c|1111|note: previous definition of 'f' was here|
 
Zaś wolf sieje pogrom
i jego build napotyka najwięcej problemów,
więc resztę tego "projektu" przestałem przeglądać.
(Wziąłem z tego tylko jeden) snd_mix.c:
  E:\KODY\RTCW-SP\src\client\snd_mix.c|84|warning: 'naked' attribute directive ignored [-Wattributes]|
  E:\KODY\RTCW-SP\src\client\snd_mix.c||In function 'S_WriteLinearBlastStereo16':|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|85|error: expected '(' before '{' token|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|87|error: unknown type name 'push'|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|88|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'push'|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|95|error: invalid suffix "FFFh" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|97|error: invalid suffix "FFFF8000h" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|99|error: invalid suffix "FFFF8000h" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|102|error: invalid suffix "FFFh" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|106|error: invalid suffix "FFFh" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|108|error: invalid suffix "FFFF8000h" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|110|error: invalid suffix "FFFF8000h" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|113|error: invalid suffix "FFFh" on integer constant|
  E:\KODY\RTCW-SP\src\client\snd_mix.c|116|error: invalid suffix "FFFFh" on integer constant|

Plik q_math.c (jego problematyczny fragment):
C/C++
__declspec( naked ) int BoxOnPlaneSide( vec3_t emins, vec3_t emaxs, struct cplane_s * p ) {
    static int bops_initialized;
    static int Ljmptab[ 8 ];
   
    __asm {
       
        push ebx
       
        cmp bops_initialized, 1
        je initialized
        mov bops_initialized, 1
       
        mov Ljmptab[ 0 * 4 ], offset Lcase0
        mov Ljmptab[ 1 * 4 ], offset Lcase1
        mov Ljmptab[ 2 * 4 ], offset Lcase2
        mov Ljmptab[ 3 * 4 ], offset Lcase3
        mov Ljmptab[ 4 * 4 ], offset Lcase4
        mov Ljmptab[ 5 * 4 ], offset Lcase5
        mov Ljmptab[ 6 * 4 ], offset Lcase6
        mov Ljmptab[ 7 * 4 ], offset Lcase7
       
        initialized:
       
        mov edx, dword ptr[ 4 + 12 + esp ]
        mov ecx, dword ptr[ 4 + 4 + esp ]
        xor eax, eax
        mov ebx, dword ptr[ 4 + 8 + esp ]
        mov al, byte ptr[ 17 + edx ]
        cmp al, 8
        jge Lerror
        fld dword ptr[ 0 + edx ]
        fld st( 0 )
        jmp dword ptr[ Ljmptab + eax * 4 ]
        Lcase0
            : fmul dword ptr[ ebx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ebx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase1
            : fmul dword ptr[ ecx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ebx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase2
            : fmul dword ptr[ ebx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ecx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase3
            : fmul dword ptr[ ecx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ecx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase4
            : fmul dword ptr[ ebx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ebx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase5
            : fmul dword ptr[ ecx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ebx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase6
            : fmul dword ptr[ ebx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ecx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ecx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) jmp LSetSides Lcase7
            : fmul dword ptr[ ecx ] fld dword ptr[ 0 + 4 + edx ] fxch st( 2 ) fmul dword ptr[ ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 4 + ecx ] fld dword ptr[ 0 + 8 + edx ] fxch st( 2 ) fmul dword ptr[ 4 + ebx ] fxch st( 2 ) fld st( 0 ) fmul dword ptr[ 8 + ecx ] fxch st( 5 ) faddp st( 3 )
             , st( 0 ) fmul dword ptr[ 8 + ebx ] fxch st( 1 ) faddp st( 3 )
             , st( 0 ) fxch st( 3 ) faddp st( 2 )
             , st( 0 ) LSetSides
            : faddp st( 2 )
             , st( 0 ) fcomp dword ptr[ 12 + edx ] xor ecx
             , ecx fnstsw ax fcomp dword ptr[ 12 + edx ] and ah
             , 1 xor ah
             , 1 add cl
             , ah fnstsw ax and ah
             , 1 add ah
             , ah add cl
             , ah pop ebx mov eax
             , ecx ret Lerror
            : int 3 }
}

Plik snd_mix.c (jego problematyczny fragment):
C/C++
__declspec( naked ) void S_WriteLinearBlastStereo16( void ) {
    __asm {
       
        push edi
        push ebx
        mov ecx, ds: dword ptr[ snd_linear_count ]
        mov ebx, ds: dword ptr[ snd_p ]
        mov edi, ds: dword ptr[ snd_out ]
        LWLBLoopTop:
        mov eax, ds: dword ptr[ - 8 + ebx + ecx * 4 ]
        sar eax, 8
        cmp eax, 07FFFh
        jg LClampHigh
        cmp eax, 0FFFF8000h
        jnl LClampDone
        mov eax, 0FFFF8000h
        jmp LClampDone
        LClampHigh:
        mov eax, 07FFFh
        LClampDone:
        mov edx, ds: dword ptr[ - 4 + ebx + ecx * 4 ]
        sar edx, 8
        cmp edx, 07FFFh
        jg LClampHigh2
        cmp edx, 0FFFF8000h
        jnl LClampDone2
        mov edx, 0FFFF8000h
        jmp LClampDone2
        LClampHigh2:
        mov edx, 07FFFh
        LClampDone2:
        shl edx, 16
        and eax, 0FFFFh
        or edx, eax
        mov ds: dword ptr[ - 4 + edi + ecx * 2 ], edx
        sub ecx, 2
        jnz LWLBLoopTop
        pop ebx
        pop edi
        ret
    }
}

Plik tr_shade_calc.c (jego problematyczny fragment):
C/C++
long myftol( float f ) {
    static int tmp;
    __asm fld f
    __asm fistp tmp
    __asm mov eax, tmp
}
_______________________________________________________

Mój kompilator to GCC załączny do tej wersji C::B.
Prosto mowiąc, w głównej mierze
kompilator ten nie rozumie tamtejszych wstawek.

Wykonałem potrzebne kroki zawarte w README.txt,
czyli uruchomienie src\extractfuncs\extractfuncs.bat
z uprzednim utworzeniem pliku wykonywalnego.
(Bez niego ten plik wsadowy uruchamiałby sam siebie w nieskończoność)

Temat uznam za zamknięty
kiedy uda mi się uzyskać pliki:
WolfSP.exe, qagamex86.dll, cgamex86.dll, uix86.dll

To dość harde zadanie...
_______________________________________________________

To samo wszystko mam zamiar zrobić też z: (ale później)
https://github.com/id-Software​/RTCW-MP (RTCW-MP.git)
P-153533
jankowalski25
» 2016-11-11 22:38:38
C/C++
__asm {
    push edi
    push ebx
W GCC to nie zadziała. Przykładowa wstawka wygląda tak:
C/C++
asm
(
".globl main\n"
"main:\n"
"    xorl %eax,%eax\n"
"    ret"
);
Pamiętaj, że domyślną składnią jest AT&T.
P-153588
Rashmistrz
Temat założony przez niniejszego użytkownika
» 2016-11-11 23:00:52
Pamiętaj, że domyślną składnią jest AT&T.
Czyli da się ją przestawić na Intelowską
dodając jakieś parametry do polecenia kompilacji?
Już jakoś przeżyję ręczne przepisywanie tych wstawek. :F
P-153589
jankowalski25
» 2016-11-11 23:03:50
Dodaj
-masm=intel
 przy kompilacji.
W Code::Blocks: "Settings"->"Compiler"->"Compiler settings"->"Other compiler options"->wpisujesz "-masm=intel" w pole tekstowe.
[StackOverflow] How do you use gcc to generate assembly code in Intel syntax?
Notes:
immediate operand must be use _variable in global variabel, not local variable.
example: mov _nLength, eax NOT mov $nLength, eax or mov nLength, eax

A number in hexadecimal format must use at&t syntax, cannot use intel syntax.
example: mov eax, 0xFF -> TRUE, mov eax, 0FFh -> FALSE.
P-153590
« 1 »
  Strona 1 z 1