This is only my first week of learning assmebly language and I am trying to write a program that counts from the value in eax to the value in ebx.
This is my code so far. From what I understand I am making room for two long values in the x section and room for the sum of the count. Than I insert 5 into eax and 10 into ebx and the value of x which will be count into ecx. I than compare eax to ebx and increment eax and jump if not zero. Once the count is zero I move ecx into the sum.
But when I run the program when I print sum I get 0 or some other number. The number I'm excepting is 5 since 5 to 10 is 5.
Any ideas?
.data # The data section
x:
    .long 1
    .long 2
sum:
    .long 0
.text # The text section
.globl _start
_start:
    movl $5, %eax
    movl $10, %ebx
    movl $x, %ecx
top:
    cmpl %eax, %ebx
    incl %eax
    jnz top
done:
    movl %ecx, sum
 
    