Advertisement
Guest User

Untitled

a guest
May 27th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2.  
  3. section .bss
  4.     n resd 1
  5.     k resb 1
  6.     r resb 1
  7.     mask resd 1
  8.     arr resd 1000000
  9.  
  10. section .text
  11. global CMAIN
  12. CMAIN:
  13.     GET_UDEC 4, [n] ; input
  14.     xor ecx, ecx
  15. .while0:
  16.     cmp ecx, dword[n]
  17.     jae .break0
  18.     GET_UDEC 4, [arr + 4 * ecx]
  19.     inc ecx
  20.     jmp .while0
  21. .break0:
  22.     GET_UDEC 1, [k]
  23.     mov cl, byte[k]
  24.     mov dword[mask], 1
  25.     shl dword[mask], cl
  26.     dec dword[mask]
  27.     mov al, 32
  28.     sub al, byte[k]
  29.     mov byte[r], al
  30.     mov esi, dword[n]
  31.     mov esi, dword[arr + 4 * esi - 4]
  32.     and esi, dword[mask]
  33.  
  34.     mov ecx, dword[n]
  35.     cmp ecx, 2
  36.     jb .break1
  37. .while1:
  38.     cmp ecx, 1
  39.     je .break1
  40.     mov al, byte[k]
  41.     xchg eax, ecx
  42.     shr dword[arr + 4 * eax - 4], cl
  43.     xchg eax, ecx
  44.     mov edx, dword[arr + 4 * ecx - 8]
  45.     and edx, dword[mask]
  46.     mov al, byte[r]
  47.     xchg eax, ecx
  48.     shl edx, cl
  49.     xchg eax, ecx
  50.     add dword[arr + 4 * ecx - 4], edx
  51.     dec ecx
  52.     jmp .while1
  53. .break1:
  54.  
  55.     mov cl, byte[k]
  56.     shr dword[arr], cl
  57.     mov cl, byte[r]
  58.     shl esi, cl
  59.     add dword[arr], esi
  60.  
  61.     xor ecx, ecx
  62. .while2:
  63.     cmp ecx, dword[n]
  64.     jae .break2
  65.     PRINT_UDEC 4, [arr + 4 * ecx]
  66.     PRINT_CHAR ' '
  67.     inc ecx
  68.     jmp .while2
  69. .break2:
  70.     NEWLINE
  71.     xor eax, eax
  72.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement