Advertisement
Guest User

NrTok

a guest
Jan 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int nrTok(char*);
  10. int main()
  11. {
  12.     char s[] = "cuv1      cuv2.cuv3,cuv4      .      ,     cuv5  CUV6";
  13.     cout << nrTok((char*)s);
  14.     return 0;
  15. }
  16.  
  17. int nrTok(char*)
  18. {
  19.     // ebx=sir de caractere
  20.     // ecx=i
  21.     // eax=nr cuv
  22.     // esi=un fel de bool care verifica daca ultimul element e separator sau nu (0 daca e, respectiv 1)
  23.     _asm {
  24.         mov ebx, [ebp + 8]
  25.         mov ecx, 0
  26.         mov esi, 0
  27.         mov eax, 0
  28.  
  29.         forInceput:
  30.         mov dl, [ebx + ecx]
  31.         cmp dl, 0
  32.         je forStop
  33.        
  34.         cmp dl,' '
  35.         je eSeparator
  36.         cmp dl,','
  37.         je eSeparator
  38.         cmp dl,'.'
  39.         je eSeparator
  40.  
  41.         //daca nu a sarit inseamna ca e litera -> verificam daca elem de pe poz anterioara e separator ptr a face eax++
  42.         cmp esi,0
  43.         jne sariPeste
  44.         inc eax
  45.         sariPeste:
  46.         mov esi,1
  47.         inc ecx
  48.         jmp forInceput
  49.  
  50.  
  51.         eSeparator:
  52.         mov esi,0
  53.         inc ecx
  54.         jmp forInceput
  55.  
  56.         forStop :
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement