From: Hul Tytus on 27 Dec 2009 12:23 comp.arch.embedded Assembly code with Borland's C compiler Anyone have suggestions regarding the form for assembley code files used with Borland's version C compiler? The code below, assembled by masm6, doesn't satisfy the linker (Borland's). The segment names are a guess for the most part - taken from masm6's accrued examples on other projects. "cs:DGROUP" appears off but, if the error is due to segment names, maybe someone here knows suitable names? The code & bat file & error messages are included below. Hul ********************************************************* ; wedtst.asm name SUPP32 ; ??? .386p public _wedtst ; Segments & groups DGROUP group _TEXT _TEXT segment assume cs:DGROUP,ds:DGROUP _wedtst proc ; awk (WORD gdtsize, DWORD flataddr) void public push bp ;save bp mov bp,sp ; -> stack frame mov eax, 66 pop bp ;restore bp ret _wedtst endp _TEXT ends end ******** bat file SET BC55PATH=C:\BOR5 %BC55PATH%\bin\bcc32 -c -tW -a4 -g20 -I.. -I%BC55PATH%\include windil.c > compout.txt rem %BC55PATH%\bin\brc32 -i%BC55PATH%\include windil.rc >> compout.txt %BC55PATH%\bin\ilink32 -L%BC55PATH%\lib -c -aa -Tpe c0w32+windil+wedtst,windil, NULL,import32.lib+cw32.lib,, >> compout.txt type compout.txt | more ******* compout.txt C:\bor5\wed>SET BC55PATH=C:\BOR5 C:\bor5\wed>C:\BOR5\bin\bcc32 -c -tW -a4 -g20 -I.. -IC:\BOR5\include windil.c 1>compout.txt C:\bor5\wed>C:\BOR5\bin\ilink32 -LC:\BOR5\lib -c -aa -Tpe c0w32+windil+wedtst, windil,NULL,import32.lib+cw32.lib,, 1>>compout.txt C:\bor5\wed>type compout.txt | more Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland WINDIL.C: Warning W8057 WINDIL.C 48: Parameter 'hPrevinstance' is never used in function WinMain Warning W8057 WINDIL.C 48: Parameter 'szCmdLine' is never used in function WinMain Warning W8065 WINDIL.C 200: Call to function 'pooi' with no prototype in function WndProc Warning W8065 WINDIL.C 262: Call to function 'iitoaa' with no prototype in function pooi Warning W8070 WINDIL.C 265: Function should return a value in function pooi Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland Error: Unresolved external '_wedtst' referenced from C:\BOR5\WED\WINDIL.OBJ
From: Rich Webb on 27 Dec 2009 13:09 On Sun, 27 Dec 2009 17:23:59 +0000 (UTC), Hul Tytus <ht(a)panix.com> wrote: >comp.arch.embedded >Assembly code with Borland's C compiler > > Anyone have suggestions regarding the form for assembley code files used >with Borland's version C compiler? The code below, assembled by masm6, doesn't >satisfy the linker (Borland's). > The segment names are a guess for the most part - taken from masm6's >accrued examples on other projects. "cs:DGROUP" appears off but, if the error >is due to segment names, maybe someone here knows suitable names? > The code & bat file & error messages are included below. It's been ages since I fiddled with X86 assembly but this might help. For "Borland C++ 5.5.1" (the version with BCB5), and running "bcc32 -S hello.c" on --- #include <stdio.h> main() { puts("Hello, world!"); return 0; } --- we get "hello.asm" as --- .386p ifdef ??version if ??version GT 500H .mmx endif endif model flat ifndef ??version ?debug macro endm endif ?debug S "hello.c" ?debug T "hello.c" _TEXT segment dword public use32 'CODE' _TEXT ends _DATA segment dword public use32 'DATA' _DATA ends _BSS segment dword public use32 'BSS' _BSS ends DGROUP group _BSS,_DATA _TEXT segment dword public use32 'CODE' _main proc near ?live1@0: ; ; main() ; push ebp mov ebp,esp ; ; { ; puts("Hello, world!"); ; @1: push offset s@ call _puts pop ecx ; ; return 0; ; xor eax,eax ; ; } ; @3: @2: pop ebp ret _main endp _TEXT ends _DATA segment dword public use32 'DATA' s@ label byte ; s@+0: db "Hello, world!",0 align 4 _DATA ends _TEXT segment dword public use32 'CODE' _TEXT ends public _main extrn _puts:near ?debug D "C:\Program Files\Borland\CBuilder5\Include\_nfile.h" 10303 10240 ?debug D "C:\Program Files\Borland\CBuilder5\Include\_null.h" 10303 10240 ?debug D "C:\Program Files\Borland\CBuilder5\Include\_defs.h" 10303 10240 ?debug D "C:\Program Files\Borland\CBuilder5\Include\_stddef.h" 10303 10240 ?debug D "C:\Program Files\Borland\CBuilder5\Include\stdio.h" 10303 10240 ?debug D "hello.c" 14050 28522 end --- -- Rich Webb Norfolk, VA
From: Jon Kirwan on 27 Dec 2009 13:27 On Sun, 27 Dec 2009 17:23:59 +0000 (UTC), Hul Tytus <ht(a)panix.com> wrote: >comp.arch.embedded >Assembly code with Borland's C compiler > > Anyone have suggestions regarding the form for assembley code files used >with Borland's version C compiler? The code below, assembled by masm6, doesn't >satisfy the linker (Borland's). > The segment names are a guess for the most part - taken from masm6's >accrued examples on other projects. "cs:DGROUP" appears off but, if the error >is due to segment names, maybe someone here knows suitable names? > The code & bat file & error messages are included below. > >Hul I don't have time right now to dig into this. But could you post the error messages? The exact details of those you are getting? I gather from the above you are using a Microsoft assembler's output and linking it together with the output from a Borland c compiler using the Borland linker. Another thing to keep in mind is that the records placed in the OBJ file (aside from naming issues you above suggest) might be somewhat different -- in short, the Borland linker may not recognize every record in the output of the Microsoft assembler. Though it may. I just don't know. The error messages may help to disambiguate here. Jon
From: ArarghMail912NOSPAM on 27 Dec 2009 13:57 On Sun, 27 Dec 2009 17:23:59 +0000 (UTC), Hul Tytus <ht(a)panix.com> wrote: >comp.arch.embedded >Assembly code with Borland's C compiler > > Anyone have suggestions regarding the form for assembley code files used >with Borland's version C compiler? The code below, assembled by masm6, doesn't >satisfy the linker (Borland's). > The segment names are a guess for the most part - taken from masm6's >accrued examples on other projects. "cs:DGROUP" appears off but, if the error >is due to segment names, maybe someone here knows suitable names? > The code & bat file & error messages are included below. > >Hul > >********************************************************* >; wedtst.asm > name SUPP32 ; ??? > > .386p >public _wedtst > >; Segments & groups >DGROUP group _TEXT > >_TEXT segment > assume cs:DGROUP,ds:DGROUP > >_wedtst proc ; awk (WORD gdtsize, DWORD flataddr) void public > push bp ;save bp > mov bp,sp ; -> stack frame > mov eax, 66 > pop bp ;restore bp > ret >_wedtst endp >_TEXT ends > end Unless I have missed something, this will generate a 16-bit object, and it looks like the c code (from below) is 32-bit. That generally don't work. Try something more like: ..386 ..model flat ..code _wedtst proc ; awk (WORD gdtsize, DWORD flataddr) void public push bp ;save bp mov bp,sp ; -> stack frame mov eax, 66 pop bp ;restore bp ret _wedtst endp end > >******** bat file >SET BC55PATH=C:\BOR5 > >%BC55PATH%\bin\bcc32 -c -tW -a4 -g20 -I.. -I%BC55PATH%\include windil.c > >compout.txt >rem %BC55PATH%\bin\brc32 -i%BC55PATH%\include windil.rc >> compout.txt >%BC55PATH%\bin\ilink32 -L%BC55PATH%\lib -c -aa -Tpe c0w32+windil+wedtst,windil, >NULL,import32.lib+cw32.lib,, >> compout.txt >type compout.txt | more > >******* compout.txt >C:\bor5\wed>SET BC55PATH=C:\BOR5 >C:\bor5\wed>C:\BOR5\bin\bcc32 -c -tW -a4 -g20 -I.. -IC:\BOR5\include windil.c > 1>compout.txt >C:\bor5\wed>C:\BOR5\bin\ilink32 -LC:\BOR5\lib -c -aa -Tpe c0w32+windil+wedtst, >windil,NULL,import32.lib+cw32.lib,, 1>>compout.txt >C:\bor5\wed>type compout.txt | more >Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland >WINDIL.C: >Warning W8057 WINDIL.C 48: Parameter 'hPrevinstance' is never used in function >WinMain >Warning W8057 WINDIL.C 48: Parameter 'szCmdLine' is never used in function >WinMain >Warning W8065 WINDIL.C 200: Call to function 'pooi' with no prototype in >function WndProc >Warning W8065 WINDIL.C 262: Call to function 'iitoaa' with no prototype in >function pooi >Warning W8070 WINDIL.C 265: Function should return a value in function pooi >Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland >Error: Unresolved external '_wedtst' referenced from C:\BOR5\WED\WINDIL.OBJ -- ArarghMail912 at [drop the 'http://www.' from ->] http://www.arargh.com BCET Basic Compiler Page: http://www.arargh.com/basic/index.html To reply by email, remove the extra stuff from the reply address.
From: Tim Wescott on 27 Dec 2009 14:03 On Sun, 27 Dec 2009 17:23:59 +0000, Hul Tytus wrote: > comp.arch.embedded > Assembly code with Borland's C compiler > > Anyone have suggestions regarding the form for assembley code files > used > with Borland's version C compiler? The code below, assembled by masm6, > doesn't satisfy the linker (Borland's). > The segment names are a guess for the most part - taken from masm6's > accrued examples on other projects. "cs:DGROUP" appears off but, if the > error is due to segment names, maybe someone here knows suitable names? > The code & bat file & error messages are included below. > -- snip -- If I'm working with a tool chain that supports compiling to assembly I cheat. I write a framework file in C and compile to assembly, then find the insides of the functions and start writing code. It may not be manly, but it works just fine. -- www.wescottdesign.com
|
Next
|
Last
Pages: 1 2 Prev: Global Warming and what you can do to against it Next: Assembly code with Borland's C compiler |