I've been trying to decipher this piece of old 16-bit Windows code and I just can't get it. The code was originally written in C and shown here interpreted by SoftIce; I guess a loose form of Assembly. The code fragment below is a loop; that I do know; which was confirmed in the IDA dissasembler. My comments are shown within "/* */". Any insight on how to transform this back to C would be greatly appreciated.
Code:
sub ax ,ax /* clear AX AX=0000 */
mov [03DF], ax /* put 0 in global variable int [03DF] */
mov [bp-14], ax /* start loop for (bp-14 = 0; bp-14 >= 8; bp-14++) */
jmp 0752 /* takes the jump */
0752: cmp word ptr [bp-14], 08 /* bp-14 >= 8 part of "for" loop */
jge 0784 /* no jump jge tells me that [bp-14] is a "signed" int or "signed" word */
mov bx, [bp-14] /* not a clue since [bp-14] is an int and "bx" register usually refers to pointers */
shl bx, 02 /* bx*4 EBX=0000 */
add bx, [03D0] /* bx+[03D0] global variable int [03D0] is equal to 0 */
shl bx, 1 /* bx*2 */
push ds /* the up coming global variable [034E] is possibly a (char *)?? */
push word ptr [bx+034E] /* finished product for operand 1 for lstrcmpi...DS:034E=0222 */
lea ax, [bp-12] /* local variable char [bp-12] operand 2 for lstrcmpi */
push ss
push ax
call lstrcmpi
or ax, ax /* lstrcmpi statement must be conditional...maybe if (lstrcmpi(operand 1, operand 2) == 0) */
jnz 074F /* no jump BTW, AX=0000; EBX is still 0000 */
mov bx, [bp-14] /* again clueless since [bp-14] is an int */
shl bx, 03 /* bx*8 */
mov ax, [bx+0354] /* put [bx+0354] in AX...which BTW everything is equal to 0 */
mov [03DF] ax /* put AX in [03DF]....which BTW means zeros for everyone */