Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 12. More Instructions > The Fastest Way to Fill Memory

12.2. The Fastest Way to Fill Memory

This is done by STOSD instruction that stores a dword value from EAX into a memory location which address is in EDI register ("D" means destination). After the value from EAX is transferred to memory the instruction increments EDI by 4 and EDI register now points to the next DWORD in memory if DF flag is 0. If DF flag is 1 then EDI value is decremented by 4 and EDI now points to the previous DWORD in memory.

If we prefix any instruction with REP prefix it causes the instruction to be repeated until the value in ECX register is decremented to 0. For example we can write very simple code that should theoretically zero "all memory" (practically it will trap because of access violation):


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial