Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .data
- msg: db "Hello world!"
- len: equ $ - msg
- endl: db 0xA
- endlen: equ $ - endl
- section .text
- global _start
- print_endl:
- mov ecx, endl
- mov edx, endlen
- mov ebx, 1 ; Дескриптор вывода
- mov eax, 4 ; Системный call
- int 80h
- ret
- print:
- mov ebx, 1 ; Дескриптор вывода
- mov eax, 4 ; Системный call
- int 80h
- ret
- ;ключ, открытый текст, закрытый текст, длина
- crypt_func:
- .crypton:
- mov eax, ebx
- mov esi, msg
- mov edi, [esi]
- add [edi], eax
- mov edx, encrypted
- mov edx, [edi]
- inc edx
- inc esi
- loop crypton
- ret
- _start:
- ;заполнение массива Hello world'ом
- mov ecx, len
- mov ebx, encrypted ;адрес encrypted[0]
- mov eax, msg ;адрес msg[0]
- _adder:
- mov edx, [eax] ;через edx заполняет encrypted элементами из msg
- mov [ebx], edx
- inc eax ;pointer +=1
- inc ebx ;pointer +=1
- loop _adder
- ;вывыод заполненного массива
- mov ecx, encrypted
- mov edx, len
- call print
- ;endline (\n)
- call print_endl
- mov ecx, len
- mov ebx, encrypted
- _encrypt:
- add [ebx], byte 3
- inc ebx
- loop _encrypt
- ;вывод инкрипт массива
- mov ecx, encrypted
- mov edx, len
- call print
- ;endline (\n)
- call print_endl
- ;тут должен быть _reverse "строки"
- ;заполнение decrypted элементами encrypted
- mov ecx, len
- mov ebx, decrypted
- mov eax, encrypted
- _cryptadder:
- mov edx, [eax] ;через edx заполняет encrypted элементами из msg
- mov [ebx], edx
- inc eax ;pointer +=1
- inc ebx ;pointer +=1
- loop _cryptadder
- ;вывод декрипт массива
- mov ecx, decrypted
- mov edx, len
- call print
- ;endline (\n)
- call print_endl
- mov ecx, len
- mov ebx, decrypted
- _decrypt:
- sub [ebx], byte 3
- inc ebx
- loop _decrypt
- ;вывод декрипт массива
- mov ecx, decrypted
- mov edx, len
- call print
- ;endline (\n)
- call print_endl
- mov eax, 1
- int 0x80
- section .bss
- encrypted resb len
- decrypted resb len
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement