SHARE
TWEET

asm_print the array

finalshare Jul 20th, 2017 (edited) 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void)
  4. {
  5.  
  6.     char printf_format[] = "Index = %d Value = %d\n";
  7.     int arrSize = 10;
  8.     int a[10] = {0,1,2,3,6,3,6,7,8,9};
  9.     int index = 0;
  10.  
  11.     _asm
  12.     {
  13.     mainEntry:
  14.         mov  eax, index
  15.         mov  ecx, 4
  16.         mul  ecx
  17.         mov  ecx,eax
  18.         lea eax, a
  19.         add eax, ecx
  20.  
  21.         push [eax]              //Push a[i]
  22.         lea eax, printf_format      //lay dia chi  "%d %d\n"
  23.         push index              //push index
  24.         push eax                // push xau "%d %d\n"
  25.         call printf             //call
  26.         add esp, 12               // push 3 lan nen phai dich stack len 4*3 =12 byte
  27.         inc index               //Tang chi so index
  28.         mov ecx,arrSize        
  29.         cmp index, ecx          //so sanh index voi arrSize
  30.         jb mainEntry
  31.     }
  32.     system("pause");
  33.     return 0;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top