On Sat, 06 Oct 2007 16:46:09 +0200, "Danny Backx" said:
On Fri, 2007-10-05 at 22:26 +0200, Vitus Jensen wrote:

I'm trying to port a small testprogramm from embedded Visual C 4 to
mingw32ce (cegcc-mingw32ce-0.50-1.i586.rpm).  It's text mode, 2 threads,
some printf, some files, nothing fancy but ... it has to use 2 object
libraries (3rd party) and a DLL (my own).

I'm able to compile and link this programm but when I call the 3rd party
library an important call fails.  It's the only call with several
parameters so I suspect different calling conventions.

Goes like this:

extern int libconfig(int hd, int subfct, void * parameter);

test()
{
      hd = libopen();
      res = libconfig(hd, 1, (void *)0815);
      res = libconfig(hd, 2, (void *)15);
      ...
      libclose(hd);
}

Result code indicates "invalid subfunction" :-(

The prototype shows no "__syscall" or the like, the object library works
when used with eVC.  I've looked at the produced assembler code in the eVC
debugger and it seems parameters are transfered via r0, r1 and r2.  Isn't
this the same as in mingw32ce?  In my opinion all this indicates that the
program should work.  It doesn't :-(

This is probably a silly remark but "0815" is an invalid number. The GNU
C compiler will treat any number that starts with a 0 as octal. In
octal, there's no 8, so the compiler issues an error :
  tt.c:8:33: error: invalid digit "8" in octal constant

In case that that isn't your problem, I've attached a source and
assembler file generated by arm-wince-mingw32ce-gcc . Which assembler
instructions does eVC generate for this file ?

See attached code.  It looks similar to me, at least the subfunction no
is in register r1, too.  But I'm new to ARM assembler, I admit.

BTW: one reason to try cegcc/minw32ce was the lack of a proper CRT in
eVC.  I wanted to build a console program using getch() or
setvbuf(_IONBF) but found in the meantime that those things won't work
under cegcc or minw32ce.  Is this correct or is that just my fault?

Bye,
   Vitus

--
Vitus Jensen, Hannover, Earth, Milky Way
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.20.9775 

        TTL     D:\winapps\swifttest\test.c
        CODE32

  00000                  AREA    |.drectve|, DRECTVE
        DCB     "-defaultlib:coredll.lib "
        DCB     "-defaultlib:corelibc.lib "

        EXPORT  |test|
        IMPORT  |libconfig|
        IMPORT  |libopen|
        IMPORT  |libclose|

  00000                  AREA    |.pdata|, PDATA
|$T105| DCD     |test|
        DCD     0x40001a02
; Function compile flags: /Odt
; File D:\winapps\swifttest\test.c

  00000                  AREA    |.text|, CODE, ARM

  00000          |test|  PROC

; 4    : {

  00000 e52de004         str       lr, [sp, #-4]!
  00004 e24dd014         sub       sp, sp, #0x14
  00008          |$M103|

; 5    :        int hd, res;
; 6    : 
; 7    :        hd = libopen();

  00008 eb000000         bl        libopen
  0000c e58d0008         str       r0, [sp, #8]
  00010 e59d1008         ldr       r1, [sp, #8]
  00014 e58d1004         str       r1, [sp, #4]

; 8    :        res = libconfig(hd, 1, (void *)815);

  00018 e3a00fcb         mov       r0, #0xCB, 30
  0001c e3802003         orr       r2, r0, #3
  00020 e3a01001         mov       r1, #1
  00024 e59d0004         ldr       r0, [sp, #4]
  00028 eb000000         bl        libconfig
  0002c e58d000c         str       r0, [sp, #0xC]
  00030 e59d100c         ldr       r1, [sp, #0xC]
  00034 e58d1000         str       r1, [sp]

; 9    :        res = libconfig(hd, 2, (void *)15);

  00038 e3a0200f         mov       r2, #0xF
  0003c e3a01002         mov       r1, #2
  00040 e59d0004         ldr       r0, [sp, #4]
  00044 eb000000         bl        libconfig
  00048 e58d0010         str       r0, [sp, #0x10]
  0004c e59d1010         ldr       r1, [sp, #0x10]
  00050 e58d1000         str       r1, [sp]

; 10   :        libclose(hd);

  00054 e59d0004         ldr       r0, [sp, #4]
  00058 eb000000         bl        libclose

; 11   : }

  0005c e28dd014         add       sp, sp, #0x14
  00060 e8bd4000         ldmia     sp!, {lr}
  00064 e12fff1e         bx        lr
  00068          |$M104|

                         ENDP  ; |test|

        END
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to