Assembly Language for Beginners
1.10. ACCESSING PASSED ARGUMENTS As we can see, the compact functionf()takes all its arguments from the registers. TheLEAinstruc ...
1.10. ACCESSING PASSED ARGUMENTS imul esi, edi lea eax, [rdx+rsi] ret main: sub rsp, 8 mov edx, 3 mov esi, 2 mov edi, 1 call f m ...
1.10. ACCESSING PASSED ARGUMENTS { return a*b+c; }; int main() { printf ("%lld\n", f(0x1122334455667788, 0x1111111122222222, 0x3 ...
1.10. ACCESSING PASSED ARGUMENTS Multiplication and addition at once (Fused multiply–add) is a very useful operation. By the way ...
1.10. ACCESSING PASSED ARGUMENTS mov w0, 0 ; restore FP and LR ldp x29, x30, [sp], 16 ret .LC7: .string "%d\n" Let’s also extend ...
1.10. ACCESSING PASSED ARGUMENTS The code saves its input arguments in the local stack, in case someone (or something) in this f ...
1.11 More about results returning There are two different addition instructions in MIPS:ADDandADDU. The difference between them ...
1.11. MORE ABOUT RESULTS RETURNING push ebp mov ebp, esp and esp, -16 sub esp, 16 mov DWORD PTR [esp], OFFSET FLAT:.LC0 call put ...
1.11. MORE ABOUT RESULTS RETURNING 1.11.3 Returning a structure. Let’s go back to the fact that the return value is left in theE ...
1.12 Pointers. ptr_to_struct = dword ptr 4 a = dword ptr 8 mov edx, [esp+a] mov eax, [esp+ptr_to_struct] lea ecx, [edx+1] mov [e ...
1.12. POINTERS So we use pointers: probably, there is no better way to solve this task without them. 1.12.2 Returning values. Po ...
1.12. POINTERS _main ENDP ...
1.12. POINTERS Let’s see this in OllyDbg: Figure 1.24:OllyDbg: global variables addresses are passed tof1() First, global variab ...
1.12. POINTERS These variables are zeroed, because non-initialized data (fromBSS) is cleared before the execution begins, [seeIS ...
1.12. POINTERS Let’s trace (F7) to the start off1(): Figure 1.26:OllyDbg:f1()starts Two values are visible in the stack: 456 (0x ...
1.12. POINTERS Let’s trace until the end off1(). In the left bottom window we see how the results of the calculation appear in t ...
1.12. POINTERS Now the global variables’ values are loaded into registers ready for passing toprintf()(via the stack): Figure 1. ...
1.12. POINTERS ret 0 ...
1.12. POINTERS Let’slookagainwithOllyDbg. Theaddressesofthelocalvariablesinthestackare0x2EF854and0x2EF858. We see how these are ...
1.12. POINTERS f1()starts. So far there is only random garbage in the stack at0x2EF854and0x2EF858: Figure 1.30:OllyDbg:f1()start ...
«
2
3
4
5
6
7
8
9
10
11
»
Free download pdf