mercredi 2 décembre 2015

How to write a while loop\if statement with assembly language in C program?

I am trying to write a program to read a sentence and count the number of uppercase letters.

Specifically I am trying to convert the c code shown below into assembly language:

scanf("%c", &L );
while(L !='\n')
 {
  if(L>='A' && L<='Z')
    V++;
  scanf("%c", &L);
}

Here is my code for assembly :

  _asm
    {
    call read
    mov V, 0;
    while:  cmp L, '\n'
    je  exit,loop
    cmp L, 'A'
    jl cont
    cmp L, 'Z'
    jg cont
    inc V
    cont: call read
      jmp while
      exit: jmp
}

However this code does not run successfully as I keep getting an error message stating :Warning C4405: 'loop' : identifier is reserved word. Sorry for any coding mistakes,I am new to assembly language. Any help or suggestions would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire