summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-02-25 11:54:53 -0500
committerMalfurious <m@lfurio.us>2024-02-25 11:54:53 -0500
commitbb7ac5c3a4f50cb34db886034df2d693d8fe3ac2 (patch)
tree69eb25e14d473511b0e85d167305d64e202ab774 /docs
parentf24146370e30e4eb247976cf50e7624d52db840f (diff)
downloadlib-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.txt15
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.