summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-06-06 10:51:20 +1200
committerArslaan Pathan <[email protected]>2026-06-06 10:51:20 +1200
commit2bb4f7e34806054fa15174b2586241c2b82e040c (patch)
treece47a57a0343a81870ad336ebdb608f86afa40b1
parentd02fff2ba2faede9e68661a398b44ca2a7e14f17 (diff)
downloadx86-asm-2bb4f7e34806054fa15174b2586241c2b82e040c.tar.xz
x86-asm-2bb4f7e34806054fa15174b2586241c2b82e040c.zip
Basic loops testHEADmain
-rw-r--r--main.asm19
1 files changed, 7 insertions, 12 deletions
diff --git a/main.asm b/main.asm
index 7d824c1..f0b6221 100644
--- a/main.asm
+++ b/main.asm
@@ -1,17 +1,12 @@
global _start
-section .data ; defines a section
- msg db "Hello, x86 Assembly Language!", 0x0a
- len equ $ - msg ; subtract the location before the message (msg) from the location after the message ($) to get the length
-
section .text
_start:
- mov eax, 4 ; sys_write syscall
- mov ebx, 1 ; stdout file descriptor
- mov ecx, msg ; bytes to write
- mov edx, len ; number of bytes to write
- int 0x80 ; perform syscall
+ mov ebx, 1 ; start at 1
+ mov ecx, 4 ; num iterations
+label:
+ add ebx, ebx ; ebx += ebx
+ dec ecx ; ecx -= 1
+ cmp ecx, 0 ; compare ecx with 0
+ jg label ; jump if greater than label
- mov eax, 1 ; sys_exit syscall
- mov ebx, 0 ; exit status 0
- int 0x80 ; perform syscall