Created
December 15, 2018 18:15
-
-
Save Eleobert/ef8ed23e78b882484f4672097cd59f82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section .bss | |
buf_in: RESB 32 ;input buffer | |
buf_out: RESB 32 ;output buffer | |
section .data | |
str: db "Введите строку: " | |
str_len: equ $-str | |
section .text | |
global _start | |
_start: | |
;print 'Введите строку: ' | |
mov eax, 4 | |
mov ebx, 1 | |
mov ecx, str | |
mov edx, str_len | |
int 80h | |
;Enter the string | |
mov eax, 3 | |
mov ebx, 2 | |
mov ecx, buf_in | |
mov edx, 32 | |
int 80h | |
mov esi, buf_in | |
mov eax, 0 | |
next_char: | |
mov bl, [esi] | |
cmp bl, 10 | |
je end_char | |
shl ax, 1 | |
cmp bl, '0' | |
jb inc_char | |
cmp bl, '9' | |
ja inc_char | |
or ax, 1 | |
inc_char: | |
inc esi | |
jmp next_char | |
end_char: | |
mov esi, buf_in | |
mov edi, buf_out + 31 | |
mov byte[edi], 10 | |
dec edi | |
next_bit: | |
mov bl, [esi] | |
cmp bl, 10 | |
je end_bit | |
mov cx, 1 | |
and cx, ax | |
mov byte [edi], '1' | |
cmp cx, 1 | |
je dont_put_zero | |
mov byte [edi], '0' | |
dont_put_zero: | |
dec edi | |
inc esi | |
shr ax, 1 | |
jmp next_bit | |
end_bit: | |
;show the result | |
mov eax, 4 | |
mov ebx, 1 | |
mov ecx, buf_out | |
mov edx, 32 | |
int 80h | |
mov eax, 1 | |
mov ebx, 0 | |
int 80h | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment