Sender: nate AT cartsys DOT com Message-ID: <35806237.C2BEE6A0@cartsys.com> Date: Thu, 11 Jun 1998 16:03:19 -0700 From: Nate Eldredge MIME-Version: 1.0 To: Ian Chapman CC: djgpp AT delorie DOT com, Xavi Cardona Subject: Re: z80 to 386 References: <357D73EA DOT 73E0 AT rocketmail DOT com> <357FDA5C DOT A56E038A AT mailcity DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Ian Chapman wrote: > > Hi Xavi, > I use > > *** char asm[30] ={"movb whatever"}; *** > > and it assembles Regards Ian. Huh??? The documentation says nothing like this, and I can't make it work either. I think the original poster wanted some instructions assembled and placed in an array, and that doesn't do it. If you really have managed to do this, please post your exact code and GCC version. > Xavi Cardona wrote: > > > > Hi! > > I'm working on a Z80 to 80386 machine code translator. > > I make the following routine for putting the "movb $0x1,i" in the > > string variable, but it doesn't work. Gcc says "parse error before > > asm". > > As you see, I don't want to execute the movb instruccion. I just want to > > store the machine code of this instruccion on an array. > > main() > > {int i=5; > > char string[30]; /*more space than we really need*/ > > string=asm ("movb $0x1,%0" > > :"=g" (i) > > :"g" (i) ); > > } > > There is any easy :) way for doing this? > > Thanks in advanced. Well.... you could do something like this: asm(".data \n\t" "_string: \n\t" "movb $0x1, %0 \n\t" ".text" : "=g" (i) : "0" (i)); /* note change here; read docs for why it's needed */ But that would require that: * It be outside all functions, or in a function that cannot be inlined. * `i' be a global or static variable This would also not be useful for an assembler (which is basically what you are writing), because for any case other than a move of that exact value to the exact location at which `i' happens to reside, the code wouldn't work. -- Nate Eldredge nate AT cartsys DOT com