From: "MarKol" Newsgroups: comp.os.msdos.djgpp Subject: Help me : DJGPP + assembly Date: Fri, 27 Apr 2001 12:06:17 +0200 Organization: Technical University of Gdansk Lines: 115 Message-ID: <9cbg7f$66t$1@sunrise.pg.gda.pl> NNTP-Posting-Host: seazone.gda.pl X-Trace: sunrise.pg.gda.pl 988365871 6365 195.117.175.253 (27 Apr 2001 10:04:31 GMT) X-Complaints-To: abuse AT pg DOT gda DOT pl NNTP-Posting-Date: 27 Apr 2001 10:04:31 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello. I encountered problem and I can't cope with it. I use DJGPP under DOS and link "C" code with assembly (MASM format). It's very important to use MASM format. I generate COFF format instead OBJ like this: ml /coff /Fo asm_file.o /c asm_file.asm and I get asm_file.o in COFF format, Then I compile my "C" program: gcc -c c_file.c and another .o file appears, and link: gcc -o ex_file.exe asm_file.o c_file.o Success, no erros. I run ex_file.exe but it doesn't work correctly. Please consider this: ;---------------- asm test file ----------------- .586P .model flat .data public _main_asm .code extrn _func_c:near _func_asm_2 proc near nop nop nop nop nop ret _func_asm_2 endp _func_asm_1 proc near lea eax, _func_c call eax ret _func_asm_1 endp _main_asm proc near call _func_asm_1 lea eax, _func_c call eax ; call _func_c ; (1) ; lea eax, _func_asm_1 ; (2) ; call eax ; (2) ret _main_asm endp END /*########## C file ########### */ #include extern void main_asm(void); void func_c(void){ printf("Ok\n"); } int main() { func_c(); main_asm(); return 0; } /*######## C file end ########*/ If you compile, link and run this program, you'll get 3x "Ok" on screen, and that is right. Problem appears after removing comments from lines marked (1) and (2). After this modification program doesn't work correct ( and it doesn't work correctly when comment is removed only from line marked (1) or lines marked (2)! ) No errors, no warnings during compilation and link. Program should write 5x "Ok" on screen but it doesn't. It crashes or writes "Ok" but not 5x. (When I build program using MS compiler VC6, I get 5x "Ok" on my monitor) What's wrong? Please, help me. I must somehow use this MASM-format assembly files with DJGPP (these files include SSE and MMX instructions, I'm afraid there is no masm 2 as converter with SSE and MMX instructions). I suspect that problem is in relocation, but I don't know how to fix it. Please, help Thanks --- |-|-|-|-| \ / Marek Kolacz - MarKol | | | | (markol4 AT wp DOT pl) ( ) ( ) (_________)