problems porting ms inline assembly codes to linux (gnu - AT&T syntax) 
Author Message
 problems porting ms inline assembly codes to linux (gnu - AT&T syntax)

hi, i m having a problem porting my ms inline assembly codes to linux
platform (using g++ compiler, gnu AT&T syntax).  i read through the A S S E
M B L Y   P R O G R A M M I N G   J O U R N A L
http://www.*-*-*.com/ , n i make some changes to my
previous ms inline assembly codes like changing "register" to "%register", n
"opcode destination, source" to "opcode source, destination".

however, i m still having a problem here which is to access the local
variables in a function.  Here is part of the ms inline assembly codes:

void initPermute(unsigned long *arg)
{
 unsigned long temparray[arraysize];
 unsigned long *temp = temparray;
 unsigned char *table = tInitPermute;

 _asm
 {
  ;Initializes temp.
  mov ecx, arraysize
  mov esi, temp
  mov eax, 00000000h

 loop_init:
  mov [esi], eax
  add esi, 00000004h
  loop loop_init

  mov ecx, 00000001h
  mov ebx, table
  mov esi, arg
  mov edi, temp

and here is the changed assembly codes to port to linux:

void initPermute(unsigned long *arg)
{
        unsigned long temparray[arraysize];
        unsigned long *temp = temparray;
        unsigned char *table = tInitPermute;

        __asm__
        (
                //Initializes temp.
                "movl arraysize, %ecx \n"
                "movl temp, %esi \n"
                "movl $0, %eax \n"

        "loop_init: \n"
                "movl %eax, (,%esi,) \n"
                "addl $4, %esi \n"
                "loop loop_init \n"

                "movl $1, %ecx \n"
                "movl table, %ebx \n"
                "movl arg, %esi \n"
                "movl temp, %edi \n"

and here is the assembly codes compiled by g++ (g++ -S filename):

.globl initPermute__FPUl

initPermute__FPUl:
.LFB1:
        pushl %ebp
.LCFI0:
        movl %esp,%ebp
.LCFI1:
        subl $16,%esp
.LCFI2:
        leal -8(%ebp),%eax
        movl %eax,-12(%ebp)
        movl $tInitPermute,-16(%ebp)
#APP
        movl arraysize, %ecx
        movl temp, %esi
        movl $0, %eax
        loop_init:
        movl %eax, (,%esi,)
        addl $4, %esi
        loop loop_init
        movl $1, %ecx
        movl table, %ebx
        movl arg, %esi
        movl temp, %edi

and here is the compiled errors:

/tmp/cca035041.o(.text+0x1b): undefined reference to `temp'
/tmp/cca035041.o(.text+0x37): undefined reference to `table'
/tmp/cca035041.o(.text+0x3d): undefined reference to `arg'
/tmp/cca035041.o(.text+0x43): undefined reference to `temp'
collect2: ld returned 1 exit status

as you can see here, arraysize is a global variable and there is no problem
referencing it in the assembly codes, however, i can't find a way to
reference the local variables like temp, table and the parameter passed to
the function, arg, in the assembly codes.  i know i can reference using ebp
n some displacements however the problem is if i change the global
arraysize, the data segment will change automatically when it compiled but
those that i use to reference in my assembly codes using ebp and etc will
not change but fix to what i specify at the first place, so it is not
flexible at all.

could anyone give me some hints of how to access the local variables?

i appreciate the help very much n thabk you in anticipation :)



Mon, 25 Jun 2001 03:00:00 GMT  
 problems porting ms inline assembly codes to linux (gnu - AT&T syntax)

Quote:
>hi, i m having a problem porting my ms inline assembly codes to linux
>platform (using g++ compiler, gnu AT&T syntax).  i read through the A S S E
>M B L Y   P R O G R A M M I N G   J O U R N A L
>http://asmjournal.freeservers.com/apj_2.txt, n i make some changes to my
>previous ms inline assembly codes like changing "register" to "%register", n
>"opcode destination, source" to "opcode source, destination".

Wow, you have linux ported to IBM/370.  And with inline assembly, too.

Quote:
>however, i m still having a problem here which is to access the local
>variables in a function.  Here is part of the ms inline assembly codes:
>void initPermute(unsigned long *arg)
>{
> unsigned long temparray[arraysize];
> unsigned long *temp = temparray;
> unsigned char *table = tInitPermute;
> _asm
> {
>  ;Initializes temp.
>  mov ecx, arraysize
>  mov esi, temp
>  mov eax, 00000000h

Hmm, this doesn't look right at all.

Now, is anyone interested in porting Linux, so we could do this with
ASM370 code.

-- glen



Mon, 25 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problem porting assembly codes from ms inline assembly to linux (gnu - AT&T syntax)

2. inline assembler error - porting Intel syntax to AT&T syntax

3. Assembly under Linux / AT&T syntax

4. Pentium RDTSC timer (+GNU inline assembly) CPUID crashes

5. inline assembly (gcc) on linux x86

6. How to convert this windows inline assembly to Linux

7. Help with optimizing newbie code (inline assembly under VC++ 6.0)

8. Help with optimizing newbie code (inline assembly under VC++ 6.0)

9. how to inline assembly code to visual c++

10. Converting Intel Masm to AT&T Gas, and inline assembly

11. inline assembly & BC++ compiler optimizations

12. Converting Intel Masm to AT&T Gas, and inline assembly

 

 
Powered by phpBB® Forum Software