Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C:
- #include <stdio.h>
- char * kodowanie(void *cos, int n);
- int main() {
- int znaki[] = { 2045122341 };
- int n = 10;
- char *zakodowane = kodowanie(znaki, 7);// jak 7 na 8 sie zmieni to bierze wszystko ze znakow { 8*4 bity - jedna liczba }
- return 0;
- }
- //assembler:
- .686
- .model flat
- public _kodowanie
- extern _malloc : PROC
- .data
- znaki db 'ABCDEFGHIJKLMNOP'
- .code
- _kodowanie PROC
- push ebp
- mov ebp, esp
- mov esi, [ebp+8]
- mov ecx, [ebp+12]
- mov eax, ecx
- push ecx
- inc eax
- push eax
- call _malloc
- add esp, 4
- pop ecx
- mov edi, eax
- mov edx, OFFSET znaki
- xor eax, eax
- shr ecx, 1
- jnc dalej
- mov al, byte ptr[esi+ecx]
- shl ecx, 1
- and al, 0F0h
- shr al, 4
- mov bl, [edx+eax]
- mov [edi+ecx], bl
- mov [edi+ecx+1], byte ptr 0
- shr ecx, 1
- dec ecx
- jmp petla
- dalej:
- shl ecx, 1
- mov [edi+ecx], byte ptr 0
- shr ecx, 1
- dec ecx
- petla:
- push eax
- mov al, byte ptr[esi+ecx]
- shl ecx, 1
- and al, 0F0h
- shr al, 4
- mov bl, [edx+eax]
- mov [edi+ecx], bl
- shr ecx, 1
- pop eax
- mov al, byte ptr[esi+ecx]
- shl ecx, 1
- and al, 0Fh
- mov bl, [edx+eax]
- mov [edi+ecx+1], bl
- shr ecx, 1
- dec ecx
- cmp ecx, -1
- jne petla
- mov eax, edi
- pop ebp
- ret
- _kodowanie ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement