gitcat

Untitled

Jun 5th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. // ConsoleApplication4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdlib.h>
  6.  
  7.  
  8.  
  9.  
  10. int main()
  11. {
  12.     char *a = (char*)malloc(16);
  13.     char **b = (char**)calloc(15, sizeof(char*));
  14.     char i, k;
  15.     printf("Array A:\n");
  16.     for (i = 0; i < 16; i++) {
  17.         scanf("%hhd", a + i);
  18.     }
  19.     __asm {
  20.         mov esi, a; указатель на a
  21.         mov ebx, b; указатель на b
  22.         mov cl, 0; счетчик цикла
  23.         mov ch, 0; счетчик элементов b
  24.         l:
  25.         mov al, byte ptr [esi]
  26.         inc esi
  27.         mov ah, byte ptr [esi]
  28.         cmp al, ah
  29.         jne skip
  30.         dec esi
  31.         mov dword ptr [ebx], esi
  32.         inc esi
  33.         add ebx, 4
  34.         inc ch
  35.         skip:
  36.         inc cl
  37.         cmp cl, 15
  38.         jl l
  39.         mov k, ch
  40.     }
  41.     printf("\nArray B length: %hhd\n", k);
  42.     printf("\nArray B:\n");
  43.     for (i = 0; i < k; i++) {
  44.         printf("%x ", b[i]);
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment