How do I convert this to assembly?

static unsigned char i, j, aResult[15]; /* Define Vars */
static const unsigned char aData[]={0xA0,0x1F,0xA5,0xB2,0x00} ; /* Define Data */
/* Initialize aResult array to all zeros */
for(i=0;i<15;i++){
aResult[i] = 0;
}
i=0; /* Set index for aData array */
while(aData[i] != 0){ /* While not EOS do */
if((aData[i]>= 0xA0) && (aData[i] <= 0xAF)) /* Check if between $A0 and $AF */
{ j = aData[i] ‐ 0xA0; /* if so, increment result array */
aResult[j]++;
}
i++; /* Look at next byte in aData array */
} /* End While loop */
/* Add SPIN Code here */

You didn't post a question.

Your compiler should have an "output to assembly" option; for GCC, this is "-S"

format PE GUI 4.0

include 'win32a.inc'

;Initialize aResult array to all zeros
        mov     ecx,15
        mov     edi,aResult
mIni:
        mov     byte [edi],0
        inc     edi
        loop    mIni

        mov     esi,aData;Set index for aData array
        mov     edi,aResult
mMain:
        cmp     byte [esi],0
        jne     mSkEx;While not EOS do
        jmp     mEx
mSkEx:

        cmp     byte [esi],0A0h;Check if between $A0 and $AF
        jl      mskA
        cmp     byte [esi],0AFh;Check if between $A0 and $AF
        jg      mskA
        mov     eax,0
        mov     al,[esi]
        sub     eax,0A0h;if so, increment result array
        add     edi,eax
        inc     byte [edi];Look at next byte in aData array
        sub     edi,eax
mskA:

        inc     esi
        jmp     mMain
mEx:

        invoke  ExitProcess,0

aResult db 15 dup (?);Define Vars
aData   db 0xA0,0x1F,0xA5,0xB2,0x00;Define Data

data import

        library kernel32,'KERNEL32.DLL'

        import  kernel32,\
                ExitProcess,'ExitProcess'

end data
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.