L
L
lAtrey2014-07-15 01:53:56
Programming
lAtrey, 2014-07-15 01:53:56

How to get an element of a character array in assembler?

There is a code below. I want to count the number of brackets "(" and ")". And everything seems to be fine, but in this line

mov cl, [eax + esi];//помещаем значение А[esi] в cl

nothing good in cl moves, every time new nonsense. And I need to put in cl the value in array A with index esi, so that later I can compare it with the bracket code (after all, 28h and 29h are bracket codes?)
At the end, I’m already confused, what am I doing wrong? Help.
char *A = new char[100];
  strcpy(A, "1+2*(3-4)+(5*(6+7)-9)");
  char left = 0, right = 0;
  _asm{
  mov eax, A; //адрес А в eax


  mov esi, 0; //счетчик в 0
  mov al, 0;  //тут будем считать "(", код 28h
  mov ah, 0;  //а тут считать ")", код 29h
newiter:
  
  mov cl, [eax + esi];//помещаем значение А[esi] в cl ВОТ ТУТ ПРОБЛЕМА!!!
           
           
  cmp cl, 28h//сравниваем
  je m1;//если равны, то в m1
  cmp cl, 29h//сравниваем
  je m2;//если равны, то в m2
  cmp cl, 29h//снова сравниваем
  jne m3;//если не равны, то в m3


m1: 
  inc al;
  inc esi;
  cmp esi, 21;
  jne newiter;
m2:
  inc ah;
  inc esi;
  cmp esi, 21;
  jne newiter;
m3:
  inc esi;
  cmp esi, 21;
  jne newiter;

  mov left, al;
  mov right, ah;
         }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2014-07-15
@lAtrey

A question for filling - but are the registers AL, AH and EAX connected to each other?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question