Question
I want the two functions but I want them simple do not make any scanf use two fixed numbers I like 7 and 9 Write
I want the two functions but I want them simple do not make any scanf use two fixed numbers I like 7 and 9
Write two functions in C, a main function and a second function. The main function should call the second function and pass to it two variable of type integer. The second function with add the two integers and return the answer to the main function. The main function will then print to the screen the sum of the two numbers: example The sum of the two numbers is 25 or whatever the answer is. After successfully writing, compiling and running the program, use objdump -D executable filename> to obtain the object dump of your program. Locate the your main function and second function in the object dump and comment each line like your book does on page 226. The page is attached for your convenience. Other examples can be viewed on almost every objdump throughout the book. Lastly, show as many examples as possible that you understand why the objdump contains the information it contains. Examples could include but not limited to: Function/call addresses, operand types, instruction suffix, etc.
Here is the page of the book:
and this is the code I have but I want to use fixed numbers 7 and 9 thanks
#include
sum(a,b); } sum(int x,int y) { int z; z=x+y; printf("Sum of the two numbers is : %d ",z); return 0; }
The stack frame for caller includes storage for local variables arg and arg2, at positions 4 and -8 relative to the frame pointer. These variables must be stored on the stack, since the code must associate an address with them. The following assembly code from the compiled version of caller shows how it calls swap_add: caller: pushl %ebp Save old %ebp movlesp, %ebp Set %ebp as frame pointer subl $24, %esp Allocate 24 bytes on stack movl $534 , -4C%ebp) Set argt to 534 movl $1057, -8(%ebp) Set arg2 to 1057 leal --8 (%ebp), %ax Compute &arg movl %ax, 4C,esp) Store on stack leal -4 (%ebp), %eax Compute Cargi movl Heax, (esp. Store on stack call swap_add Call the swap_add function 10 11 This code saves a copy of Gebp and sets %ebp to the beginning of the stack frame (lines 2-3). It then allocates 24 bytes on the stack by decrementing the stack pointer (recall that the stack grows toward lower addresses). It initializes arg1 and arg2 to 534 and 1057respectively (lines 56), and computes the values of &arg2 and &arg1 and stores these on the stack to form the arguments to swap. add (lines 7-10). It stores these arguments relative to the stack pointer, at offsets 0 and 14 |Is swap_add . Of the 24 bytes allocated for Dcal variables, 8 are used for passing parameters to swap-awa. sed for anything. O
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started