SHARE
TWEET

Untitled

a guest Apr 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. procedure main;
  2. var
  3.   a: array of Integer;
  4.   i, n, evenSum, oddSum: Integer;
  5. begin
  6.   write('Enter N: ');
  7.   readln(n);
  8.   setLength(a, n);
  9.   for i := 0 to n - 1 do
  10.     readln(a[i]);
  11.   asm
  12.           mov [oddSum], 0
  13.           mov [evenSum], 0
  14.           mov ebx, a
  15.           mov ecx, [n]
  16.     @main_cycle:
  17.           test [ebx], 1
  18.           mov eax, [ebx]
  19.           jne @eva
  20.           add [evenSum], eax
  21.           jmp @exit
  22.     @eva:
  23.           add [oddSum], eax
  24.     @exit:
  25.           add ebx, 4
  26.           loop @main_cycle
  27.   end;
  28.   writeln('Odd sum = ' + IntToStr(oddSum) + '; Even sum = ' + IntToStr(evenSum));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top