Я работаю над простой процедурой, которая перебирает список чисел и возвращает макс. Всегда возвращается 11, и я не вижу, что не так с моей логикой. Чтобы протестировать подпрограмму, у меня есть список чисел (data_items), по которым я зацикливаюсь. Что я здесь не так делаю?
.section .data
data_items: #these are the data items
.long 3,67,34,222,45,75,857,858,983,11,55,43,23,123,785,4356,0
.section .text
.globl _start
_start:
movl $0, %edi #move 0 into the index register
movl data_items(,%edi,4), %eax #load the first byte of data
movl %eax, %ebx #since this is the first item, %eax is the biggest
start_loop:
cmpl $0, %eax #check to see if we've hit the end
je loop_exit
incl %edi #load the next value
movl data_items(,%edi,4), %eax
cmpl %ebx, %eax #compare values
jle start_loop #jump to the start of the loop if the value is not larger
movl %eax, %ebx #move the value as the largest
jmp start_loop #jump to the loop beginning
loop_exit:
movl $1, %eax #1 is the exit() syscall
int $0x80