I am tasked to write a GNU assembly program using Intel syntax which counts numbers in array which are <= 6
I came up with the following code:
.intel_syntax noprefix
.data
n: .word 5
a: .word 1, 6, 7, 4, 8
r: .word 0
.text
.global main
main:
mov cx, n
mov al, 0
mov eax, 0
l1: cmpw [a+eax*2], 6
ja l2
inc al
l2: inc eax
loop l1
mov r, al
ret
However while debugging it with GDB it seems to output 8 to variable r
which is incorrect for given data.