| | |
C++ internals
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
•
•
Join Date: Apr 2007
Posts: 28
Reputation:
Solved Threads: 0
I'm trying to advance my understanding of how computers and compilers work.
Given the C++ program bellow with exceptions and runtime typing turned off and no optimizing that removes main or makes it into a non-standard function.
Produced an disassembly with the following code for main:
1. What will the assembly that calls the main function look like?
2. What will be on the start before this code is run?
3. What will EBP (the stack frame pointer) be at the start? Garbage values?
4. What is in the accumulator at the start? Garbage values again?
5. What does the leave function do? I've read around for this but I can't find anything that makes much sense.
6. To what address will ret jump the instruction pointer to?
7. What does the assembly look like for the code that is executed the main function exits?
8. Another thing that is being getting at me is: why does C++ CDECL calling convention pass argument right to left? It seems counter intuitive to me as it rewards doing right to left as the order of evaluation of the parameters which is also counter intuitive to me.
Thanks in advance, any help would be much appreciated
Given the C++ program bellow with exceptions and runtime typing turned off and no optimizing that removes main or makes it into a non-standard function.
c Syntax (Toggle Plain Text)
int main() {return0;}
Produced an disassembly with the following code for main:
asm Syntax (Toggle Plain Text)
pushl %ebp ; pushes the stack frame xorl %eax, %eax ; sets the eax register to zero movl %esp, %ebp ; empties the stack frame leave ret ; return with 0 in eax
1. What will the assembly that calls the main function look like?
2. What will be on the start before this code is run?
3. What will EBP (the stack frame pointer) be at the start? Garbage values?
4. What is in the accumulator at the start? Garbage values again?
5. What does the leave function do? I've read around for this but I can't find anything that makes much sense.
6. To what address will ret jump the instruction pointer to?
7. What does the assembly look like for the code that is executed the main function exits?
8. Another thing that is being getting at me is: why does C++ CDECL calling convention pass argument right to left? It seems counter intuitive to me as it rewards doing right to left as the order of evaluation of the parameters which is also counter intuitive to me.
Thanks in advance, any help would be much appreciated
Thanks in advance; in advance taken (thankfully).
![]() |
Similar Threads
- Compile PHP (PHP)
- Tutorial in Graphics&Mouse in C (Game Development)
- upgraded to 10.3.4 Scsi not found (Apple Hardware)
- Problems IE 6 Win98 redirected from google to other site (Web Browsers)
- Microsoft IE Offline Pop-ups (Web Browsers)
- my internet cache won't clear... help! (Web Browsers)
Other Threads in the Computer Science Forum
- Previous Thread: SuggEsTionS plZ..!!
- Next Thread: Final Year Project help!!!
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
ai algorithm algorithms assignment assignmenthelp assignments automata battery bigbrother binary bittorrent bizarre bletchleypark blogging bomb business clueless codebreaker compiler computer computerscience connect conversion csc data dataanalysis dataintepretation development dfa dissertation dissertationthesis dissertationtopic employment energy extensions foreclosure foreclosuresoftware fuel geeks givemetehcodez government graphics hardware history homeowners homework homeworkassignment homeworkhelp humor ibm idea ideas internet iphone ipod jobs kindle laser laws lazy linkbait lsmeans mainframes marketing mining mobileapplication msaccess nano netbeans news os p2p piracy piratebay principles programming rasterizer research sam-being-cute sas science security simulation software spoonfeeding spying sql stephenfry student supercomputer supercomputing sweden syntactic technology turing turingtest two'scompliment virus warehouse ww2





