Using an array in embedded x86 assembly??

Posted by Mark V. on Stack Overflow See other posts from Stack Overflow or by Mark V.
Published on 2010-04-13T08:26:45Z Indexed on 2010/04/13 8:33 UTC
Read the original article Hit count: 355

Filed under:
|
|
|

Hey all

I have a method (C++) that returns a character and takes an array of characters as its parameters.

I'm messing with assembly for the first time and just trying to return the first character of the array in the dl register. Here's what I have so far:

char returnFirstChar(char arrayOfLetters[])
{
 char max;

 __asm
 {
  push eax
      push ebx
       push ecx
     push edx
  mov dl, 0

  mov eax, arrayOfLetters[0]
  xor edx, edx
  mov dl, al

  mov max, dl       
  pop edx
  pop ecx
  pop ebx
  pop eax

 }

 return max;
}

For some reason this method returns a ?

Any idea whats going on? Thanks

© Stack Overflow or respective owner

Related posts about x86

Related posts about assembly