diff options
author | Malfurious <m@lfurio.us> | 2024-02-25 11:54:53 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-02-25 11:54:53 -0500 |
commit | bb7ac5c3a4f50cb34db886034df2d693d8fe3ac2 (patch) | |
tree | 69eb25e14d473511b0e85d167305d64e202ab774 /docs | |
parent | f24146370e30e4eb247976cf50e7624d52db840f (diff) | |
download | lib-des-gnux-bb7ac5c3a4f50cb34db886034df2d693d8fe3ac2.tar.gz lib-des-gnux-bb7ac5c3a4f50cb34db886034df2d693d8fe3ac2.zip |
Add x86 loop instruction callout
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'docs')
-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. |