www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/31/13:54:26

Message-Id: <199607311747.KAA27339@bluesky.com>
Comments: Authenticated sender is <kbaca AT bluesky>
From: kbaca AT skygames DOT com
To: 004277a AT dragon DOT acadiau DOT ca (Hafiz Awang Pon)
Date: Wed, 31 Jul 1996 10:49:59 +0000
MIME-Version: 1.0
Subject: Re: inline assmebly problem
CC: djgpp AT delorie DOT com

[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

- Raw text -


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