Mail Archives: djgpp/1996/08/03/07:27:20
On Wed, 31 Jul 1996 kbaca AT skygames DOT com wrote:
> [snip...]
> > here is the code below
> >
> > asm ("movw %0,%%cx":: "g" (x1):"%cx");
> > asm ("movw %0,%%dx":: "g" (x2):"%dx");
> > asm ("movl %0,%%esi":: "g" (&(arrvstep[x1])):"%esi");
> > asm ("movl %0,%%eax":: "g" (vstep):"%eax");
> > asm ("movl %0,%%ebx":: "g" (vvar):"%ebx");
> > asm ("prc1: movl %eax, (%esi)");
> > asm ("addl $0x4, %edi");
> > asm ("addl %ebx, %eax");
> > asm ("inc %cx");
> > asm ("cmp %dx, %cx");
> > asm ("jbe prc1");
> >
> > the problem i'm encoutering is that the value inside the
> > array is not what i expected. After putting some test
> > variables into the program, I suspect some values
> > in the registers has been altered not in the manner
> > dictated by my code above. can someone help?
> >
> > 004277a AT dragon DOT acadiau DOT ca
>
> I didn't study your code for correctness, but yes it is true that the
> compiler may modify registers between asm statements. To circumvent
> this put the whole group of assembly instructions inside one asm("")
> clause.
>
> -Kevin
>
You would probably want to put them inside __asm__ __volatile__ to keep
the compiler from messing them up.
-Pat
- Raw text -