IT공부/IT서적

[윤성우 열혈 C프로그래밍] 디버깅 빌드, 어셈블리 코드 - Chapter5

shine94 2025. 1. 13. 15:22
#include <stdio.h>

int main(void)
{
006C1870  push        ebp  
006C1871  mov         ebp,esp  
006C1873  sub         esp,0E8h  
006C1879  push        ebx  
006C187A  push        esi  
006C187B  push        edi  
006C187C  lea         edi,[ebp-28h]  
006C187F  mov         ecx,0Ah  
006C1884  mov         eax,0CCCCCCCCh  
006C1889  rep stos    dword ptr es:[edi]  
006C188B  mov         ecx,offset _4B8E694C_SizeOfOperator@c (06CC008h)  
006C1890  call        @__CheckForDebuggerJustMyCode@4 (06C132Ah)  
006C1895  nop  
	char ch = 9;
006C1896  mov         byte ptr [ch],9  
	int inum = 1052;
006C189A  mov         dword ptr [inum],41Ch  
	double dnum = 3.14;
006C18A1  movsd       xmm0,mmword ptr [__real@40091eb851eb851f (06C7C18h)]  
006C18A9  movsd       mmword ptr [dnum],xmm0  

	printf("변수 ch의 크기 : %d\n", sizeof(ch));
006C18AE  push        1  
006C18B0  push        offset string "\xba\xaf\xbc\xf6 ch\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7B30h)  
006C18B5  call        _printf (06C10D2h)  
006C18BA  add         esp,8  
	printf("변수 inum의 크기 : %d\n", sizeof(inum));
006C18BD  push        4  
006C18BF  push        offset string "\xba\xaf\xbc\xf6 inum\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7B4Ch)  
006C18C4  call        _printf (06C10D2h)  
006C18C9  add         esp,8  
	printf("변수 dnum의 크기 : %d\n\n", sizeof(dnum));
006C18CC  push        8  
006C18CE  push        offset string "\xba\xaf\xbc\xf6 dnum\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n\n" (06C7B68h)  
006C18D3  call        _printf (06C10D2h)  
006C18D8  add         esp,8  
	
	printf("char의 크기 : %d\n", sizeof(char));
006C18DB  push        1  
006C18DD  push        offset string "char\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7B84h)  
006C18E2  call        _printf (06C10D2h)  
006C18E7  add         esp,8  
	printf("int의 크기 : %d\n", sizeof(int));
006C18EA  push        4  
006C18EC  push        offset string "int\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7B9Ch)  
006C18F1  call        _printf (06C10D2h)  
006C18F6  add         esp,8  
	printf("long의 크기 : %d\n", sizeof(long));
006C18F9  push        4  
006C18FB  push        offset string "long\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7BB0h)  
006C1900  call        _printf (06C10D2h)  
006C1905  add         esp,8  
	printf("long long의 크기 : %d\n\n", sizeof(long long));
006C1908  push        8  
006C190A  push        offset string "long long\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n\n" (06C7BC8h)  
006C190F  call        _printf (06C10D2h)  
006C1914  add         esp,8  

	printf("float의 크기 : %d\n", sizeof(float));
006C1917  push        4  
006C1919  push        offset string "float\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7BE4h)  
006C191E  call        _printf (06C10D2h)  
006C1923  add         esp,8  
	printf("double의 크기 : %d\n", sizeof(double));
006C1926  push        8  
006C1928  push        offset string "double\xc0\xc7 \xc5\xa9\xb1\xe2 : %d\n" (06C7BFCh)  
006C192D  call        _printf (06C10D2h)  
006C1932  add         esp,8  

	return 0;
006C1935  xor         eax,eax  
}
006C1937  pop         edi  
006C1938  pop         esi  
006C1939  pop         ebx  
006C193A  add         esp,0E8h  
006C1940  cmp         ebp,esp  
006C1942  call        __RTC_CheckEsp (06C124Eh)  
006C1947  mov         esp,ebp  
006C1949  pop         ebp  
006C194A  ret

 

* xmm0 레지스터

   128비트 크기의 레지스터

   SIMD(Single Instruction, Multiple Data) 연산에 사용 : 한 번에 여러 데이터를 병렬 처리

   사용범위

      - 64비트 모드 : xmm0부터 xmm15까지,

      - 32비트 모드 : xmm0 ~ xmm7까지 사용 가능

   주 용도

      - 부동소수점 연산

 

#include <stdio.h>

int main(void)
{
00F244F0  push        ebp  
00F244F1  mov         ebp,esp  
00F244F3  sub         esp,108h  
00F244F9  push        ebx  
00F244FA  push        esi  
00F244FB  push        edi  
00F244FC  lea         edi,[ebp-48h]  
00F244FF  mov         ecx,12h  
00F24504  mov         eax,0CCCCCCCCh  
00F24509  rep stos    dword ptr es:[edi]  
00F2450B  mov         ecx,offset _1E7E2136_CharShortBaseAdd@c (0F2C008h)  
00F24510  call        @__CheckForDebuggerJustMyCode@4 (0F2131Bh)  
00F24515  nop  
	char num1 = 1, num2 = 2, result1 = 0;
00F24516  mov         byte ptr [num1],1  
00F2451A  mov         byte ptr [num2],2  
00F2451E  mov         byte ptr [result1],0  
	short num3 = 300, num4 = 400, result2 = 0;
00F24522  mov         eax,12Ch  
00F24527  mov         word ptr [num3],ax  
00F2452B  mov         eax,190h  
00F24530  mov         word ptr [num4],ax  
00F24534  xor         eax,eax  
00F24536  mov         word ptr [result2],ax  

	printf("size of num1 & num2: %d, %d\n", sizeof(num1), sizeof(num2));
00F2453A  push        1  
00F2453C  push        1  
00F2453E  push        offset string "size of num1 & num2: %d, %d\n" (0F27BCCh)  
00F24543  call        _printf (0F213B1h)  
00F24548  add         esp,0Ch  
	printf("size of num3 & num4: %d, %d\n\n", sizeof(num3), sizeof(num4));
00F2454B  push        2  
00F2454D  push        2  
00F2454F  push        offset string "size of num3 & num4: %d, %d\n\n" (0F27CD0h)  
00F24554  call        _printf (0F213B1h)  
00F24559  add         esp,0Ch  

	printf("size of char add: %d\n", sizeof(num1 + num2));
00F2455C  push        4  
00F2455E  push        offset string "size of char add: %d\n" (0F27E20h)  
00F24563  call        _printf (0F213B1h)  
00F24568  add         esp,8  
	printf("size of char add: %d\n\n", sizeof(num3 + num4));
00F2456B  push        4  
00F2456D  push        offset string "size of char add: %d\n\n" (0F285A8h)  
00F24572  call        _printf (0F213B1h)  
00F24577  add         esp,8  

	result1 = num1 + num2;
00F2457A  movsx       eax,byte ptr [num1]  
00F2457E  movsx       ecx,byte ptr [num2]  
00F24582  add         eax,ecx  
00F24584  mov         byte ptr [result1],al  
	result2 = num3 + num4;
00F24587  movsx       eax,word ptr [num3]  
00F2458B  movsx       ecx,word ptr [num4]  
00F2458F  add         eax,ecx  
00F24591  mov         word ptr [result2],ax  

	printf("size of result1 & result2: %d %d\n", sizeof(result1), sizeof(result2));
00F24595  push        2  
00F24597  push        1  
00F24599  push        offset string "size of result1 & result2: %d %@"... (0F28608h)  
00F2459E  call        _printf (0F213B1h)  
00F245A3  add         esp,0Ch  

	return 0;
00F245A6  xor         eax,eax  
}
00F245A8  pop         edi  
00F245A9  pop         esi  
00F245AA  pop         ebx  
00F245AB  add         esp,108h  
00F245B1  cmp         ebp,esp  
00F245B3  call        __RTC_CheckEsp (0F2123Fh)  
00F245B8  mov         esp,ebp  
00F245BA  pop         ebp  
00F245BB  ret

 

일반적으로 CPU가 처리하기에 가장 적합한 크기의 정수 자료형은 int로 정의한다

   따라서 int형 연산 속도가 다른 자료형의 연산 속도에 비해서 동일하거나 더 빠르다

 

#include <stdio.h>

int main(void)
{
00291960  push        ebp  
00291961  mov         ebp,esp  
00291963  sub         esp,0E4h  
00291969  push        ebx  
0029196A  push        esi  
0029196B  push        edi  
0029196C  lea         edi,[ebp-24h]  
0029196F  mov         ecx,9  
00291974  mov         eax,0CCCCCCCCh  
00291979  rep stos    dword ptr es:[edi]  
0029197B  mov         eax,dword ptr [__security_cookie (029A000h)]  
00291980  xor         eax,ebp  
00291982  mov         dword ptr [ebp-4],eax  
00291985  mov         ecx,offset _BB2611C7_CircleArea@c (029C008h)  
0029198A  call        @__CheckForDebuggerJustMyCode@4 (0291339h)  
0029198F  nop  
	double rad;
	double area;
	printf("원의 반지름 입력: ");
00291990  push        offset string "\xbf\xf8\xc0\xc7 \xb9\xdd\xc1\xf6\xb8\xa7 \xc0\xd4\xb7\xc2: " (0297B30h)  
00291995  call        _printf (02910DCh)  
0029199A  add         esp,4  
	scanf_s("%lf", &rad);
0029199D  lea         eax,[rad]  
002919A0  push        eax  
002919A1  push        offset string "%lf" (0297B48h)  
002919A6  call        _scanf_s (0291294h)  
002919AB  add         esp,8  

	area = rad * 3.14195;
002919AE  movsd       xmm0,mmword ptr [rad]  
002919B3  mulsd       xmm0,mmword ptr [__real@400922b6ae7d566d (0297B60h)]  
002919BB  movsd       mmword ptr [area],xmm0  
	printf("원의 넓이: %f\n", area);
002919C0  sub         esp,8  
002919C3  movsd       xmm0,mmword ptr [area]  
002919C8  movsd       mmword ptr [esp],xmm0  
002919CD  push        offset string "\xbf\xf8\xc0\xc7 \xb3\xd0\xc0\xcc: %f\n" (0297B4Ch)  
002919D2  call        _printf (02910DCh)  
002919D7  add         esp,0Ch  

	return 0;
002919DA  xor         eax,eax  
}
002919DC  push        edx  
002919DD  mov         ecx,ebp  
002919DF  push        eax  
002919E0  lea         edx,ds:[291A0Ch]  
002919E6  call        @_RTC_CheckStackVars@8 (02911F4h)  
002919EB  pop         eax  
002919EC  pop         edx  
002919ED  pop         edi  
002919EE  pop         esi  
002919EF  pop         ebx  
002919F0  mov         ecx,dword ptr [ebp-4]  
002919F3  xor         ecx,ebp  
002919F5  call        @__security_check_cookie@4 (0291159h)  
002919FA  add         esp,0E4h  
00291A00  cmp         ebp,esp  
00291A02  call        __RTC_CheckEsp (0291258h)  
00291A07  mov         esp,ebp  
00291A09  pop         ebp  
00291A0A  ret

 

#include <stdio.h>

int main(void)
{
00881960  push        ebp  
00881961  mov         ebp,esp  
00881963  sub         esp,0DCh  
00881969  push        ebx  
0088196A  push        esi  
0088196B  push        edi  
0088196C  lea         edi,[ebp-1Ch]  
0088196F  mov         ecx,7  
00881974  mov         eax,0CCCCCCCCh  
00881979  rep stos    dword ptr es:[edi]  
0088197B  mov         eax,dword ptr [__security_cookie (088A000h)]  
00881980  xor         eax,ebp  
00881982  mov         dword ptr [ebp-4],eax  
00881985  mov         ecx,offset _BB2611C7_CircleArea@c (088C008h)  
0088198A  call        @__CheckForDebuggerJustMyCode@4 (0881339h)  
0088198F  nop  
	float rad;
	float area;
	printf("원의 반지름 입력: ");
00881990  push        offset string "\xbf\xf8\xc0\xc7 \xb9\xdd\xc1\xf6\xb8\xa7 \xc0\xd4\xb7\xc2: " (0887B30h)  
00881995  call        _printf (08810DCh)  
0088199A  add         esp,4  
	scanf_s("%f", &rad);
0088199D  lea         eax,[rad]  
008819A0  push        eax  
008819A1  push        offset string "%f" (0887B48h)  
008819A6  call        _scanf_s (0881294h)  
008819AB  add         esp,8  

	area = rad * 3.14195f;
008819AE  movss       xmm0,dword ptr [rad]  
008819B3  mulss       xmm0,dword ptr [__real@404915b5 (0887B44h)]  
008819BB  movss       dword ptr [area],xmm0  
	printf("원의 넓이: %f\n", area);
008819C0  cvtss2sd    xmm0,dword ptr [area]  
008819C5  sub         esp,8  
008819C8  movsd       mmword ptr [esp],xmm0  
008819CD  push        offset string "\xbf\xf8\xc0\xc7 \xb3\xd0\xc0\xcc: %f\n" (0887B4Ch)  
008819D2  call        _printf (08810DCh)  
008819D7  add         esp,0Ch  

	return 0;
008819DA  xor         eax,eax  
}
008819DC  push        edx  
008819DD  mov         ecx,ebp  
008819DF  push        eax  
008819E0  lea         edx,ds:[881A0Ch]  
008819E6  call        @_RTC_CheckStackVars@8 (08811F4h)  
008819EB  pop         eax  
008819EC  pop         edx  
008819ED  pop         edi  
008819EE  pop         esi  
008819EF  pop         ebx  
008819F0  mov         ecx,dword ptr [ebp-4]  
008819F3  xor         ecx,ebp  
008819F5  call        @__security_check_cookie@4 (0881159h)  
008819FA  add         esp,0DCh  
00881A00  cmp         ebp,esp  
00881A02  call        __RTC_CheckEsp (0881258h)  
00881A07  mov         esp,ebp  
00881A09  pop         ebp  
00881A0A  ret

 

* 메모리 오퍼랜드 키워드

   byte ptr: 8비트(1바이트) 데이터

   word ptr: 16비트(2바이트) 데이터

   dword ptr: 32비트(4바이트) 데이터

   qword ptr: 64비트(8바이트) 데이터

   mmword ptr: 64비트(8바이트) 데이터

   xmmword ptr: 128비트(16바이트) 데이터

 

* CPU는 메모리 정렬(alignment)과 효율성을 위해 더 큰 레지스터를 사용

 

 

#include <stdio.h>

int main(void)
{
00F81870  push        ebp  
00F81871  mov         ebp,esp  
00F81873  sub         esp,0F0h  
00F81879  push        ebx  
00F8187A  push        esi  
00F8187B  push        edi  
00F8187C  lea         edi,[ebp-30h]  
00F8187F  mov         ecx,0Ch  
00F81884  mov         eax,0CCCCCCCCh  
00F81889  rep stos    dword ptr es:[edi]  
00F8188B  mov         ecx,offset _4700986F_HowChar@c (0F8C008h)  
00F81890  call        @__CheckForDebuggerJustMyCode@4 (0F8132Ah)  
00F81895  nop  
	char ch1 = 'A', ch2 = 65;
00F81896  mov         byte ptr [ch1],41h  
00F8189A  mov         byte ptr [ch2],41h  
	int ch3 = 'Z', ch4 = 90;
00F8189E  mov         dword ptr [ch3],5Ah  
00F818A5  mov         dword ptr [ch4],5Ah  

	printf("%c %d \n", ch1, ch1);
00F818AC  movsx       eax,byte ptr [ch1]  
00F818B0  push        eax  
00F818B1  movsx       ecx,byte ptr [ch1]  
00F818B5  push        ecx  
00F818B6  push        offset string "%c %d \n" (0F87B30h)  
00F818BB  call        _printf (0F810D2h)  
00F818C0  add         esp,0Ch  
	printf("%c %d \n", ch2, ch2);
00F818C3  movsx       eax,byte ptr [ch2]  
00F818C7  push        eax  
00F818C8  movsx       ecx,byte ptr [ch2]  
00F818CC  push        ecx  
00F818CD  push        offset string "%c %d \n" (0F87B30h)  
00F818D2  call        _printf (0F810D2h)  
00F818D7  add         esp,0Ch  
	printf("%c %d \n", ch3, ch3);
00F818DA  mov         eax,dword ptr [ch3]  
00F818DD  push        eax  
00F818DE  mov         ecx,dword ptr [ch3]  
00F818E1  push        ecx  
00F818E2  push        offset string "%c %d \n" (0F87B30h)  
00F818E7  call        _printf (0F810D2h)  
00F818EC  add         esp,0Ch  
	printf("%c %d \n", ch4, ch4);
00F818EF  mov         eax,dword ptr [ch4]  
00F818F2  push        eax  
00F818F3  mov         ecx,dword ptr [ch4]  
00F818F6  push        ecx  
00F818F7  push        offset string "%c %d \n" (0F87B30h)  
00F818FC  call        _printf (0F810D2h)  
00F81901  add         esp,0Ch  

	return 0;
00F81904  xor         eax,eax  
}
00F81906  pop         edi  
00F81907  pop         esi  
00F81908  pop         ebx  
00F81909  add         esp,0F0h  
00F8190F  cmp         ebp,esp  
00F81911  call        __RTC_CheckEsp (0F8124Eh)  
00F81916  mov         esp,ebp  
00F81918  pop         ebp  
00F81919  ret

 

* movzx(Move with Zero-Extend)

   확장 대입, 부호없는 산술 값에 대해서 사용

 

* movsx(Move with Sign-Extend)

   확장 대입, 부호있는 산술 값에 대해서 사용

 

   https://blog.naver.com/stop2y/221049321800

 

[리버싱] 기본 어셈블리어 - MOV / MOVZX / MOVSX /MOVS

MOV / MOVZX / MOVSX /MOVSMOV형식 : MOV [OPER1][OPER2] 의미 : OPER...

blog.naver.com

 

#include <stdio.h>

int main(void)
{
00E91870  push        ebp  
00E91871  mov         ebp,esp  
00E91873  sub         esp,0C0h  
00E91879  push        ebx  
00E9187A  push        esi  
00E9187B  push        edi  
00E9187C  mov         edi,ebp  
00E9187E  xor         ecx,ecx  
00E91880  mov         eax,0CCCCCCCCh  
00E91885  rep stos    dword ptr es:[edi]  
00E91887  mov         ecx,offset _EAF959F1_LiteralSize@c (0E9C008h)  
00E9188C  call        @__CheckForDebuggerJustMyCode@4 (0E9132Ah)  
00E91891  nop  
	printf("literal int size: %d", sizeof(7));
00E91892  push        4  
00E91894  push        offset string "literal int size: %d" (0E97B30h)  
00E91899  call        _printf (0E910D2h)  
00E9189E  add         esp,8  
	printf("literal double size: %d", sizeof(7.14));
00E918A1  push        8  
00E918A3  push        offset string "literal double size: %d" (0E97B4Ch)  
00E918A8  call        _printf (0E910D2h)  
00E918AD  add         esp,8  
	printf("literal char size: %d", sizeof('A'));
00E918B0  push        4  
00E918B2  push        offset string "literal char size: %d" (0E97B68h)  
00E918B7  call        _printf (0E910D2h)  
00E918BC  add         esp,8  
	
	return 0;
00E918BF  xor         eax,eax  
}
00E918C1  pop         edi  
00E918C2  pop         esi  
00E918C3  pop         ebx  
00E918C4  add         esp,0C0h  
00E918CA  cmp         ebp,esp  
00E918CC  call        __RTC_CheckEsp (0E9124Eh)  
00E918D1  mov         esp,ebp  
00E918D3  pop         ebp  
00E918D4  ret

 

#include <stdio.h>

int main(void)
{
00D21870  push        ebp  
00D21871  mov         ebp,esp  
00D21873  sub         esp,0F4h  
00D21879  push        ebx  
00D2187A  push        esi  
00D2187B  push        edi  
00D2187C  lea         edi,[ebp-34h]  
00D2187F  mov         ecx,0Dh  
00D21884  mov         eax,0CCCCCCCCh  
00D21889  rep stos    dword ptr es:[edi]  
00D2188B  mov         ecx,offset _CE215058_AutoConvOne@c (0D2C008h)  
00D21890  call        @__CheckForDebuggerJustMyCode@4 (0D2132Ah)  
00D21895  nop  
	double num1 = 245;
00D21896  movsd       xmm0,mmword ptr [__real@406ea00000000000 (0D27B90h)]  
00D2189E  movsd       mmword ptr [num1],xmm0  
	int num2 = 3.14;
00D218A3  mov         dword ptr [num2],3  
	int num3 = 129;
00D218AA  mov         dword ptr [num3],81h  
	char ch = num3;
00D218B1  movzx       eax,byte ptr [num3]  
00D218B5  mov         byte ptr [ch],al  

	printf("정수 245를 실수로: %f\n", num1);
00D218B8  sub         esp,8  
00D218BB  movsd       xmm0,mmword ptr [num1]  
00D218C0  movsd       mmword ptr [esp],xmm0  
00D218C5  push        offset string "\xc1\xa4\xbc\xf6 245\xb8\xa6 \xbd\xc7\xbc\xf6\xb7\xce: %f\n" (0D27B30h)  
00D218CA  call        _printf (0D210D2h)  
00D218CF  add         esp,0Ch  
	printf("실수 3.1415를 실수로: %d\n", num2);
00D218D2  mov         eax,dword ptr [num2]  
00D218D5  push        eax  
00D218D6  push        offset string "\xbd\xc7\xbc\xf6 3.1415\xb8\xa6 \xbd\xc7\xbc\xf6\xb7\xce: %d\n" (0D27B4Ch)  
00D218DB  call        _printf (0D210D2h)  
00D218E0  add         esp,8  
	printf("큰 정수 129를 실수로: %d\n", ch);
00D218E3  movsx       eax,byte ptr [ch]  
00D218E7  push        eax  
00D218E8  push        offset string "\xc5\xab \xc1\xa4\xbc\xf6 129\xb8\xa6 \xbd\xc7\xbc\xf6\xb7\xce: %d\n" (0D27B6Ch)  
00D218ED  call        _printf (0D210D2h)  
00D218F2  add         esp,8  
	return 0;
00D218F5  xor         eax,eax  
}
00D218F7  pop         edi  
00D218F8  pop         esi  
00D218F9  pop         ebx  
00D218FA  add         esp,0F4h  
00D21900  cmp         ebp,esp  
00D21902  call        __RTC_CheckEsp (0D2124Eh)  
00D21907  mov         esp,ebp  
00D21909  pop         ebp  
00D2190A  ret

 

* movss(Move Scalar Single-Precision Floating-Point Value)

   단정밀도 부동소수점(32비트) 값을 복사

 

* movsd(Move Scalar Double-Precision Floating-Point Value)

   배정밀도 부동소수점(64비트) 값을 복사

 

#include <stdio.h>

int main(void)
{
00D41870  push        ebp  
00D41871  mov         ebp,esp  
00D41873  sub         esp,0E8h  
00D41879  push        ebx  
00D4187A  push        esi  
00D4187B  push        edi  
00D4187C  lea         edi,[ebp-28h]  
00D4187F  mov         ecx,0Ah  
00D41884  mov         eax,0CCCCCCCCh  
00D41889  rep stos    dword ptr es:[edi]  
00D4188B  mov         ecx,offset _A5280B87_ConvDiv@c (0D4C008h)  
00D41890  call        @__CheckForDebuggerJustMyCode@4 (0D4132Ah)  
00D41895  nop  
	int num1 = 3, num2 = 4;
00D41896  mov         dword ptr [num1],3  
00D4189D  mov         dword ptr [num2],4  
	double divResult;
	divResult = num1 / num2;
00D418A4  mov         eax,dword ptr [num1]  
00D418A7  cdq  
00D418A8  idiv        eax,dword ptr [num2]  
00D418AB  cvtsi2sd    xmm0,eax  
00D418AF  movsd       mmword ptr [divResult],xmm0  
	printf("나눗셈의 결과 : %f\n", divResult);
00D418B4  sub         esp,8  
00D418B7  movsd       xmm0,mmword ptr [divResult]  
00D418BC  movsd       mmword ptr [esp],xmm0  
00D418C1  push        offset string "\xb3\xaa\xb4\xb0\xbc\xc0\xc0\xc7 \xb0\xe1\xb0\xfa : %f\n" (0D47B30h)  
00D418C6  call        _printf (0D410D2h)  
00D418CB  add         esp,0Ch  
	return 0;
00D418CE  xor         eax,eax  
}
00D418D0  pop         edi  
00D418D1  pop         esi  
00D418D2  pop         ebx  
00D418D3  add         esp,0E8h  
00D418D9  cmp         ebp,esp  
00D418DB  call        __RTC_CheckEsp (0D4124Eh)  
00D418E0  mov         esp,ebp  
00D418E2  pop         ebp  
00D418E3  ret

 

#include <stdio.h>

int main(void)
{
000A1960  push        ebp  
000A1961  mov         ebp,esp  
000A1963  sub         esp,100h  
000A1969  push        ebx  
000A196A  push        esi  
000A196B  push        edi  
000A196C  lea         edi,[ebp-40h]  
000A196F  mov         ecx,10h  
000A1974  mov         eax,0CCCCCCCCh  
000A1979  rep stos    dword ptr es:[edi]  
000A197B  mov         eax,dword ptr [__security_cookie (0AA000h)]  
000A1980  xor         eax,ebp  
000A1982  mov         dword ptr [ebp-4],eax  
000A1985  mov         ecx,offset _25AF3A46_Problem5_1_1@c (0AC008h)  
000A198A  call        @__CheckForDebuggerJustMyCode@4 (0A1339h)  
000A198F  nop  
	int xpos1, ypos1;
	int xpos2, ypos2;
	int area;

	printf("좌 상단의 x, y 좌표: ");
000A1990  push        offset string "\xc1\xc2 \xbb\xf3\xb4\xdc\xc0\xc7 x, y \xc1\xc2\xc7\xa5: " (0A7B30h)  
000A1995  call        _printf (0A10DCh)  
000A199A  add         esp,4  
	scanf_s("%d %d", &xpos1, &ypos1);
000A199D  lea         eax,[ypos1]  
000A19A0  push        eax  
000A19A1  lea         ecx,[xpos1]  
000A19A4  push        ecx  
000A19A5  push        offset string "%d %d" (0A7B4Ch)  
000A19AA  call        _scanf_s (0A1294h)  
000A19AF  add         esp,0Ch  
	printf("우 상단의 x, y 좌표: ");
000A19B2  push        offset string "\xbf\xec \xbb\xf3\xb4\xdc\xc0\xc7 x, y \xc1\xc2\xc7\xa5: " (0A7B54h)  
000A19B7  call        _printf (0A10DCh)  
000A19BC  add         esp,4  
	scanf_s("%d %d", &xpos2, &ypos2);
000A19BF  lea         eax,[ypos2]  
000A19C2  push        eax  
000A19C3  lea         ecx,[xpos2]  
000A19C6  push        ecx  
000A19C7  push        offset string "%d %d" (0A7B4Ch)  
000A19CC  call        _scanf_s (0A1294h)  
000A19D1  add         esp,0Ch  
	
	area = (xpos2 - xpos1) * (ypos2 - ypos1);
000A19D4  mov         eax,dword ptr [xpos2]  
000A19D7  sub         eax,dword ptr [xpos1]  
000A19DA  mov         ecx,dword ptr [ypos2]  
000A19DD  sub         ecx,dword ptr [ypos1]  
000A19E0  imul        eax,ecx  
000A19E3  mov         dword ptr [area],eax  
	printf("두 점이 이루는 직사각형의 넓이는 %d입니다. \n", area);
000A19E6  mov         eax,dword ptr [area]  
000A19E9  push        eax  
000A19EA  push        offset string "\xb5\xce \xc1\xa1\xc0\xcc \xc0\xcc\xb7\xe7\xb4\xc2 \xc1\xf7\xbb\xe7\xb0\xa2\xc7\xfc\xc0\xc7 \xb3\xd0\xc0\xcc\xb4@"... (0A7B70h)  
000A19EF  call        _printf (0A10DCh)  
000A19F4  add         esp,8  

	return 0;
000A19F7  xor         eax,eax  
}
000A19F9  push        edx  
000A19FA  mov         ecx,ebp  
000A19FC  push        eax  
000A19FD  lea         edx,ds:[0A1A28h]  
000A1A03  call        @_RTC_CheckStackVars@8 (0A11F4h)  
000A1A08  pop         eax  
000A1A09  pop         edx  
000A1A0A  pop         edi  
000A1A0B  pop         esi  
000A1A0C  pop         ebx  
000A1A0D  mov         ecx,dword ptr [ebp-4]  
000A1A10  xor         ecx,ebp  
000A1A12  call        @__security_check_cookie@4 (0A1159h)  
000A1A17  add         esp,100h  
000A1A1D  cmp         ebp,esp  
000A1A1F  call        __RTC_CheckEsp (0A1258h)  
000A1A24  mov         esp,ebp  
000A1A26  pop         ebp  
000A1A27  ret

 

#include <stdio.h>

int main(void)
{
00251960  push        ebp  
00251961  mov         ebp,esp  
00251963  sub         esp,0E4h  
00251969  push        ebx  
0025196A  push        esi  
0025196B  push        edi  
0025196C  lea         edi,[ebp-24h]  
0025196F  mov         ecx,9  
00251974  mov         eax,0CCCCCCCCh  
00251979  rep stos    dword ptr es:[edi]  
0025197B  mov         eax,dword ptr [__security_cookie (025A000h)]  
00251980  xor         eax,ebp  
00251982  mov         dword ptr [ebp-4],eax  
00251985  mov         ecx,offset _27E9841F_Problem5_1_2@c (025C008h)  
0025198A  call        @__CheckForDebuggerJustMyCode@4 (0251339h)  
0025198F  nop  
	double num1, num2;
	printf("두 개의 실수 입력: ");
00251990  push        offset string "\xb5\xce \xb0\xb3\xc0\xc7 \xbd\xc7\xbc\xf6 \xc0\xd4\xb7\xc2: " (0257B30h)  
00251995  call        _printf (02510DCh)  
0025199A  add         esp,4  
	scanf_s("%lf %lf", &num1, &num2);
0025199D  lea         eax,[num2]  
002519A0  push        eax  
002519A1  lea         ecx,[num1]  
002519A4  push        ecx  
002519A5  push        offset string "%lf %lf" (0257B48h)  
002519AA  call        _scanf_s (0251294h)  
002519AF  add         esp,0Ch  

	printf("두 수의 덧셈: %f\n", num1 + num2);
002519B2  movsd       xmm0,mmword ptr [num1]  
002519B7  addsd       xmm0,mmword ptr [num2]  
002519BC  sub         esp,8  
002519BF  movsd       mmword ptr [esp],xmm0  
002519C4  push        offset string "\xb5\xce \xbc\xf6\xc0\xc7 \xb5\xa1\xbc\xc0: %f\n" (0257B54h)  
002519C9  call        _printf (02510DCh)  
002519CE  add         esp,0Ch  
	printf("두 수의 뺄셈: %f\n", num1 - num2);
002519D1  movsd       xmm0,mmword ptr [num1]  
002519D6  subsd       xmm0,mmword ptr [num2]  
002519DB  sub         esp,8  
002519DE  movsd       mmword ptr [esp],xmm0  
002519E3  push        offset string "\xb5\xce \xbc\xf6\xc0\xc7 \xbb\xac\xbc\xc0: %f\n" (0257B6Ch)  
002519E8  call        _printf (02510DCh)  
002519ED  add         esp,0Ch  
	printf("두 수의 곱셈: %f\n", num1 * num2);
002519F0  movsd       xmm0,mmword ptr [num1]  
002519F5  mulsd       xmm0,mmword ptr [num2]  
002519FA  sub         esp,8  
002519FD  movsd       mmword ptr [esp],xmm0  
00251A02  push        offset string "\xb5\xce \xbc\xf6\xc0\xc7 \xb0\xf6\xbc\xc0: %f\n" (0257B84h)  
00251A07  call        _printf (02510DCh)  
00251A0C  add         esp,0Ch  
	printf("두 수의 나눗셈: %f\n", num1 / num2);
00251A0F  movsd       xmm0,mmword ptr [num1]  
00251A14  divsd       xmm0,mmword ptr [num2]  
00251A19  sub         esp,8  
00251A1C  movsd       mmword ptr [esp],xmm0  
00251A21  push        offset string "\xb5\xce \xbc\xf6\xc0\xc7 \xb3\xaa\xb4\xb0\xbc\xc0: %f\n" (0257B9Ch)  
00251A26  call        _printf (02510DCh)  
00251A2B  add         esp,0Ch  
}
00251A2E  xor         eax,eax  
00251A30  push        edx  
00251A31  mov         ecx,ebp  
00251A33  push        eax  
00251A34  lea         edx,ds:[251A60h]  
00251A3A  call        @_RTC_CheckStackVars@8 (02511F4h)  
00251A3F  pop         eax  
00251A40  pop         edx  
00251A41  pop         edi  
00251A42  pop         esi  
00251A43  pop         ebx  
00251A44  mov         ecx,dword ptr [ebp-4]  
00251A47  xor         ecx,ebp  
00251A49  call        @__security_check_cookie@4 (0251159h)  
00251A4E  add         esp,0E4h  
00251A54  cmp         ebp,esp  
00251A56  call        __RTC_CheckEsp (0251258h)  
00251A5B  mov         esp,ebp  
00251A5D  pop         ebp  
00251A5E  ret