a urgent reply needed
|
Banned
|
|
| 28Dec2009,23:52 | #1 |
|
say the output for the following code with explanation how is it implemented inside the compiler : main() { int i=3,j; j=i++ + i++; printf("%d %d",i,j); } thanks in advance
|
|
Contributor
|
|
| 29Dec2009,01:05 | #2 |
|
My compiler (VS2008, debug,x86) implements it thus:
Code:
main() { int i=3,j; j=i++ + i++; printf("%d %d",i,j); }
00063950 push ebp
00063951 mov ebp,esp
00063953 sub esp,0D8h
00063959 push ebx
0006395A push esi
0006395B push edi
0006395C lea edi,[ebp-0D8h]
00063962 mov ecx,36h
00063967 mov eax,0CCCCCCCCh
0006396C rep stos dword ptr es:[edi]
0006396E mov dword ptr [i],3
00063975 mov eax,dword ptr [i]
00063978 add eax,dword ptr [i]
0006397B mov dword ptr [j],eax
0006397E mov ecx,dword ptr [i]
00063981 add ecx,1
00063984 mov dword ptr [i],ecx
00063987 mov edx,dword ptr [i]
0006398A add edx,1
0006398D mov dword ptr [i],edx
00063990 mov esi,esp
00063992 mov eax,dword ptr [j]
00063995 push eax
00063996 mov ecx,dword ptr [i]
00063999 push ecx
0006399A push offset string "%d %d" (6573Ch)
0006399F call dword ptr [__imp__printf (68374h)]
000639A5 add esp,0Ch
000639A8 cmp esi,esp
000639AA call @ILT+335(__RTC_CheckEsp) (61154h)
000639AF xor eax,eax
000639B1 pop edi
000639B2 pop esi
000639B3 pop ebx
000639B4 add esp,0D8h
000639BA cmp ebp,esp
000639BC call @ILT+335(__RTC_CheckEsp) (61154h)
000639C1 mov esp,ebp
000639C3 pop ebp
000639C4 ret
|
|
Banned
|
|
| 29Dec2009,09:04 | #3 |
|
first thank u for ur effort........ Actually i dunno 8086 assembly programming , now only learning ... so only am not able to appreciate ur program.... can u pl. tell me the implementation more easily from the compiler point of view ??????
![]()
|
|
Contributor
|
|
| 29Dec2009,11:52 | #4 |
|
What is it you want to know? You've been told in another thread that expressions of this sort:
Code:
j=i++ + i++; There's no reason why any sane programmer would ever need to use such an expression. Why is this "urgent"? |
|
Banned
|
|
| 30Dec2009,01:12 | #5 |
|
no no , actually i had a debugging test day before yest... that's why i put urgent.... and u are correct , it's purely compiler dependent ... i too saw today.......
![]() in other compiler it's printing as 7........ thank u |


