I'm currently learning Intel x86 Assembly, and I've run into a problem while trying to construct a simple loop, which loops 10 times. It's supposed to stop after the 10 loops, but it keeps going on and on, forever.
This is the code that I am using:
section .data
msg db "Hello, World!", 0x0a
len equ $-msg
section .text
global _start
_start:
mov cx, 10 ; loop counter
_loop_start:
mov ebx, 0x01
mov ecx, msg
mov edx, len
mov eax, 0x04
int 0x80
dec cx
cmp cx, 0
jge _loop_start
_done:
mov ebx, 0x00
mov eax, 0x01
int 0x80
Before attempting to write this code, I looked at this tutorial for doing simple arithmetic.
I compile it like so:
nasm -f elf64 test.s -o test.o
And link like this:
ld -s -o test_exec test.o
Thanks in advance, Anickyan