Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use a String in C   Inline Assembly code?
  2. int main(int argc, char *argv[])
  3. {
  4. char entry[]="apple";
  5. __asm
  6. {
  7. mov esi, entry
  8. mov edi, [ebx] //ebx has base address of the array
  9.        
  10. // InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
  11. // processor: x86
  12. #include <stdio.h>
  13.  
  14. char format[] = "%s %sn";
  15. char hello[] = "Hello";
  16. char world[] = "world";
  17. int main( void )
  18. {
  19.    __asm
  20.    {
  21.       mov  eax, offset world
  22.       push eax
  23.       mov  eax, offset hello
  24.       push eax
  25.       mov  eax, offset format
  26.       push eax
  27.       call printf
  28.       //clean up the stack so that main can exit cleanly
  29.       //use the unused register ebx to do the cleanup
  30.       pop  ebx
  31.       pop  ebx
  32.       pop  ebx
  33.    }
  34. }