inline assembly 
Author Message
 inline assembly

I am a beginner.
I made a simple inline assembly program.

------------------------------------------------------
#include <stdio.h>

void func(int d[10]);

void main()
{
    int i;
    int d[10];

    func(b);

    for( i = 0 ; i < 10 ; i++){
        printf("d[%d] = %d \n", i, d[i] );
    }

Quote:
}

void func(int d[10])
{
    asm("movl $0, %1      ;
         movl $9, %%eax   ;
         movl (%0), %%edx ;
         addl $36, %%edx  ;
    LOOP:
         movl %1, (%0)    ;
         incl %1          ;
         subl $4, %%edx   ;
         decl %%eax       :
         ins  LOOP  ;"
         : "=&r"(d)
         : "r"(i)
         : "%edx", "%eax" );

Quote:
}

-------------------------------------------
This program don't work.
I acknowledge func() is bad, but I don't know where is bad point.
I would like to ask why this program don't work.
And please show me how I mend in this program.
Regards.


Mon, 04 Jul 2005 12:54:07 GMT  
 inline assembly

Quote:

> #include <stdio.h>

> void func(int d[10]);

> void main()

bad bad bad bad bad.
main returns int (except exceptions that most people never meet).

Quote:
> {
>     int i;
>     int d[10];

>     func(b);

b?
d surely.

Quote:
>     for( i = 0 ; i < 10 ; i++){
>         printf("d[%d] = %d \n", i, d[i] );
>     }
> }

> void func(int d[10])
> {
>     asm("movl $0, %1      ;
>          movl $9, %%eax   ;
>          movl (%0), %%edx ;
>          addl $36, %%edx  ;
>     LOOP:
>          movl %1, (%0)    ;
>          incl %1          ;
>          subl $4, %%edx   ;
>          decl %%eax       :

:?
And no, that's not a smiley!

Quote:
>          ins  LOOP  ;"

ins?
jns?

Quote:
>          : "=&r"(d)
>          : "r"(i)

i?
No such variable. Did you mean to pass i to func?

Quote:
>          : "%edx", "%eax" );

> }

I can get it to build with my modifiations, but whether it does what yo
uwanted it to do is another question, as you've not told us what you
wanted it to do.

Phil



Mon, 04 Jul 2005 14:05:51 GMT  
 
 [ 2 post ] 

 Relevant Pages 

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

2. Pragma and inline assembly

3. inline assembly language, please help!!!

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

5. PB DOS inline assembly

6. Pragma and inline assembly

7. Pragma and inline assembly

8. Pragma and inline assembly

9. Pragma and inline assembly

10. Inline assembly conversion

11. Inline assembly

12. inline assembly (gcc) on linux x86

 

 
Powered by phpBB® Forum Software