Created
September 19, 2024 17:44
-
-
Save YusufOzmen01/070611b911d7dd876393bf555b856673 to your computer and use it in GitHub Desktop.
x86_64 GCC Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main: | |
| push rbp ; Store the previous stack frame base pointer | |
| mov rbp, rsp ; Copy the current stack frame pointer to rbp | |
| mov DWORD PTR [rbp-4], 5 ; Store the value 5 (32 bit integer) | |
| loop: | |
| cmp DWORD PTR [rbp-4], 0 ; Compare the value we stored with 0 to see if we completed the loop | |
| je loop_exit ; Jump to the .loop_exit section of the code if we hit 0 | |
| sub DWORD PTR [rbp-4], 1 ; Subtract 1 from the counter | |
| jmp loop ; Jump to the loop beginning to repeat the cycle | |
| loop_exit: | |
| pop rbp ; Pop the pointer we stored | |
| ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment