我试图在Visual Studio中的内联汇编程序中创建一个Base64Encode。Base64汇编程序填充数组错误“操作数大小不同”Visual Studio
我得到这个FUNC
char* Base64Encode(char* data, int len)
{
// Tabelle mit den Zeichen für die Codierung
const char* encodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/";
//
char* result;
if (len > 0) // sonst gibt es nichts zu tun ...
{
int encodedLength = ((len + 2)/3) * 4; // effektiv die Ganzzahlfassung von ceil(length/3)*4
result = new char[encodedLength+1]; // +1 wg. Null-Terminierung
_asm
{
mov esi,data
mov edi,encodeTable
xor eax, eax
// get 3 bytes
mov ah, byte ptr[esi]
mov al, byte ptr[esi+1]
shl eax,16
mov ah, byte ptr[esi+2]
//
mov edx,eax
shl eax,6
shr edx, 26
mov bl, byte ptr[edi + edx]
mov [result],bl
//
mov edx, eax
shl eax, 6
shr edx, 26
mov bl, byte ptr[edi + edx]
mov[result+1], bl
//manipulate in edx bitset3
mov edx, eax
shl eax, 6
shr edx, 26
mov bl, byte ptr[edi + edx]
mov[result+2], bl
//manipulate in edx bitset4
mov edx, eax
shl eax, 6
shr edx, 26
mov bl, byte ptr[edi + edx]
mov[result+3], bl
}
}
else
{
result = "";
}
return result;
}
的编码工作正确的,我在BL总是正确的字母,但输出不工作(结果数组不以字母填写,即时得到的错误,操作数具有不同的大小,我只允许在__asm函数中进行更改)。
有人能帮助我如何填写结果数组与我在BL中获得的字母?如果我注释掉所有结果行,调试总是会向我显示bl中的正确字母。
我得到什么结果数组时,我使用字节的PTR。
任何想法?
EDIT2:
是什么,通过汇编代码步进建议? http://stackoverflow.com/questions/14905769/step-through-an-assembly-language-program-one-statement-at-a-time –
不知道这是你的意思,在编辑2你看到有一个在BL中,在下一步它应该在结果数组中,但结果数组只是0'/ 0' – Alexxxx
不能这么难做一个base64编码在那__asm :( – Alexxxx