assembler copy char[]
Daniel Keep
daniel.keep.lists at gmail.com
Thu Jun 7 03:41:39 PDT 2007
nobody wrote:
> Hello,
>
> i try copy mystring to st in assembler.
> Can someone give me an advice how to do this.
>
> import std.stdio;
> void main()
> {
> char[] mystring = "Hey Assembler\n";
> char[] st;
>
> asm
> {
> mov EAX, dword ptr [mystring+4];
> mov st,EAX;
> }
> writefln("st: ", st);
> }
>
> I get a Segmentation fault .
>
> Thanks
I have to wonder why on earth you're using assembly, and how you arrived
at the above code. From what I can tell, you're copying mystring's
length into st's *pointer* field, and then trying to print it.
You say you want to "copy" the string, but you could do it just as
easily like this:
st = mystring;
Why exactly are you doing this? I ask because I'm somewhat hesitant to
hand a bazooka to someone who seems to be having trouble working out
which end the rocket comes out of...
-- Daniel
More information about the Digitalmars-d-learn
mailing list