www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/03/07:27:20

Date: Sat, 3 Aug 1996 07:24:36 -0400 (EDT)
From: patrick fox <web183 AT charweb DOT org>
To: kbaca AT skygames DOT com
cc: Hafiz Awang Pon <004277a AT dragon DOT acadiau DOT ca>, djgpp AT delorie DOT com
Subject: Re: inline assmebly problem
In-Reply-To: <199607311747.KAA27339@bluesky.com>
Message-ID: <Pine.SOL.3.91.960803072355.4125A-100000@wilbur>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019