Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         .att_syntax     noprefix
  2.         .text
  3.         .global main
  4.  
  5. main:
  6.         call    readi32
  7.         jc      out
  8.        
  9.         mov     eax, edx
  10.         add     edx, NumberSum
  11.         jno     main
  12.  
  13.         mov     NumberSum, eax
  14.         mov     $1073741824, edx        // mask to detect first bit
  15.         and     NumberSum, edx
  16.         sar     $30, edx
  17.         mov     edx, ebx
  18.         xor     $1, ebx
  19.  
  20.         mov     edx, eax
  21.         mov     $2147483647, ecx
  22.         imul    ecx
  23.         mov     eax, IntHighOverflow
  24.        
  25.         mov     ebx, eax
  26.         mov     $-2147483648, ecx
  27.         imul    ecx
  28.         mov     eax, IntLowOverflow
  29.        
  30.         xor     eax, eax
  31.         add     IntHighOverflow, eax
  32.         add     IntLowOverflow, eax
  33.  
  34.         call    writei32
  35.         call    nl
  36.         call    finish
  37.  
  38. out:
  39.         mov     NumberSum, eax
  40.         call    writei32
  41.         call    nl
  42.         call    finish
  43.  
  44.         .data
  45. NumberSum:
  46.         .int    0
  47. IntLowOverflow:
  48.         .int    0
  49. IntHighOverflow:
  50.         .int    0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement