Compile how to merge two 8-bit data into one 16-bit a7b7a6b6a5b5. A0b0)?

assemble how to merge two 8-bit data into one 16-bit a7b7a6b6a5b5. A0b0)?

Asm
Jul.17,2021

short foo(char a_8,char b_8) {
    short a_16=a_8,b_16=b_8;
    short a=0,b=0,result;
    for(short i=0,mask=1;i<8;iPP){
        a+=(a_16&mask)<<i;
        b+=(b_16&mask)<<i;
        printf("%d,%d\n",a_16&mask,a_16);
        mask<<=1;
    }
    result=a<<1+b;
    return result;
}

gcc

foo(char, char):
        push    rbp
        mov     rbp, rsp
        mov     eax, edi
        mov     edx, esi
        mov     BYTE PTR [rbp-20], al
        mov     eax, edx
        mov     BYTE PTR [rbp-24], al
        movsx   ax, BYTE PTR [rbp-20]
        mov     WORD PTR [rbp-10], ax
        movsx   ax, BYTE PTR [rbp-24]
        mov     WORD PTR [rbp-12], ax
        mov     WORD PTR [rbp-2], 0
        mov     WORD PTR [rbp-4], 0
        mov     WORD PTR [rbp-6], 0
        mov     WORD PTR [rbp-8], 1
.L3:
        cmp     WORD PTR [rbp-6], 7
        jg      .L2
        movzx   eax, WORD PTR [rbp-10]
        and     ax, WORD PTR [rbp-8]
        movsx   edx, ax
        movsx   eax, WORD PTR [rbp-6]
        mov     ecx, eax
        sal     edx, cl
        mov     eax, edx
        mov     edx, eax
        movzx   eax, WORD PTR [rbp-2]
        add     eax, edx
        mov     WORD PTR [rbp-2], ax
        movzx   eax, WORD PTR [rbp-12]
        and     ax, WORD PTR [rbp-8]
        movsx   edx, ax
        movsx   eax, WORD PTR [rbp-6]
        mov     ecx, eax
        sal     edx, cl
        mov     eax, edx
        mov     edx, eax
        movzx   eax, WORD PTR [rbp-4]
        add     eax, edx
        mov     WORD PTR [rbp-4], ax
        movsx   eax, WORD PTR [rbp-8]
        add     eax, eax
        mov     WORD PTR [rbp-8], ax
        movzx   eax, WORD PTR [rbp-6]
        add     eax, 1
        mov     WORD PTR [rbp-6], ax
        jmp     .L3
.L2:
        movsx   edx, WORD PTR [rbp-2]
        movsx   eax, WORD PTR [rbp-4]
        add     eax, 1
        mov     ecx, eax
        sal     edx, cl
        mov     eax, edx
        mov     WORD PTR [rbp-14], ax
        movzx   eax, WORD PTR [rbp-14]
        pop     rbp
        ret

clang

foo(char, char):                               -sharp @foo(char, char)
        push    rbp
        mov     rbp, rsp
        mov     al, sil
        mov     cl, dil
        mov     byte ptr [rbp - 1], cl
        mov     byte ptr [rbp - 2], al
        movsx   esi, byte ptr [rbp - 1]
        mov     dx, si
        mov     word ptr [rbp - 4], dx
        movsx   esi, byte ptr [rbp - 2]
        mov     dx, si
        mov     word ptr [rbp - 6], dx
        mov     word ptr [rbp - 8], 0
        mov     word ptr [rbp - 10], 0
        mov     word ptr [rbp - 14], 0
        mov     word ptr [rbp - 16], 1
.LBB0_1:                                -sharp =>This Inner Loop Header: Depth=1
        movsx   eax, word ptr [rbp - 14]
        cmp     eax, 8
        jge     .LBB0_4
        movsx   eax, word ptr [rbp - 4]
        movsx   ecx, word ptr [rbp - 16]
        and     eax, ecx
        movsx   ecx, word ptr [rbp - 14]
        shl     eax, cl
        movsx   edx, word ptr [rbp - 8]
        add     edx, eax
        mov     si, dx
        mov     word ptr [rbp - 8], si
        movsx   eax, word ptr [rbp - 6]
        movsx   edx, word ptr [rbp - 16]
        and     eax, edx
        movsx   ecx, word ptr [rbp - 14]
        shl     eax, cl
        movsx   edx, word ptr [rbp - 10]
        add     edx, eax
        mov     si, dx
        mov     word ptr [rbp - 10], si
        movsx   eax, word ptr [rbp - 16]
        shl     eax, 1
        mov     si, ax
        mov     word ptr [rbp - 16], si
        mov     ax, word ptr [rbp - 14]
        add     ax, 1
        mov     word ptr [rbp - 14], ax
        jmp     .LBB0_1
.LBB0_4:
        movsx   eax, word ptr [rbp - 8]
        movsx   ecx, word ptr [rbp - 10]
        add     ecx, 1
        shl     eax, cl
        mov     dx, ax
        mov     word ptr [rbp - 12], dx
        movsx   eax, word ptr [rbp - 12]
        pop     rbp
        ret
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47a76-4397a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47a76-4397a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?