diff options
Diffstat (limited to 'docs/re/arch_x86.txt')
-rw-r--r-- | docs/re/arch_x86.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/re/arch_x86.txt b/docs/re/arch_x86.txt index f1f2a03..85cf22f 100644 --- a/docs/re/arch_x86.txt +++ b/docs/re/arch_x86.txt @@ -150,3 +150,18 @@ for(i = 0x20; i != 0; i--) *buf_ptr = 0; buf_ptr++; ``` + + +LOOP instruction +---------------- +#from stack overflow: +#https://stackoverflow.com/questions/46881279/how-exactly-does-the-x86-loop-instruction-work + +LOOP is exactly like `dec ecx / jnz`, except it doesn't set flags. + +It's like the bottom of a `do {} while (--ecx != 0);` loop in C. If execution +enters the loop with ecx=0, wrap-around means the loop will run 2**32 times +(2**64 times in 64-bit mode). + +Unlike `rep movsb/stosb/etc`, it doesn't check for ecx=0 before decrementing, +only after. |