C++ 如何在c++;到汇编程序?
我正在尝试将加密字符转换为汇编程序。我在for循环中已经有一些x86 in汇编,但是我正在尝试将过程的其余部分转换为汇编程序。如果你能帮助我,我将不胜感激C++ 如何在c++;到汇编程序?,c++,assembly,C++,Assembly,我正在尝试将加密字符转换为汇编程序。我在for循环中已经有一些x86 in汇编,但是我正在尝试将过程的其余部分转换为汇编程序。如果你能帮助我,我将不胜感激 void encrypt_chars (int length, char EKey) { char temp_char; // char temporary store for (int i = 0; i < length; i++) // encrypt charac
void encrypt_chars (int length, char EKey)
{ char temp_char; // char temporary store
for (int i = 0; i < length; i++) // encrypt characters one at a time
{
temp_char = OChars [i]; //
__asm { //
push eax // save register values on stack to be safe
push ecx //
//
movzx ecx,temp_char // set up registers (Nb this isn't StdCall or Cdecl)
lea eax,EKey //
call encrypt12 // encrypt the character
mov temp_char,al //
//
pop ecx // restore original register values from stack
pop eax //
}
EChars [i] = temp_char; // Store encrypted char in the encrypted chars array
}
void encrypt\u字符(int-length,char-EKey)
{char temp_char;//char临时存储
for(int i=0;i
接下来是转换为汇编程序的“for”语句的代码,寄存器EDI用作控制变量“i”,如果EDI被“encrypt21”更改,只需在“call encrypt21”之前推送它,然后在“call encrypt21”之后弹出它,以保留或恢复其值。我将参数“length”更改为“len”,因为名称给了我问题:
void encrypt_chars(int len, char EKey)
{ char temp_char;
__asm { mov edi, 0 ;FOR ( EDI = 0;
fori:
;GET CURRENT CHAR.
mov al, OChars[edi]
mov temp_char, al
;ENCRYPT CURRENT CHAR.
push eax // save register values on stack to be safe
push ecx
movzx ecx,temp_char // set up registers (Nb this isn't StdCall or Cdecl)
lea eax,EKey
call encrypt12 // encrypt the character
mov temp_char,al
pop ecx // restore original register values from stack
pop eax
;STORE ENCRYPTED CHAR.
mov al, temp_char
mov EChars[ edi ], al
;FOR STATEMENT : FOR ( EDI = 0; EDI < LEN, EDI++ )
inc edi ;EDI++.
cmp edi, len
jb fori ;IF ( EDI < LEN ) JUMP.
}
return;
}
void encrypt\u字符(int len,char EKey)
{char temp_char;
__asm{mov edi,0;FOR(edi=0;
福里:
;获取当前字符。
mov al,OChars[edi]
移动临时字符,al
;加密当前字符。
将eax//保存堆栈上的寄存器值以确保安全
推ecx
movzx ecx,temp_char//设置寄存器(注意,这不是StdCall或Cdecl)
lea eax,EKey
调用encrypt12//加密字符
移动临时字符,al
pop ecx//从堆栈还原原始寄存器值
波普eax
;存储加密字符。
移动,临时字符
mov EChars[edi],al
;FOR语句:FOR(EDI=0;EDI 最好的方法是用C++编译程序。C++,现在我使用VisualStudio。关于如何做的任何建议。@ Mikvin我问了一个不同的问题。我问如何把for循环转换成汇编程序。我的坏-我想,我知道我以前见过这个。如果我被评定为15,我会投票给你!谢谢哟!非常喜欢。我只是想知道为什么我的变量会被EDI控制?可以使用“I”,但EDI更像是“汇编程序”。