将 c++ for 循环更改为 x86

Changing c++ for loop into x86

本文关键字:x86 循环 c++ for      更新时间:2023-10-16

目前我正在学习 x86 汇编作为我的 uni 模块之一,我有一个用 C++ 编写的程序,它采用 6 个字符的字符串并根据加密密钥对其进行加密。

encrypt_chars的代码:

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
            push ecx
            lea eax, EKey
            push temp_char
            push eax
            call encrypt21
            mov temp_char, al
            add esp, 8
            pop ecx
            pop eax
        }
    EChars[i] = temp_char;          // Store encrypted char in the encrypted chars array
    }
return;
}

我希望得到一些关于如何将代码顶部的 for 循环更改为汇编语言的帮助,谢谢。

阅读有关 jmp 和读取变量并保存到寄存器的信息。我会给你举个例子,你可以阅读像 var(,%esi,4) 这样的变量,其中 var 是 yor 变量的名称,esi 是递增寄存器,4 是你的单词有多长。查看英特尔文档