A
A
Arkady Sahakyan2022-03-11 19:16:17
assembler
Arkady Sahakyan, 2022-03-11 19:16:17

The sum of a sequence of numbers in assembler. Where is the mistake?

I wrote a program that was supposed to find the sum of a sequence of numbers, but it does not work correctly.
Can you tell me where is the mistake?

section .text
main:
  xor eax, eax
  xor ecx, ecx
  push 20
  call ssn
ssn:
  pop ecx
  L1:
    add eax, ecx
    loop L1
  ret

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2022-03-11
@freeExec

But the eax register contains some address

call ssn -> ложит адрес следующего оператора, куда возвращаться после выхода
ssn:
  pop ecx -> тут ты этот адрес и извлекаешь

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question