I'm trying to loop 5 times and print "Hello World\n" for each loop. Regardless of whether I use jmp(jge, jle) and sub from ecx or use loopne, the loop either continues forever, or else not at all. I don't understand why the loop doesn't break when the counter reaches zero.
.intel_syntax noprefix
.globl main
.type main, @function
main:
endbr64
push rbp
mov ecx, 5 # set counter to 5
call looper
pop rbp
ret
.globl looper
.type looper, @function
looper:
lea rdi, str[rip] #load the string
call puts #print the string each loop
mov eax, ecx
cmp eax, 0
loopne looper # dec counter and loop if counter not zero
ret
str:
.string "Hello World\n"