Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .bss
- n resd 1
- k resb 1
- r resb 1
- mask resd 1
- arr resd 1000000
- section .text
- global CMAIN
- CMAIN:
- GET_UDEC 4, [n] ; input
- xor ecx, ecx
- .while0:
- cmp ecx, dword[n]
- jae .break0
- GET_UDEC 4, [arr + 4 * ecx]
- inc ecx
- jmp .while0
- .break0:
- GET_UDEC 1, [k]
- mov cl, byte[k]
- mov dword[mask], 1
- shl dword[mask], cl
- dec dword[mask]
- mov al, 32
- sub al, byte[k]
- mov byte[r], al
- mov esi, dword[n]
- mov esi, dword[arr + 4 * esi - 4]
- and esi, dword[mask]
- mov ecx, dword[n]
- cmp ecx, 2
- jb .break1
- .while1:
- cmp ecx, 1
- je .break1
- mov al, byte[k]
- xchg eax, ecx
- shr dword[arr + 4 * eax - 4], cl
- xchg eax, ecx
- mov edx, dword[arr + 4 * ecx - 8]
- and edx, dword[mask]
- mov al, byte[r]
- xchg eax, ecx
- shl edx, cl
- xchg eax, ecx
- add dword[arr + 4 * ecx - 4], edx
- dec ecx
- jmp .while1
- .break1:
- mov cl, byte[k]
- shr dword[arr], cl
- mov cl, byte[r]
- shl esi, cl
- add dword[arr], esi
- xor ecx, ecx
- .while2:
- cmp ecx, dword[n]
- jae .break2
- PRINT_UDEC 4, [arr + 4 * ecx]
- PRINT_CHAR ' '
- inc ecx
- jmp .while2
- .break2:
- NEWLINE
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement