C300_014
C300_소스코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <stdio.h> #define PI 3.141592 const double j = 1.23456789; main() { //PI = 3.141592; // 에러 발생 //j = 1.23456789; // 에러 발생 printf("실수형 상수 PI의 값은 %f \n", PI); printf("실수형 상수 j의 값은 %f \n", j); } | cs |
IDA - Layout Graph
IDA - Text View
우선 ds:__real@400921faf 8b007a의 값은 3.141592이다.
ds:__로 시작한것과 .rdata 영역에 있는것으로 보아 const type으로 선언되었음을 예상해 볼 수 있다.
movsd: 부동 소수를 옮길 때 사용하는 명령어
(Merge Scalar Double-Precision Floating Pointing-Point Value)
배정도 부정소수(64비트)
_j 값은 본 소스코드에서 const double j = 1.23456789;로 되어있다.
왜 IDA에서 3FF3C0CA4283DE1Bh로 되어있지...??
pseudo code - 의사 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <stdio.h> const var_8 = 3.141592; const j =12345678; main() { xmm0 = var_8; [esp+8+var_8] = xmm0; printf(_Format); xmm0 = j; [esp+8+var_8] = xmm0; printf(byte_40303C); eax=0; } | cs |
정수를 다룰 때와 달리 소수를 다룰 때 #define과 같은 매크로 함수로 인해 바로 stack에 push 되지 못한다.
pseudo code - 최종 의사 코드
1 2 3 4 5 6 7 8 9 10 11 | #include <stdio.h> const var_8 = 3.141592; const j =12345678; main() { printf(_Format, var_8); printf(byte_40303C, j); } | cs |
'Reversing > ASM to C' 카테고리의 다른 글
ASM to C with IDA - 016 (0) | 2018.05.28 |
---|---|
ASM to C with IDA - 015 (0) | 2018.05.28 |
ASM to C with IDA - 013 (0) | 2018.05.27 |
ASM to C with IDA - 012 (0) | 2018.05.27 |
ASM to C with IDA - 011 (0) | 2018.05.27 |