|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
dissassembled code questions
This is part of a function that does this:
for(int i = 0; i < num; i++) local_buf[i] = arg_buf[i]; //here we load the address of the local buffer into EAX 1) 0x804837d <func+33>: lea 0xffffff28(%ebp),%eax //then we move this address into EDX 2) 0x8048383 <func+39>: mov %eax,%edx //then we add the value of a local counter @ address 0xffffff24(%ebp) to EDX to get the offset inside the local char buffer 3) 0x8048385 <func+41>: add 0xffffff24(%ebp),%edx //then we move the value of the local counter into EAX, OVERWRITING THE STORED ADDRESS OF THE LOCAL BUFFER 4) 0x804838b <func+47>: mov 0xffffff24(%ebp),%eax Questions: -in step 1 what is the point of loading the address into EAX just so we can move it into EDX? why not just do this instead: "lea 0xffffff28(%ebp), %edx"? am i missing something? b/c it seems as tho its pointless, especially since we also overwrite that value in EAX anyways in step 4, yes?
__________________
|
|
#2
|
||||
|
||||
|
-in step 1 what is the point of loading the address into EAX just so we can move it into EDX? why not just do this instead:
"lea 0xffffff28(%ebp), %edx"? Depends on the instruction set and CPU architecture. Maybe there's no instruction to load into edx directly. |
|
#3
|
||||
|
||||
|
i tried this,
asm("lea 0xffffff28(%ebp), %edx"); and it compiled and executed correctly, any other ideas? or is it possible that the compiler is just retarded? ![]() |
|
#4
|
|||
|
|||
|
Just a question, but is (%ebp) the same as [ebp] in intel?
|
|
#5
|
||||
|
||||
|
yes its dereferencing the register
|
|
#6
|
||||
|
||||
|
What happens when you add different optimization options. I presume you compiled this without the -O option. Try compiling it with different optimization levels -O1, -O2, -O3 and see what happens
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > dissassembled code questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|