Professional Documents
Culture Documents
Task-1: Crns 19IT066
Task-1: Crns 19IT066
Task-1
Code:
Create program in c with vi editer.
Run program using below command and create 32-bit object code for above code.
CRNS 19IT066
add()
3) Show the contents of the stack before the call to add(). Specifically show the content
of IP and SP registers. Identify the instructions executed before the prelude to the
function add() and those that are part of prelude of the cell.
So, here 0x0000123c and 0x00001235 are making parameters which we are passing as part of
function call for add.
4) Show the address of the instruction executed after function returns to main().
5) Show how the space of the local variables is created in the prelude to the function
call.
Here as part of function call once call will start it will push old value of base pointer (ebp) on
first instruction and then it will make space for all the local variables in function call by next
2 instructions and then function body will start execution.
CRNS 19IT066
6) Show the contents of the stack during add() Call. Note that the stack grows and
shrinks as a result of function calls made by add(). Specifically show the contents of
the IP and SP registers.
Here, print ebp, esp, eip value before of function call and then executed steps.
CRNS 19IT066
Task -2
Code:
Write the program using vi editor.
Run the program using below command and create 32-bit object code for the file.
1) Compile the code with the options as discussed during the class. Disassemble the
function main() and the function IsPasswordOK().
Disassemble main()
CRNS 19IT066
Disassemble IsPasswordOk()
CRNS 19IT066
2) Identify the instructions that represent the prelude in the main() function call.
CRNS 19IT066
Here instruction prior to address 0x00001291 are part of prelude of main function.
CRNS 19IT066
3) Show the contents of the stack before the Call to IsPasswordOK(). Specifically show
the contents of the IP and SP registers. Identify the instructions executed before the
prelude to the functions IsPasswordOK() and those that are part of the prelude of the
call.
5) Show how the space of the local variables is created in the prelude to the function call
6) Show the contents of the stack before the Call to IsPasswordOK(). Specifically show
the contents of the IP and SP registers.
CRNS 19IT066
7) Show the contents of the stack during IsPasswordOK() Call. Note that the stack grows
and shrinks as a result of function calls made by IsPasswordOK(void). Specifically
show the contents of the IP and SP registers.
CRNS 19IT066