Answers for "summation of odd and even in assembly"

0

summation of odd and even in assembly

...
mov cx, 9               ; Count downward from 9 to 1
xor ax, ax              ; sum of even numbers
xor bx, bx              ; sum of odd numbers

l1:                     ; Entry point for the loop
test cx, 1              ; Is CX even?
jz l2                   ; Yes -> jump to the label l2
add bx, cx
jmp l3                  ; Skip the following instruction for even numbers
l2:
add ax, cx
l3:
loop l1                 ; Repeat until CX becomes 0
...
Posted by: Guest on April-21-2021

Browse Popular Code Answers by Language