请教一个delphi汇编的基本问题,谢谢(50分)

F

form2

Unregistered / Unconfirmed
GUEST, unregistred user!
如下:
const
ss='A';
.....
asm
.....
mov eax,[ss] <---我想把ss的地址给eax
// mov eax,dword ptr[ss]
.....
end;

上面是错误的,请问如何写才能正确?我在delphi帮助里面没有找到相关说明
 
//mov eax,@ss[1]
这样写不知道对否 总之 String[1]才是第一个字符 String[0]一般是毫无疑义的
 
这样行吗?
mov eax,offset [ss]
 
用变量,在我的印象中常量好像是编译期绑定的,即无法得到它的地址。
var
ss: string;
begin
ss := 'squall';
asm
mov eax, [ebp-4]
call showmessage
end;
end;
 
谢谢liuxi,看来const是没办法了
我的问题来源于下面的代码,当然我知道一行:
hWindow:=CreateWindowEx(0,AppName,AppName,WS_VISIBLE+WS_OVERLAPPED,MaxWH.Left,MaxWH.Top,MaxWH.Right,MaxWH.Bottom,0,0,HInstance,nil);
就能解决问题,可是我要在汇编状态中加入一些指令,以逃脱静态分析。。。。
[test code]
var
ss:string;
begin
ss:='123456';
asm
mov ebx, [eax]
........
push $00
mov eax,[HInstance]
push eax
push $00
push $00
mov eax,$100
push eax
push eax
push eax
push eax
push WS_VISIBLE+WS_OVERLAPPED//$90000000
push ebx
push ebx
push $00
mov eax,[CreateWindowEx]
// add eax,2
// mov ch,$30
// jmp eax
call eax
mov [hWindow],eax
end;
.....
end;

可是没有显示,但ss==#32[只能!],那么就能显示窗口,其他的字符将导致CreateWindowEx调用出错!
不知道是什么原因:(
 
要用变量
var
ss:char;
begin
ss:='A';
asm
lea eax,ss
end;
 
procedure TForm1.Button1Click(Sender: TObject);
const
S: String = 'Hello, World';
begin
asm
mov eax, S
push eax
call ShowMessage
add esp, 4
end
end;
 
顶部