Учитывая следующий код в ассемблере:
.section .rodata
input_format: .string "%d"
output_format: .string "%d\n"
.text
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
movl $0,%ebx # reset the sum register
movl $0,%esi # reset the counter of the numbers
movl $0,%eax # in order to know when to stop the loop
.loop:
addl $-8,%esp # moving down the stack
pushl %esp
pushl $input_format
call scanf # call scanf to get number from the user
addl $8,%esp
addl (%esp),%ebx # add the number to the total summary
movl (%esp),%ecx
addl $1,%esi # add 1 to the counter
pushl $output_format
call printf # print the given number
cmpl %ecx,%eax
jne .loop
# return from printf:
movl $0,%eax
movl %ebp,%esp
popl %ebp
ret
Я пытаюсь суммировать числа больше 0 в ebx
и в итоге вычислить их среднее значение, но по какой-то причине цикл не остановилсяЯ поставил «0» (0 предполагается, что это конец цикла).Где я ошибся?