Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't correctly update pointer for rep stos for dynamic direction #925

Open
rfalke opened this issue Jul 31, 2020 · 1 comment
Open

Doesn't correctly update pointer for rep stos for dynamic direction #925

rfalke opened this issue Jul 31, 2020 · 1 comment

Comments

@rfalke
Copy link

rfalke commented Jul 31, 2020

Subject: https://github.com/rfalke/decompiler-subjects/tree/master/from_holdec/i386_memset_rep_stos/ia32_elf

Output:

void i386_memset_both_b(byte * dwArg04, byte bArg08, word32 dwArg0C, word32 dwArg10)
{
	byte * edi_18 = dwArg04;
	byte al_36 = (byte) (word32) bArg08;
	word32 ecx_20;
	for (ecx_20 = dwArg0C; ecx_20 != 0x00; --ecx_20)
	{
		*edi_18 = al_36;
		++edi_18;
	}
}

Assembler:

i386_memset_both_b proc
        push    ebx
        push    edi
        mov     eax,[esp+18]
        test    eax,eax
        cld
        jz      0804966C

l0804966B:
        std

l0804966C:
        mov     edi,[esp+0C]
        movzx   eax,byte ptr [esp+10]
        mov     ecx,[esp+14]

l08049679:
        rep stosb

l0804967B:
        pop     edi
        pop     ebx
        xor     eax,eax
        ret

The direction is controlled by the 4th parameter (dwArg10) which reko doesn't use.

The edi_18 update should be something like edi_18 = edi_18 + (dwArg10!=0?-1:1).

@rfalke
Copy link
Author

rfalke commented Aug 26, 2023

Still an issue in version 0.11.4.0-931ca7d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant