The fastest way to fill memory
•STOSD instruction
•
1.Stores a dword value from EAX into memory location the address of which is in EDI (“D” - destination).
2.After the value from EAX is transferred it increments EDI by 4 (EDI now points to the next DWORD in memory) if DF flag is 0.
• If DF flag is 1 then EDI value decremented by 4 (EDI now points to the previous DWORD in memory)
•
•REP prefix
•
•Causes the next instruction to be repeated until the count in ECX register is decremented to 0
•
•Example: zeroing “all memory” (will trap because of access violation)
•
•XOR EAX,EAX  ; fill with 0
•MOV EDI, 0       ; starting address, XOR EDI, EDI
•MOV ECX, 0xFFFFFFFF / 4  ; 0x3FFFFFFF dwords
•REP STOSD