Mail Archives: djgpp/1998/06/11/19:34:38
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
- Raw text -