汇编程序打包数据

Dmi*_*try 1 x86 assembly inline-assembly

我需要写一个用于在最小单元格内存中写入3个字母单词的置信码来说明这个图片,它说明了我需要的东西:

在此输入图像描述

我开始编写代码了:

    mov eax, dword ptr str[0]
    bsr cl, eax
    inc cl
    shl eax, cl
    push eax
    //
    mov eax, dword ptr str[1]
    pop ebx
    or eax, ebx
    push eax // unshifted
    //
    mov eax, dword ptr str[2]
    bsr cl, eax
    inc cl
    pop ebx
    shl ebx, cl
    or eax, ebx
    mov result, ebx
Run Code Online (Sandbox Code Playgroud)

但我得到-934608896(否定后
为00110111101101010000000000000000 )而不是1304526(0100111110011111001110)

Sep*_*and 5

结果是在EAX决赛之后or eax, ebx.
你为什么把EBX结果?这是你检查的错误值吗?

这是一个在同一寄存器中插入3位模式的代码:

movzx eax, byte ptr str[0]
movzx ebx, byte ptr str[1]
bsr   ecx, ebx
inc   ecx
shl   eax, cl
or    eax, ebx
movzx ebx, byte ptr str[2]
bsr   ecx, ebx
inc   ecx
shl   eax, cl
or    eax, ebx
mov   result, eax
Run Code Online (Sandbox Code Playgroud)