Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create Looping in Assembly Language.asm

Abdul Wahab Junaid89b97f0abf3c
diff --git a/Assembly language/Question on Assembly Language/Looping in Assembly Language.asm b/Assembly language/Question on Assembly Language/Looping in Assembly Language.asm
new file mode 100644
index 0000000..8b2309c
--- /dev/null
+++ b/Assembly language/Question on Assembly Language/Looping in Assembly Language.asm
@@ -0,0 +1,36 @@
+section .data
+ count db 10 ; Initialize a variable 'count' with value 10
+
+section .text
+ global _start ; Entry point for the program
+
+_start:
+ mov ecx, count ; Load the value of 'count' into the ECX register
+ jmp loop_start ; Jump to the loop_start label
+
+loop_start:
+ ; Your loop instructions go here
+ ; For example, print a message
+ ; For simplicity, let's assume it prints a message and decrements count
+
+ ; Print a message
+ mov eax, 4 ; System call for 'write' (syscall number)
+ mov ebx, 1 ; File descriptor (stdout)
+ mov edx, 13 ; Message length
+ mov ecx, message ; Address of the message
+ int 0x80 ; Call kernel to perform write syscall
+
+ ; Decrement count
+ dec byte [count] ; Decrement the value stored in 'count'
+
+ ; Check if count is zero
+ cmp byte [count], 0 ; Compare 'count' with zero
+ jne loop_start ; If not zero, jump back to loop_start
+
+ ; Exit the program
+ mov eax, 1 ; System call for 'exit' (syscall number)
+ xor ebx, ebx ; Exit code 0
+ int 0x80 ; Call kernel to perform exit syscall
+
+section .data
+ message db 'Hello, World!', 0xA ; Message to be printed, followed by newline (0xA)