Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6703375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:09:50+00:00 2026-05-26T07:09:50+00:00

I been debugging REP STOS DWORD PTR ES:[EDI] for a while now From my

  • 0

I been debugging REP STOS DWORD PTR ES:[EDI] for a while now

From my conclusion it always uses

ECX as counter.
EAX as the value that will be copied over EDI and then appended ECX times
so after putting in the pointed dump of EDI

it seems to overwrite the pointed data at EDI with what’s
it seems it always only uses ECX as a counter, while changing EDI by 4 bytes.
it stops working when counter hits 0

So I came up with this kind of code

while(regs.d.ecx != 0)
{
    *(unsigned int *)(regs.d.edi) = regs.d.eax;
    regs.d.edi += 4;
    regs.d.ecx--;
}

Seems to work.. but i’m concerned since I just did this by luck and guess work. Is it solid? like will it always be ECX as counter, EAX as data, and it always copies 4 bytes never less?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:09:50+00:00Added an answer on May 26, 2026 at 7:09 am

    You are almost correct. The only difference is that the direction flag (DF) controls whether 4 is added or subtracted from EDI (and it actually is offset from the ES segment base, but you probably don’t care about that):

    for (; regs.d.ecx != 0; regs.d.ecx--)
    {
        *(unsigned int *)(regs.d.edi) = regs.d.eax;
        regs.d.edi += regs.eflags.df ? -4 : 4;
    }
    

    Note that the for (; regs.d.ecx != 0; regs.d.ecx--) { } is the action of the REP prefix, and the body of the loop is the action of STOS DWORD....

    Since you are asking a lot of these questions, I think you will find the Intel 64 and IA-32 Architectures Software Developer’s Manual, Volumes 2A and 2B to be useful. These contain descriptions of each instruction and prefix, including pseudo-code descriptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been getting an error recently while debugging an ASP.NET application in Visual Studio
Been using PHP/MySQL for a little while now, and I'm wondering if there are
We've been debugging this JBoss server problem for quite a while. After about 10
I've been experiencing nasty lockups while debugging under VS2008, SP1 on my machine. I
Been debugging for a while... Help? Yes, I know what caused it, but idk
I have been debugging the infamous EXC_BAD_ACCESS error for a few days now. NSZombieEnabled
We have been debugging a strange case for some days now, and have somewhat
I have been debugging this for awhile now, and I'm hoping someone could shed
I've been debugging this one application for a while and it led me to
I have been debugging my code for a while and looking at posts in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.