我试图在字符串数组中找到字符串的索引.我知道数组的基地址,现在我想做的事情如下所示:
但是,我对如何将EDI寄存器指向我正在搜索的字符串感到困惑?
int main(int argc, char *argv[])
{
char entry[]="apple";
__asm
{
mov esi, entry
mov edi, [ebx] //ebx has base address of the array
Run Code Online (Sandbox Code Playgroud)
等等.
那么,将我的esi寄存器指向我正在搜索的字符串的正确方法是什么?
我在Win XP SP3上使用Visual Studio C++ Express Edition 2010进行编程.
Visual C++编译器允许您直接在汇编代码中使用变量.示例来自:http://msdn.microsoft.com/en-us/library/y8b57x4b(v=vs.80).aspx
// InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
// processor: x86
#include <stdio.h>
char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
int main( void )
{
__asm
{
mov eax, offset world
push eax
mov eax, offset hello
push eax
mov eax, offset format
push eax
call printf
//clean up the stack so that main can exit cleanly
//use the unused register ebx to do the cleanup
pop ebx
pop ebx
pop ebx
}
}
Run Code Online (Sandbox Code Playgroud)
它没有比这更容易,IMO.你可以获得所有的速度,而不必费力地找出变量存储的位置.
| 归档时间: |
|
| 查看次数: |
3561 次 |
| 最近记录: |