汇编中2到100之间的所有偶数之和

时间:2020-10-24 02:24:17

标签: assembly x86

%include "asm_io.inc"
;
; initialized data is put in the .data segment
;
segment .data


; uninitialized data is put in the .bss segment
;
segment .bss

;
; code is put in the .text segment
;
segment .text
        global  asm_main
asm_main:
        enter   0,0               ; setup routine
        pusha
; put your code below this comment.
        mov eax,2
        mov ecx,100

loop_start: add eax,ecx
            loop loop_start

loop_end: call print_int
          call print_nl


; don't delete anything following this comment
        popa
        mov     eax, 0            ; return back to C
        leave
        ret

请理解我是初学者哈哈。我知道如何找到2到100之间的所有数字的总和,但是我不确定如何只将2到100之间的偶数数字相加。答案应该是2550,但是我得到了将所有数字相加的答案。

0 个答案:

没有答案