| | |
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 |
ai algorithm algorithms amazon assignment assignmenthelp assignments automata battery bigbrother binary bittorrent bizarre blogging bomb business cern codebreaker compiler computer computers computerscience computertrackingsoftware connect conversion data dataanalysis dataintepretation development dfa dissertation dissertations dissertationthesis dissertationtopic ebook employment energy extensions floatingpoint foreclosure foreclosuresoftware fuel gadgets geeks givemetehcodez government graphics hardware history homeowners homeworkassignment homeworkhelp humor ibm ideas internet iphone itcontracts jobs kindle laser linkbait lsmeans mainframes marketing mobileapplication msaccess nano netbeans networking news os p2p piracy principles programming rasterizer research sam-being-cute science security sex simulation software spying sql stephenfry study supercomputer supercomputing sweden technology textfield turing turingtest two'scompliment uk virus warehouse ww2





