Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. // C:
  2.  
  3. #include <stdio.h>
  4. char * kodowanie(void *cos, int n);
  5. int main() {
  6. int znaki[] = { 2045122341 };
  7. int n = 10;
  8. char *zakodowane = kodowanie(znaki, 7);// jak 7 na 8 sie zmieni to bierze wszystko ze znakow { 8*4 bity - jedna liczba }
  9.  
  10.  
  11. return 0;
  12. }
  13.  
  14.  
  15. //assembler:
  16.  
  17. .686
  18. .model flat
  19.  
  20. public _kodowanie
  21. extern _malloc : PROC
  22.  
  23. .data
  24.  
  25. znaki db 'ABCDEFGHIJKLMNOP'
  26.  
  27. .code
  28.  
  29. _kodowanie PROC
  30.  
  31. push ebp
  32. mov ebp, esp
  33. mov esi, [ebp+8]
  34. mov ecx, [ebp+12]
  35.  
  36. mov eax, ecx
  37.  
  38.  
  39. push ecx
  40. inc eax
  41. push eax
  42. call _malloc
  43. add esp, 4
  44. pop ecx
  45. mov edi, eax
  46.  
  47. mov edx, OFFSET znaki
  48. xor eax, eax
  49.  
  50. shr ecx, 1
  51. jnc dalej
  52.  
  53. mov al, byte ptr[esi+ecx]
  54. shl ecx, 1
  55. and al, 0F0h
  56. shr al, 4
  57. mov bl, [edx+eax]
  58. mov [edi+ecx], bl
  59. mov [edi+ecx+1], byte ptr 0
  60. shr ecx, 1
  61. dec ecx
  62. jmp petla
  63.  
  64. dalej:
  65. shl ecx, 1
  66. mov [edi+ecx], byte ptr 0
  67. shr ecx, 1
  68. dec ecx
  69.  
  70. petla:
  71. push eax
  72. mov al, byte ptr[esi+ecx]
  73. shl ecx, 1
  74. and al, 0F0h
  75. shr al, 4
  76. mov bl, [edx+eax]
  77. mov [edi+ecx], bl
  78.  
  79. shr ecx, 1
  80. pop eax
  81.  
  82. mov al, byte ptr[esi+ecx]
  83. shl ecx, 1
  84. and al, 0Fh
  85. mov bl, [edx+eax]
  86. mov [edi+ecx+1], bl
  87.  
  88. shr ecx, 1
  89.  
  90. dec ecx
  91. cmp ecx, -1
  92. jne petla
  93.  
  94. mov eax, edi
  95. pop ebp
  96. ret
  97.  
  98. _kodowanie ENDP
  99. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement