ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1225. Flags

Assembler in Pascal
Posted by Zinovij 1 Dec 2017 20:47
var
  n:Integer;
  r:cardinal;
begin
  read(n);
  asm
    xor eax,eax
    mov ebx,eax
    inc eax
    mov esi,eax
    mov edi,eax
    mov ecx,1 shl 5
    @@3:
     or ecx,ecx
     je @@1
      mov eax,ebx
      mul eax
      mov ebx,eax
      mov eax,esi
      mul eax
      add eax,ebx
      mov esi,eax
      mov eax,edi
      mul eax
      add eax,ebx
      mov edi,eax
      sub eax,esi
      mov ebx,eax
      test n,ecx
      je @@2
        add edi,ebx
        add ebx,esi
        mov esi,edi
        sub esi,ebx
      @@2:
      shr ecx,1
      jmp @@3
    @@1:
    mov eax,ebx
    shl eax,1
    mov r,eax
  end;
  write(r);
end.