asm code: Win95->ok but crashes on Linux 
Author Message
 asm code: Win95->ok but crashes on Linux

Hi,

I've developed a relatively short assembly language module as a function
callable from C to drive the C program a lot faster.  While the code
works perfectly on Windows95 it crashes with a Segmentation Fault on
Linux (its the same machine which is dual bootable into Win95 or Linux)

The tools I'm using are
Win95  --> VC++ 6.0 with the assembly code as a standard C function with
each instruction preceeded by a _asm directive

Linux  --> Nasm version 0.98
                compiled using "% nasm -f elf compare.asm"
           gcc for compilation of the main C program
           the .c file of the C program and the .o file from the
           assembly are linked using gcc
                e.g.  % gcc -O2 -o mainprog compare.o main.c

Again, the code works perfect on Win95.  So my guess is that I'm doing
the initializations wrong on linux or I guess I'm forgetting to save the
value of some registers... or the like.

I shall be greatly appreciative if anyone can please help me in this
regard.

thanks very much,
-Amit.

PS:The assembly module involves use of MMX code and is as follows:

        global AMD_VCMP
        align 32

AMD_VCMP:
        push ebp                ;store previous content of ebp
        mov ebp, esp            ;store esp in ebp to get params frm ebp
        femms                   ;empty mmx state
        mov eax, [ebp+8]        ;load all function parameters
        movq mm0, [eax]         ;
        mov ebx, [ebp+9]        ;
        movq mm1, [ebx]         ;
        mov ebx, [ebp+11]       ;
        movq mm3, [ebx]         ;
        mov ebx, [ebp+12]       ;
        movq mm2, [ebx]         ;
        psubb mm1, mm2          ;subtract
        mov ecx, [ebp+13]       ;load counter
        mov ebx, [ebp+10]       ;load ebp with pointer to result
loop1:
        psubb mm0, mm2          ;mmx subtract
        pcmpgtb mm0, mm1        ;mmx compare
        pand mm0, mm3           ;mmx and
        add eax, 8              ;increment data pointer
        movq [ebx], mm0         ;store result
        add ebx, 8              ;increment result pointer
        movq mm0, [eax]         ;load next data
        dec ecx                 ;check counter
        jnz loop1               ;and jump depending on counter
        femms                   ;loops finished so empty the mmx state
        pop ebp                 ;restore ebp
        ret                     ;get back to C program

; end of code for compare stage

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Thu, 08 Aug 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. asm code:Win95->Ok but crashes on Linux

2. Making std asm code into Turbo Asm code?

3. Convert DOS asm code to Linux

4. Linux asm coding *without* C?

5. basic -> asm code conversion

6. BCC->ASM->OBJ->EXE ??

7. Windows DLL with Tcl 8.0 OK, crashes with 8.3

8. Graphics>>Rectangle>>intersects: erroneous code

9. Win32 asm/Linux asm newsgroups?

10. Win32 asm/Linux asm newsgroups?

11. Win95 revC ok for clip52e?

12. Clip53 Blink OK Exospace No in Win95

 

 
Powered by phpBB® Forum Software