banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận hệ điều hành Windows Mã ASM do VS2010 sinh ra. :D  XML
  [Programming]   Mã ASM do VS2010 sinh ra. :D 13/04/2011 21:57:42 (+0700) | #1 | 235396
zjm_zjm
Member

[Minus]    0    [Plus]
Joined: 26/07/2009 01:53:09
Messages: 159
Location: hhhhhh
Offline
[Profile] [PM] [WWW] [Yahoo!] [MSN] [ICQ]
Mình có 1 bài C dịch ra ASM bằng VS2010, nhưng o hiểu 1 số đoạn, anh em giải thích dùm smilie

Code:
--- e:\microsoft visual studio 10.0\project\poiters\poiters\poiter2.cpp --------
#include <stdio.h>
#include <conio.h>
void main2()	{
00141650 55                   push        ebp  
00141651 8B EC                mov         ebp,esp  
00141653 81 EC CC 00 00 00    sub         esp,0CCh  
00141659 53                   push        ebx  
0014165A 56                   push        esi  
0014165B 57                   push        edi  
0014165C 8D BD 34 FF FF FF    lea         edi,[ebp-0CCh]  
00141662 B9 33 00 00 00       mov         ecx,33h  
00141667 B8 CC CC CC CC       mov         eax,0CCCCCCCCh  
0014166C F3 AB                rep stos    dword ptr es:[edi]  
	static int Array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	int i;
	for( i = 0 ; i < 10; i++)	{
0014166E C7 45 F8 00 00 00 00 mov         dword ptr [i],0  
[color=red]00141675 EB 09                jmp         main2+30h (141680h)[/color]
00141677 8B 45 F8             mov         eax,dword ptr [i]  
0014167A 83 C0 01             add         eax,1  
0014167D 89 45 F8             mov         dword ptr [i],eax  
00141680 83 7D F8 0A          cmp         dword ptr [i],0Ah  
00141684 7D 60                jge         main2+96h (1416E6h)  
printf("\n i = %d, Array[i] = %d, *(Array +i) = %d\t", i, Array[i], *(Array +i) );
00141686 8B F4                mov         esi,esp  
00141688 8B 45 F8             mov         eax,dword ptr [i]  
0014168B 8B 0C 85 00 90 14 00 mov         ecx,dword ptr Array (149000h)[eax*4]  
00141692 51                   push        ecx  
00141693 8B 55 F8             mov         edx,dword ptr [i]  
00141696 8B 04 95 00 90 14 00 mov         eax,dword ptr Array (149000h)[edx*4]  
0014169D 50                   push        eax  
0014169E 8B 4D F8             mov         ecx,dword ptr [i]  
001416A1 51                   push        ecx  
001416A2 68 00 68 14 00       push        offset string "\n i = %d, Array[i] = %d, *(Array"... (146800h)  
001416A7 FF 15 FC A2 14 00    call        dword ptr [__imp__printf (14A2FCh)]  
001416AD 83 C4 10             add         esp,10h  
001416B0 3B F4                cmp         esi,esp  
001416B2 E8 BB FA FF FF       call        @ILT+365(__RTC_CheckEsp) (141172h)  
		printf("&Array[i] = %X , Array + i = %X", &Array[i], Array + i);
001416B7 8B 45 F8             mov         eax,dword ptr [i]  
001416BA 8D 0C 85 00 90 14 00 lea         ecx,Array (149000h)[eax*4]  
001416C1 8B F4                mov         esi,esp  
001416C3 51                   push        ecx  
001416C4 8B 55 F8             mov         edx,dword ptr [i]  
001416C7 8D 04 95 00 90 14 00 lea         eax,Array (149000h)[edx*4]  
001416CE 50                   push        eax  
001416CF 68 D8 67 14 00       push        offset string "&Array[i] = %X , Array + i = %X" (1467D8h)  
001416D4 FF 15 FC A2 14 00    call        dword ptr [__imp__printf (14A2FCh)]  
001416DA 83 C4 0C             add         esp,0Ch  
001416DD 3B F4                cmp         esi,esp  
001416DF E8 8E FA FF FF       call        @ILT+365(__RTC_CheckEsp) (141172h)  

	}
001416E4 EB 91                jmp         main2+27h (141677h)  
	getch();
001416E6 8B F4                mov         esi,esp  
001416E8 FF 15 00 A3 14 00    call        dword ptr [__imp___getch (14A300h)]  
001416EE 3B F4                cmp         esi,esp  
001416F0 E8 7D FA FF FF       call        @ILT+365(__RTC_CheckEsp) (141172h)  
}
001416F5 5F                   pop         edi  
001416F6 5E                   pop         esi  
001416F7 5B                   pop         ebx  
001416F8 81 C4 CC 00 00 00    add         esp,0CCh  
001416FE 3B EC                cmp         ebp,esp  
00141700 E8 6D FA FF FF       call        @ILT+365(__RTC_CheckEsp) (141172h)  
00141705 8B E5                mov         esp,ebp  
00141707 5D                   pop         ebp  
00141708 C3                   ret

00141675 EB 09 jmp main2+30h
jmp main2+30h
cái dòng này mình o biết nó nhảy đến vị trí nào hết, 30h
ps Sao mình o bỏ được màu trong tab code vậy nhỉ.
[Up] [Print Copy]
  [Programming]   Mã ASM do VS2010 sinh ra. :D 14/04/2011 06:03:18 (+0700) | #2 | 235403
TQN
Elite Member

[Minus]    0    [Plus]
Joined: 29/06/2006 22:28:01
Messages: 888
Location: Biết làm chi ?
Offline
[Profile] [PM] [WWW] [Yahoo!]

jmp main2+30h (141680h)
 

141680 là Virtual Address rành rành ra đấy !
[Up] [Print Copy]
  [Programming]   Mã ASM do VS2010 sinh ra. :D 14/04/2011 07:21:43 (+0700) | #3 | 235405
zjm_zjm
Member

[Minus]    0    [Plus]
Joined: 26/07/2009 01:53:09
Messages: 159
Location: hhhhhh
Offline
[Profile] [PM] [WWW] [Yahoo!] [MSN] [ICQ]
Hi hi, hồi tối mình vừa post thì cũng vừa tìm ra lun, dù sao cũng thanks, do o để ý smilie
mình đếm 30h = 48 byte vừa đúng và nhìn sau câu lệnh là biết mình hớ smilie
[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|