tobjectpascal
asked on
BASM question
Hopefully Rlibby wont want to rip my head off for this one, he explained it and well i still don't get it..
var
s: String;
begin
s:='hello world';
asm
lea eax,s;
call uniquestring; //fine
mov eax,s;
call showmessage; //fine
end;
//example works.
procedure UniqueString(var S: string);
Following a call to SetString, S is guaranteed to reference a unique string; that is, a string with a reference count of one. For normal string handling, there is no need to ever call UniqueString. Only in cases where an application casts a string to a PChar and then modifies the contents of the string must UniqueString be used.
procedure ShowMessage(const Msg: string);
Description
Call ShowMessage to display a simple message box with an OK button. The Msg parameter is the message string that appears in the message box. The name of the application's executable file appears as the caption of the message box.
So, unique string requires a POINTER to the data where as show message requires the data....
now here's
lea eax,s;
call uniquestring; //fine
http://ymlitechat.com/leabasm.gif
mov eax,s;
call showmessage; //fine
http://ymlitechat.com/movbasm.gif
Now this is where i'm confused, I look up the address of Lea Eax,s; I was expecting to see the String but instead i don't see the String..
but now when i look up the address of Mov Eax,S; and i actually pin point it in memory, i actually find the data i'm looking for..
So if lea does not pass in the address, what exactly is it passing? look at the screenshots and you'll see my confusion..
is Lea Eax,Str;
the same as saying Eax:=@Str; ?
var
s: String;
begin
s:='hello world';
asm
lea eax,s;
call uniquestring; //fine
mov eax,s;
call showmessage; //fine
end;
//example works.
procedure UniqueString(var S: string);
Following a call to SetString, S is guaranteed to reference a unique string; that is, a string with a reference count of one. For normal string handling, there is no need to ever call UniqueString. Only in cases where an application casts a string to a PChar and then modifies the contents of the string must UniqueString be used.
procedure ShowMessage(const Msg: string);
Description
Call ShowMessage to display a simple message box with an OK button. The Msg parameter is the message string that appears in the message box. The name of the application's executable file appears as the caption of the message box.
So, unique string requires a POINTER to the data where as show message requires the data....
now here's
lea eax,s;
call uniquestring; //fine
http://ymlitechat.com/leabasm.gif
mov eax,s;
call showmessage; //fine
http://ymlitechat.com/movbasm.gif
Now this is where i'm confused, I look up the address of Lea Eax,s; I was expecting to see the String but instead i don't see the String..
but now when i look up the address of Mov Eax,S; and i actually pin point it in memory, i actually find the data i'm looking for..
So if lea does not pass in the address, what exactly is it passing? look at the screenshots and you'll see my confusion..
is Lea Eax,Str;
the same as saying Eax:=@Str; ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You know them plastic dogs with a stick and then a weighted head which when you press on it, it starts nodding.....
I'm similar to one of them right now... I get the jist of it, and i certainly understand what your saying, thank you again :)
I'm similar to one of them right now... I get the jist of it, and i certainly understand what your saying, thank you again :)
ASKER
OMG!!!!!
something just clicked, i understand perfectly..
ah, you end up passing the pointer of a pointer or a pointer address of where the pointer is sitting....
something just clicked, i understand perfectly..
ah, you end up passing the pointer of a pointer or a pointer address of where the pointer is sitting....
Sounds like you have it now, as I just heard the "click"... ;-)
Russell
var S: String;
begin
S:='Hello world';
ShowMessage(Format('Conten
ShowMessage(Format('Addres
end;